How to code UNTIL?

Forums ProRealTime English forum ProOrder support How to code UNTIL?

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

    Hi

    I’m trying to code UNTIL using the below example. I used IF, WHILE and BREAK but an infinite loop was detected and stopped the backtest. Help please to correct my code.

    If my long trade closes early due to a stop loss, then I don’t want the system to enter into another long trade while x is still greater than y UNTIL  y > x i.e. exit long position condition is met which should reset a back to zero.

    I have tried to code a = 1 whilst x is still greater than y when my long trade closes early due to a stop loss.

    Thanks

    Sachin

    #113084

    It’s an infinite loop, in between WHILE ….WEND initial conditions  never change.

    Indeed there’s no need for an iteration, another IF…ENDIF will do.

    Replace lines 7-12 with:

     

    2 users thanked author for this post.
    #113144

    Thanks Roberto

    However, wouldn’t the suggested code change prevent the next long trade even after y becomes greater than x if there is no other trade executed after the stop loss exit trade?

    #113147

    You’ll have to assign a different value to a when it’s time to, not always.

    Replace line 4 with:

    Then you’ll need to add:

    somewhere in the code to reenable trading when you want to, according to your conditions.

     

     

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