Creating an average line from a mtf buffer

 

Hi,

The values from the lines are in buffers. How can I calulate and draw an average line from each line?

 

Please be more clear!

  • Are you wishing to modify the original Indicator, in order to also show the average?
  • Are you wishing just to calculate the average in a separate Indicator using the results of iCustom() for the base indicator in question?

If the former, just add more buffers and calculate the Moving Average in the same way used in the example code "Custom Moving Averages.mq4" in the Indicators folder.

If the latter, then you can use the same example code, but use iCustom() to obtain the data from the base indicator.

 

I want to see the lines not with the steps, I want to see it as continous line.

The best would be I can calculate the average price beween the last 2/3 different prices.

How can I do that calculation in a good way, so that the indicators hasn't work to much.

 
iMAOnArray()
 

Thanks, but it isn't working. I tried:

double test =iMAOnArray(PDailyBuffer,0,3,0,MODE_SMA,0);

And PDailyBuffer is my indicator buffer from that line. But the variable test is always EMPTY_VALUE
even I can see the PDailyBuffer line.

 
Are you filling the PDailyBuffer before calling iMAOnArray ?
 
sunshineh:

I want to see the lines not with the steps, I want to see it as continous line.

The best would be I can calculate the average price beween the last 2/3 different prices.

How can I do that calculation in a good way, so that the indicators hasn't work to much.

I think you don't understand what a Multi-Time-frame (MTF) Indicator is. If it is representing data from higher time-frames, then it will always be in "steps".

You can only get around that, if the type of indicator can be calculated with equivalent representation based on lower time frame data, but in that case you don't need to use the MTF indicator.

For example, a MTF Moving Average of a Daily time-frame shown on an H1 time-frame can be approximated by multiplying the period with the time-frame ratio. So if your are using a MA(9) on the daily then the equivalent on the H1 is an MA(216) where 216 = 9 * 24 (hours in a day). However, this is only possible if the indicator calculation lends itself to this sort of equivalent approximations. For the rest, there are the standard "stepped" MTF indicators.
Reason: