Help with setting limit order to be previous days closing candle

Forums ProRealTime English forum ProOrder support Help with setting limit order to be previous days closing candle

Viewing 4 posts - 1 through 4 (of 4 total)
  • #134348

    Hello ProRealCode community!

    I’m still a bit new to coding and I need a bit of help with something. I have a mean reversion script here that essentially sells/buys the open if we’ve deviated a bit too much from the previous days 9pm candle open.

    Going through the backtest results I’ve noticed that my target limit order was set at the wrong price level- instead of the target being yesterdays 9pm opening candle, it was todays 7am opening candle.

    What I think might’ve happened is the “open” variables got a bit mixed up – I just don’t know how to fix this.

    Any help you can give me with my code will be greatly appreciated. I’ve attached a screenshot with a little example of what went wrong.

    Thanks,

    Aleks

    #134362

    Between lines 10 and 11 insert a new one (wich will become the new line 11):

    whenevr you need to use today’s PREV, use PREV, whenever you need to use yesterday’s PREV use PREVIOUSPREV, instead.

     

    #134386

    Hi Roberto,

    Thanks for taking the time to look into this issue. However, the issue persists. Here’s my code:

    Could you advise if I implemented the right changes?

    Thanks,

    Aleks

    #134493

    Since at line 10 you are using TIME, open will return the OPENing price  od the candle that closes at 210000. If you need the opening price of the candle starting at 210000 then you’ll have to use OPENTIME, instead.

    In line 5 you should use

    (despite Dax makes no difference), but it’s good programming practice when you need to convert pips into price.

    Lines 29 and 35 should read:

    or

     

     

    1 user thanked author for this post.
Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login