How to plot custom indicator result of higher timeframe on a lower timeframe chart?

 
for example:
if i calculate simple moving average on GBPUSD on 4h timeframe, i would get a result every four hours, suppose it was 1.7823 for 2005.10.28 16:00; 1.7815 for 2005.10.28 20:00. how can i plot the 4h result of SMA on a lower timeframe chart, such as 15min chart. thus from the 2005.10.28 16:00 to 2005.10.28 19:45, totally 4*4=16 bars have 1.7823 static plotted, from 2005.10.28 20:00 to 2005.10.28 23:45 totally 4*4=16 bars have 1.7815 static plotted.

how can i achieve the target?
and can i found a function in mql 4 to apply? like timeframexchange(CustomIndicator,4H),means calculate the self-defined indicator CustomIndicator for 4h timeframe, and plot the static result on recent lower timeframe chart.
 
You can iCustom(NULL, PERIOD_4H, "MyIndicator", 0, iBarShift(PERIOD_4H, Time[shift]));



Markus
 

You can iCustom(NULL, PERIOD_4H, "MyIndicator", 0, iBarShift(PERIOD_4H, Time[shift]));

Markus



Dear Markus, thank you very much.

one more question:

if applying iCustom() function on MyIndicator as iCustom(NULL, PERIOD_4H, "MyIndicator", 0, iBarShift(PERIOD_4H, Time[shift])) to plot the result on a 15min chart, When a new 15min bar appear, whether the result be recalculated based on the lately 4*4=16 bars, and everytime a new 15min bar appear, a new result will be given?
 
It is up to you to recalculate the. Your start() function will be called on every tick and which part of the chart you redraw is up to you.


Markus
 
and if the MyIndicator return two data like Bollinger Band. how to adjust the iCustom()
 
You will need two calls. The mode parameter in the iCustom() call (parameter before the shift) controls which of the buffers you want to fetch from the other indicator.


Markus
 
THANKS, MARKUS.
IF I WANT TO DEVELOP USING MQL II IN METATRADER 3.8X. HOW TO DO THAT?
 
Zhou

sorry, I hardly use MQ2. I don't know if it offers this function.


Markus
 
MT 3.x does not offer access to other time frames than the current chart.

Sorry, this may be just semantics, but actually the script has no say on how/when the chart draws. All one can do is set values in the indicator buffers and/or post objects to be drawn. MT does the actual instigation of the chart drawing.
 
Shimodax :

You can iCustom(NULL, PERIOD_4H, "MyIndicator", 0, iBarShift(PERIOD_4H, Time[shift]));



Markus

Markus, wanted to thank you for pointing this out.

JForex.

Reason: