Average range of candles

 

Hello Friends,

I'm working at this idea, and learning how to code, I could not find any example on the internet, I hope you guys could help me.

The initial idea is:

Candles:

0 to 12     =====> x1 ( variable1 )  where x1 is the simple average between 0 to 12

12 to 24     ====> x2 ( variable2 )  where x2 is the simple average between 12 to 24

24 to 36    =====>x3 (variable3 )   where x3 is the simple average between 24 to 36


then: (x1+x2+x3)/3 = z

drawing a Horizontal line on the Chart = HLine value =z


Got it?


Thanks

Reason: