This forum is now read-only. You can discuss you questions on Forums of MQL4.community and MQL5.community

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


Back to topics list
avatar
3
Zh_mingbo 2005.10.30 11:32 
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.
avatar
239
Shimodax 2005.10.30 14:32 

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



Markus

avatar
3
Zh_mingbo 2005.10.30 15:22 

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?
avatar
239
Shimodax 2005.10.30 15:39 

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
avatar
3
Zh_mingbo 2005.10.30 15:59 
and if the MyIndicator return two data like Bollinger Band. how to adjust the iCustom()
avatar
239
Shimodax 2005.10.30 17:32 

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
avatar
6
Zhoumingbo 2005.11.11 14:11 
THANKS, MARKUS.
IF I WANT TO DEVELOP USING MQL II IN METATRADER 3.8X. HOW TO DO THAT?
avatar
239
Shimodax 2005.11.11 16:47 

Zhou

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


Markus
avatar
39
davidwt 2005.11.12 08:00 
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.
avatar
1
JForex 2009.03.13 23:02 
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.

Back to topics list