Request Help for Code Summation

Forums ProRealTime English forum ProBuilder support Request Help for Code Summation

Viewing 12 posts - 1 through 12 (of 12 total)
  • #216508

    Hi everyone,

    I need help to understand how to code a condition, maybe two. As you can see in attachment, there is an oscillator. I’d like to define the condition of this generic indicator as follow:

    1) oscillator has to be in red condition , so indicator<0 more than for example 50 bars.

    2) then second condition oscillator has to be green no more than 10 bars

    3)oscillator has to cross Zero line from green to red, that is the trigger Short in this case.

    How could I code it?

    thank’s in advance to everyone that can help me.

    Alessio

    #216517

    in particular the indicator is B.M.I. angle.

    https://www.prorealcode.com/prorealtime-indicators/b-m-i-angle-of-ma/

    how can I create those conditions?  Hope Roberto can help me

    // — settings
    //Periode = 10 //Période de la MM
    //nbChandelier= 20 // Nombre de chandeliers sur lesquels on évalue la pente
    // — end of settings

    MM = Exponentialaverage[Periode](close)
    ADJASUROPPO = (MM-MM[nbchandelier]*pipsize) / nbChandelier
    ANGLE = (ATAN(ADJASUROPPO))
    if angle>0 then
    r=0
    g=255
    else
    r=255
    g=0
    endif

    RETURN angle coloured(r,g,0) style(histogram) as “Angle”, 0 as “level 0”

     

    #216518

    Hi,

     

     

    #216534

    Hi JC,

    thank you for your answer. I have a question: C3 means that condition is true if Bar are exactly 50 ?if I need more than 50 bars, Should I write C3=summation[50](c1)>50 ?

    what does C3[1] mean?  previous condition of C3 ?but which one? I don0t understand the code

    thank you in advance for your answer

    Alessio

    #216535

    Hi,

    C3 means it’s true if C1 was true 50 times out of 50 in the latest 50 candles, meaning the one it’s read on and its 49 previous ones. So if this is true regardless of how many more red bars there was before these 50, then the “more than 50” case is covered.

    C3[1] means value of C3 for previous candle before the one it’s read on (writing c3[2] would have been value of C3 2 candles ago, etc…).

    #216542

    Thank you very much for your explanation. Is it too much if I ask you also the long side of the same code?

    1) oscillator has to be in green condition , so indicator>0 more than for example 50 bars.

    2) then second condition oscillator has to be red no more than 10 bars

    3)oscillator has to cross Zero line from red to green, trigger Long.

     

    thank you very much in advance

    alessio

    #216543

    Here is added long side too:

     

     

    #216592

    thank you. for some reasons condition N°2, related to C5 and C9 do not work, I don’t know why.

    #216597

    I would not know how this works out by guarantee or better : what is intended, without braces. E.g. :

     

    #216639

    c2= angle>0

    what do you mean “c2 does not work”? Please describe in details what you consider as not working, or we are left guessing multiple hypothesis from “just a potential typo in copy/paste, but which one…”, to “trying to find cases with c2 true when it should be wrong”, via “c2 works but conditions with use of c2 don’t give intended results”, etc…

    #216640

    The “…and (c4[1] or c5[1])” was there to either initialize the series of c5 with a c4 at previous candle (c4[1]), or subsequently for a new c5 to be preceded itself by a c5 at previous candle (c5[1]). The purpose was to rule out the few cases where a c4 occurs but is quickly followed by a c1 and then by a c2 again, all within 10 bars. So a series of c5 only occurs directly after c4, no unbroken chain of events.

    #216670

    Hi JC, adding the braces it works. thank’s for the code! very appreciated

    Alessio

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

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