Horizontal Line for Typical MA.

 

I am trying to draw a horizontal line to show me this weeks Typical MA. I want it as a horizontal line. It does not draw a horizontal line but like a zig zag line up and down with the price value. I want a horizontal line across this weeks price action in any time frame. It will move around with price as it is this weeks forming Typical MA. I have attached the Indicator Code below.

Thank you. 

Files:
 
ForexTrader17:

I am trying to draw a horizontal line to show me this weeks Typical MA. I want it as a horizontal line. It does not draw a horizontal line but like a zig zag line up and down with the price value. I want a horizontal line across this weeks price action in any time frame. It will move around with price as it is this weeks forming Typical MA. I have attached the Indicator Code below.

Thank you. 

It's "zig zagging" because you're feeding every bar in your buffer with different weekly moving average figures. A horizontal line should have the same value for every bar. And if it's just going to be a horizontal line, why not just draw a horizontal line rather than using buffers?

If you do want to continue using a buffer, try changing from this:

 

Buffer1[i] = iMA(NULL, PERIOD_W1, 1, 0, MODE_SMA, PRICE_TYPICAL,i); //Set indicator value at Moving Average

to this

Buffer1[i] = iMA(NULL, PERIOD_W1, 1, 0, MODE_SMA, PRICE_TYPICAL,0); //Set indicator value at current bar Weekly Moving Average
 

Thanks. That worked. And what if I need it draw only for the current week? So start Sunday and end Friday.

Thanks. 

 
Basically I want to draw this weeks Typical MA on the chart. So it will technically update with every tic.