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

To add comments, please log in or register
Forex Trader
114484
Forex Trader  
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.
Forex Trader
114484
Forex Trader  
You can iCustom(NULL, PERIOD_4H, "MyIndicator", 0, iBarShift(PERIOD_4H, Time[shift]));



Markus
Forex Trader
114484
Forex Trader  

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?
Forex Trader
114484
Forex Trader  
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
Forex Trader
114484
Forex Trader  
and if the MyIndicator return two data like Bollinger Band. how to adjust the iCustom()
Forex Trader
114484
Forex Trader  
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
Forex Trader
114484
Forex Trader  
THANKS, MARKUS.
IF I WANT TO DEVELOP USING MQL II IN METATRADER 3.8X. HOW TO DO THAT?
Forex Trader
114484
Forex Trader  
Zhou

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


Markus
Forex Trader
114484
Forex Trader  
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.
Forex Trader
114484
Forex Trader  
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.

To add comments, please log in or register