Code of series of periods

Forums ProRealTime English forum ProBuilder support Code of series of periods

Viewing 15 posts - 1 through 15 (of 25 total)
  • #75475

    Good morning,

    is there anybody who knows if there’s an easier way to write this code, in which the actual close is > or < of a series of previous close like this?

    I need to put in a backtest with a variable X,  that is the last of the series,

    Thanks so much

    Maxx

    #75477

    EDIT: Code is now corrected as discussed further down in this thread.

    #75480

    What about

    ?

    #75482

    As usual I make the job harder than it needs to be! 🙂

    #75484

    As for the Vonasi’s code, ‘count’ variable should be reset to 0 before the FOR/NEXT loop, otherwise it will endlessly increase.

    #75491

    As for the Vonasi’s code, ‘count’ variable should be reset to 0 before the FOR/NEXT loop, otherwise it will endlessly increase.

    So not only harder but it doesn’t work! Why do in one line what you can do in 8. I blame it on the heat…..

    #75498

    But don’t both code options fail to give the OP what he wants?

    OP wanted close of bar 1 > close of bar 2 and close of bar 2 > Close of bar 3 etc … put another way 5 bars with a increasing value of Close?

    #75500

    OP wanted close of bar 1 > close of bar 2 and close of bar 2 > Close of bar 3 etc … put another way 5 bars with a increasing value of Close?

    That is not what he wrote – he wrote this:

     

    #75501

    He always compared CLOSE, not CLOSE[previous bar].

    Anyway, that would be

     

    #75502

    That is not what he wrote – he wrote this:

    Hahaha the heat is getting to all of us, I got it locked in my mind from initial reading  (I should have reread) that he wanted an increasing value of close.

    Cheers

    #75503

    …. and I first wrote that summation code that Robert just posted but then deleted my post when I realised my mistake and then went on to post a very complicated method that didn’t work! It is definitely the heat.

    #75507

    Thanks guys for the replies,  yes Roberto’s code is correct, I have verified.

    My mind was blocked too….actually it was so simple!

    Maxx

    #75516

    CLOSE[previous bar]. Anyway, that would be

    Code added to Snippet Link Library

    #104152

    Sorry for reviving this old topic, but after thinking it over and with a whole additional year experience… VONASI was right (apart from resetting count to 0 at line 2 as suggested by Nicolas).

    My code always compares the current candle to the previous one, which is not exactly what maximus78 wanted. Indeed I believed using CLOSE without brackets would do, but summation reads it as being CLOSE[0], then it shifts both every iteration, so that the next one would be CLOSE[1] compared to CLOSE[2] and so on. CLOSE does NOT remain CLOSE[0] thus making a loop necessary.

     

    #104154

    VONASI was right

    Finally almost thirteen months later I get the recognition that I deserve. I’ve had trouble sleeping at night ever since I posted something that was thought to be wrong. Thank goodness that nightmare is now over. 🙂

    Strangely maximus78 was happy with your code Roberto so perhaps what he wanted and what he described were actually different things? It wouldn’t be the first time someone did that on the forums!

Viewing 15 posts - 1 through 15 (of 25 total)

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