Coding question

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #3360 quote
    Sofitech
    Participant
    Master

    Hello. I have a question about how to modify a code from the library.
    I’ve seen the Renko box on price chart indicator. I would like to know how to modify indicators to make them calculated on the renko box and not on the price. In the Renko indicator, i’ve seen 2 information Top and Bottom of the box. Maybe the middle would be correct… well, the goal would be to have the indicator calculated just like if it was on renko chart.

    So, let’s take for example the “Stair Step” indicator How would you modify the code to make it calculated on renko box indicator ??
    Here is the code :

    //parameters :
    // Step = 0.0010 forex 10 pips, adapt to item you are trading
    // MAperiod = 20

    once ssMA = close
    MA = average[MAperiod](close)

    if(MA > ssMA + Step) THEN
    ssMA = MA
    ELSIF (MA < ssMA – Step) THEN
    ssMA = MA
    ELSE
    ssMA = ssMA
    ENDIF

    RETURN ssMA

    And here is the renko code :

    //parameters :
    // boxsize = 100 //1 hour timeframe default size, adapt it for your 
    
    once topprice = close
    once bottomprice = close - boxsize*2
    
    if(close > topprice + boxsize*2) THEN
       topprice = close
       bottomprice = topprice - boxsize*2
    ELSIF (close < bottomprice - boxsize*2) THEN
       bottomprice = close
       topprice = bottomprice + boxsize*2 
    ELSE
       topprice = topprice
       bottomprice = bottomprice
    ENDIF
    
    
    RETURN topprice as "box top", bottomprice as "bottom box"
    
    
    #3363 quote
    Nicolas
    Keymaster
    Master

    Well, if i understand correctly, you would like to make the stairstep moving average calculated with something else than a classical candle close? And in your case, that would be the close of a renko box? (or my so called indicator..:) )

    #3364 quote
    Sofitech
    Participant
    Master

    Yes ! Correct. To have the same result than on a renko chart… but on candlestick chart with your renko indicator.

    #3365 quote
    Nicolas
    Keymaster
    Master

    First, you’ll have to adapt the renko indicator with a new variable that deal with what is the current close. Because indicators are often calculated on Close, my renko box indicator does not have one.

    if(close > topprice + boxsize*2) THEN
       topprice = close
       bottomprice = topprice - boxsize*2
       boxclose = topprice
    ELSIF (close < bottomprice - boxsize*2) THEN
       bottomprice = close
       topprice = bottomprice + boxsize*2 
       boxclose = bottomprice
    ELSE
       topprice = topprice
       bottomprice = bottomprice
       boxclose = boxclose
    ENDIF

    Then, instead of having :

    MA = average[MAperiod](close)

     

    You should make :

    MA = average[MAperiod](boxclose)

     

    But you have to merge the 2 indicators first. Let me know if it works like you want.

    #3368 quote
    Sofitech
    Participant
    Master

    Thanks a lot for your answer.
    I let you see if it can work like i want and tell me if it is the case.
    Thanks again

    #3370 quote
    Nicolas
    Keymaster
    Master

    sofitech stepMA renko

    Here is the full indicator code :

    //parameters :
    // boxsize = 100 //1 hour timeframe default size, adapt it for your
    // Step = 0.0010 forex 10 pips, adapt to item you are trading
    // MAperiod = 20
    
    boxsize = 100*pipsize
    Step = 10*pipsize
    MAperiod = 20
    
    once topprice = close
    once bottomprice = close - boxsize*2
    once ssMA = close
    
    if(close > topprice + boxsize*2) THEN
      topprice = close
      bottomprice = topprice - boxsize*2
      boxclose = topprice
    ELSIF (close < bottomprice - boxsize*2) THEN
      bottomprice = close
      topprice = bottomprice + boxsize*2
      boxclose = bottomprice
    ELSE
      topprice = topprice
      bottomprice = bottomprice
      boxclose = boxclose
    ENDIF
    
    MA = average[MAperiod](boxclose)
    
    if(MA > ssMA + Step) THEN
      ssMA = MA
    ELSIF (MA < ssMA - Step) THEN
      ssMA = MA
    ELSE
      ssMA = ssMA
    ENDIF
    
    RETURN ssMA
    #3372 quote
    Nicolas
    Keymaster
    Master

    With the boxes, more visual :

    renko boxes MA

    Just change the last line of the indicator by this :

    RETURN ssMA, topprice as "box top", bottomprice as "bottom box"
    #3373 quote
    Sofitech
    Participant
    Master

    Just great. Thanks.

    #3376 quote
    Nicolas
    Keymaster
    Master

    You are welcome. Just ask. 🙂

    #3769 quote
    Nicolas
    Keymaster
    Master

    Hey Sofitech, does it work like you want?

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Coding question


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Sofitech @sofitech Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by Nicolas
9 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/01/2016
Status: Active
Attachments: No files
Logo Logo
Loading...