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 :
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"
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..:) )
Yes ! Correct. To have the same result than on a renko chart… but on candlestick chart with your renko indicator.
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.
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

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
With the boxes, more visual :

Just change the last line of the indicator by this :
RETURN ssMA, topprice as "box top", bottomprice as "bottom box"
You are welcome. Just ask. 🙂
Hey Sofitech, does it work like you want?