Condition met, Buy below certain price in the future bars

Forums ProRealTime English forum ProOrder support Condition met, Buy below certain price in the future bars

Viewing 3 posts - 1 through 3 (of 3 total)
  • #221700

    Hi

    I am trying to code in PRT and when backtesting it is not giving the desired results, as it is NOT buying at the TargetPrice, seems I am not getting it right.

    Attached screenshot for reference, where the condition met at Bar 1583 with my TargetPrice to buy at 14737.2, but it is bought at Bar 1585 at a price 14816.5.

    My TargetPrice and CloseReferencePrice are also changing for each bar, and BuyBar and CurrentBar are also the same when the code runs for backtesting.

    Could please advise how this should be done i.e. Buying at the TargetPrice within the next 5 bars when the C1 condition is met,  with the below script:

    Thanks

    Harry

    #221720
    JS

    Hi Harry,

    It goes wrong by “resetting” the variables every time the code is executed…

    Use “Once” here and reset the variable “BuyFlag” when you are actually in a “Long” position…

     

    2 users thanked author for this post.
    #221736

    Hi JS

    Thanks for this insight, very much appreciated. I would have never got this right on my own without your help on this, it works now as expected.

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

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