Infinite Loop – While in If function

Forums ProRealTime English forum ProBuilder support Infinite Loop – While in If function

Viewing 9 posts - 1 through 9 (of 9 total)
  • #95901

    I have a problem to find a solution for an infinite loop problem. The code below works fine, but with a while command in the if function, I receive the infinite loop message. The code should do the following:

    • The if function is the trigger to set pb = 1 and calculate krange/kprice/kbuy
    • Now pb should remain at 1 and krange/kprice/kbuy should be calculated on every new bar UNTIL close < lowerband
    • I supposed after the if line: while close < lowerband do

    Any idea?

     

    #96025

    I don’t know the entire code, so it is difficult to make a precise answer, but I think that there should be another way to make the calculation avoiding the while/wend loop. I do not see any count variable increasing?

    Why not just using: if close<lowerband then .. endif ?

    #96052

    Count simply counts bars outside of a band in relation to a defined bar range – this works fine. The if function is now the trigger for the first close below the upperband – works also fine – but only for one Bar. But now, if this trigger is 1 it should remain at 1 until close < lowerband or close > upperband…In other words: If the trigger is at 1, I want to screen until close is between upperband/lowerband and if close is outside of the bands trigger should 0. Do you know what I mean?

     

    #96070

    Not really sure of what you want to achieved, it is still part of a complete code and some variables are missing for a better understanding, but:

    it has no start and no end, that’s why you fell into an infinite loop.
    BTW, is pullbuy the same variable as pbuy?

    #96088

    Sorry…it’s only “pullbuy” – pullbuy/pbuy was a copy/paste error. BUT I don’t need a solution for the first if function – This works fine, like described above. I need a solution for the second if function – In this function pb is triggerd to 1 and should remain at 1 UNTIL close is within upperband/lowerband. I don’t have more code – consider upperband/lowerband just as Bollinger Bands.

     

     

     

    #96090

    Something like this perhaps. Not tested.

     

    1 user thanked author for this post.
    #96102

    YES, thats the solution. Thanks Vonasi and Nicolas!

    #96104

    No problem – glad we finally worked out what it was that you wanted! Don’t forget that you can click ‘Thanks’ on any helpful replies.

    On a separate note – did you spot that the indicator you requested elsewhere is now in the library:

    https://www.prorealcode.com/prorealtime-indicators/candlesticks-ohlc-yearly-quarterly-monthly-weekly-daily-h4-h1/

    I only ask because you have not replied to the topic.

    1 user thanked author for this post.
    #96137

    No, I didn’t saw it. Thanks for the info….it looks great.

Viewing 9 posts - 1 through 9 (of 9 total)

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