Command CROSSES OVER bug, normal behavior or wrong coding?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #23473 quote
    Nikita
    Participant
    New

    Dear all,

    I’ve set a condition like this:

    c1 = xClose CROSSES OVER indicator1

    where XClose is the closure of an Heking Ashi and indicator1 it’s a Moving Average.

    I’ve noticed it openes position even if HA opens above MA then HA-low crosses under the MA and finally the HA-Close come back and closes over MA.

    So it looks like the CROSSES OVER command is true in these two cases:

    1. Open is below MA and close is above MA.
    2. Open and close are both above MA but low crosses under MA.

    Do you think it’s normal behavior, a bug or a mistake in coding of the condition?

    Thank you all!

    #23498 quote
    Derek
    Participant
    Veteran

    Hello Nikita,

    please check if your chart is set to to show the whole 24 hours including sundays. I had a rather similar problem a few weeks ago and this was the solution.

    #23591 quote
    Nikita
    Participant
    New

    Dear Derek,

     

    thanks for you answer, could you please help me to find that options you said?

    I had a look in charts option and time zone and trading hours but I couldn’t find it.

     

    I would like to add that I compared that chart with investing.com one.

    It’s a candle at 10.15 of 01/02/2017 and it looks like on both charts (prorealtime and investing.com) as a Doji, but in prorealtime the low crosses under the MA instead it does not crosses under the MA in investing.com chart.

    Thank you again

    #23612 quote
    JC_Bywan
    Moderator
    Master

    Looks like normal behaviour to me, as long as the xclose of previous candle was below your indicator1, and the xclose at completion of current candle is above your indicator1, the “xclose crosses over indicator1” statement is true, regardless of what the low did.

    Yes it can be untrue while current candle is not complete yet and xclose has gone below indicator1 again, but as far as logic at completion of candle is concerned, xclose went above at end of candle, so it did cross over, doesn’t matter where the low is, no problem there.

    Only if you had coded “low crosses over indicator1” would the cross over remain untrue at end of candle.

    PS: I think Derek’s problem was rather due to different results between probuilder and probacktest/proorder because of taking into account cfd weekend data (apologies if I mistakenly mix it up with another topic). Doesn’t seem to be related here considering you don’t mention comparative results of probuilder and proorder.

    #23634 quote
    Nikita
    Participant
    New

    Hi Noobywan,

     

    thank you for the answer, but the previous closure was already above the MA and actually the previous 7/8 HA bars had closure above MA

    What could it be than?

     

    Thank you

    #23636 quote
    Nicolas
    Keymaster
    Master

    @Nikita,

    Are you sure of your Heikin Ashi candlesticks calculation? Please provide the code to see if it’s ok. Did you test your HA returned values with the Heikin Ashi candlesticks of the platform already?

    #23639 quote
    JC_Bywan
    Moderator
    Master

    Ok, you didn’t mention in first post that xClose was already above MA in previous candle (opening above at current candle is not necessarily equal to having closed above at previous candle because of possible gap between two candles). In that case, it’s likely there’s a bug somewhere in the code that might affect the value of either xClose or indicator1 and/or c1.

    If this is a backtest the best way to debug is to use the GRAPH function (works from PRT v10.2 but not older versions I think) by adding those lines at end of backtest:

    GRAPH c1 as “c1”

    GRAPH xClose as “xClose”

    GRAPH indicator1 as “indicator1 ”

    and verify they behave as expected.

    If not, the instances when they don’t behave as expected would provide clues to search for the bug(s)

    #23640 quote
    JC_Bywan
    Moderator
    Master

    (Oops sorry Nicolas, didn’t see you answered already while I was editing my answer)

    #23643 quote
    Nicolas
    Keymaster
    Master

    (no worries Noobywan, your answers are always valuable, no matter if I answer myself to the topic too).

    #23674 quote
    Nikita
    Participant
    New

    Thank you all for the answers!


    @Noobywan
    : you are right I didn’t specify it because I thought CROSSES OVER meant that the current candle open below the MA and close above it. I did know I should consider the previous xclose to be below MA and current xclose to be above MA. Thank you a lot to clarify.

    I think to have that condition I have to use something like this:

    c1 = xOpen < indicator1 and xClose > indicator1

    About that position I mentioned you were right I think, I had a better look to the charts and the bar before the doji was a bearish HA and close  was few decimal of pips below the MA which were rounded like this:

    MA: 1,0792

    Xclose: 1,0791

    Instead investing.com reports them as both at 1.0792 and a loss postion would have not been opened.


    @Nicolas
    , here is the HA, I will post them to be sure:

    xClose = (open+high+low+close)/4
    IF BarIndex=0 THEN
    xOpen = open
    xHigh = high
    xLow = low
    ELSE
    xOpen = (xOpen[1] + xClose[1])/2
    xHigh = Max(Max(high, xOpen), xClose)
    xLow = Min(Min(low, xOpen), xClose)
    ENDIF

    and this too (even if I’m using the first and the results do not changes):

    IF BarIndex = 0 THEN
    XClose = TotalPrice
    XOpen = (Open + Close) / 2
    xHigh = high
    xLow = low
    ELSE
    XClose = TotalPrice
    XOpen = (XOpen[1] + Xclose[1]) / 2
    xHigh = Max(Max(high, xOpen), xClose)
    xLow = Min(Min(low, xOpen), xClose)
    ENDIF

    Thank you all again for your support and sorry for the bad reading value, anyway I’ve learned how the CROSSES OVER and UNDER behave.

    Now I will have to study a way to avoid this situation.

    Thank you!:)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Command CROSSES OVER bug, normal behavior or wrong coding?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Nikita @nikita Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Nikita
9 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/01/2017
Status: Active
Attachments: No files
Logo Logo
Loading...