hello,
i'm trying to code an ea that will notify me if some conditions occurs on multitimeframe.
I m using it on M15, M30 and H1, the ea work BUT as i'm attaching it to the m15 charts, when the H1 conditions occurs, it send me the same notification on every new m15 bar until a new H1 bar appear.
how can i have it working on 3 differents cycles independently, so a new bar on smaller timeframe doesn't re-check higher timeframe conditions that have already been notified ?
PS: hope you understand what i mean, english isn't my first language ;-)
thank for the answer, but not exactly, a M15 notification can occurs on every M15 new bar, including xx:00 or xx:30.
Maybe a sample of the code could clarify this.
And this will be attached on a M15 chart. so "Oneverynewbar" function will re-check every conditions and re-send notifications from higher timeframe that have already been signaled.
So basicaly i would need 3 "Oneverynewbar" block, one for each timeframe. But i don't know how to do that..
void OnEveryNewBar1() { if (true == false && false) PipValue = 10; if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10; if (BarTime1 < Time[0]) { // we have a new bar opened BarTime1 = Time[0]; // keep the new bar open time TechnicalAnalysisvolH1(); TechnicalAnalysisvolM30(); TechnicalAnalysisvolM15(); } } void TechnicalAnalysisvolH1() { if (iCustom(NULL, PERIOD_H1, "volume MA mod3",0,2) > iCustom(NULL, PERIOD_H1, "volume MA mod3",1,2)) { SendNotificationH1 (); } } void SendNotificationH1 () { SendNotification( Symbol() + "alert buy H1? "); } void TechnicalAnalysisvolM30() { if (iCustom(NULL, PERIOD_M30, "volume MA mod3",0,2) > iCustom(NULL, PERIOD_M30, "volume MA mod3",1,2)) { SendNotificationM30 (); } } void SendNotificationM30 () { SendNotification( Symbol() + "alert buy M30? "); } void TechnicalAnalysisvolM15() { if (iCustom(NULL, PERIOD_M15, "volume MA mod3",0,2) > iCustom(NULL, PERIOD_M15, "volume MA mod3",1,2)) { SendNotificationM15 (); } } void SendNotificationM15 () { SendNotification( Symbol() + "alert buy M15? "); } int deinit() { if (false) ObjectsDeleteAll(); }
thank for the answer, but not exactly, a M15 notification can occurs on every M15 new bar, including xx:00 or xx:30.
Maybe a sample of the code could clarify this.
And this will be attached on a M15 chart. so "Oneverynewbar" function will re-check every conditions and re-send notifications from higher timeframe that have already been signaled.
So basicaly i would need 3 "Oneverynewbar" block, one for each timeframe. But i don't know how to do that..
thank for the answer, but not exactly, a M15 notification can occurs on every M15 new bar, including xx:00 or xx:30.
Maybe a sample of the code could clarify this.
And this will be attached on a M15 chart. so "Oneverynewbar" function will re-check every conditions and re-send notifications from higher timeframe that have already been signaled.
So basicaly i would need 3 "Oneverynewbar" block, one for each timeframe. But i don't know how to do that..
Errors in your code !
Let current chart is M15, and you want to get some indicator value, from, say, M30, or even from other symbol.
You should write something like this:
int LastError = 1; while(LastError != 0) { double d_MACD_Red_ValueBar2 = iCustom(NULL, 0, es_MACD_IndicatorName, ei_FastEMA, ei_SlowEMA, ei_SignalEMA, 1, 2); LastError = GetLastError(); }
See documentation : Any indicator can be calculated on the data of not only current chart, but also on the data of any available symbol/period. If data (symbol name and/or timeframe differ from the current ones) are requested from another chart, the situation is possible that the corresponding chart was not opened in the client terminal and the necessary data must be requested from the server. In this case,error ERR_HISTORY_WILL_UPDATED (4066 - the requested history data are under updating) will be placed in the last_errorvariable, and one will has to re-request ...
would something like that do the trick??
void TechnicalAnalysisvolH1() { double volH1 = iCustom(NULL, PERIOD_H1, "volume MA mod3",MA_Period, MA_Shift, MA_Method,0,2); double volH1x1 = iCustom(NULL, PERIOD_H1, "volume MA mod3",MA_Period, MA_Shift, MA_Method,1,2); { if (volH1 > volH1x1) { TechnicalAnalysisCANDLEH1(); SendNotificationH1 (); } } }
if (iCustom(NULL, PERIOD_H1, "volume MA mod3",0,2) > iCustom(NULL, PERIOD_H1, "volume MA mod3",1,2))
- Why are you looking at two bars back?
- Why are you not doing it as a standard bidirectional crossover?
double buf0Cur = iCustom(NULL, PERIOD_H1, "volume MA mod3",0,1), buf0Pre = iCustom(NULL, PERIOD_H1, "volume MA mod3",0,2), buf1Cur = iCustom(NULL, PERIOD_H1, "volume MA mod3",1,1), buf1Pre = iCustom(NULL, PERIOD_H1, "volume MA mod3",1,2); bool wasGTR = buf0Pre > buf1Pre, isGTR = buf0Cur > buf0Pre; if(isGTR != wasGTR) // Crossed.
- or unidirectional crossover?
if(isGTR && !wasGTR) // Just went above.
- Don't write things more than once. Why did you not factor the three functions into one function since the only thing changing is the TF?
- Don't write things more than once. You should also encapsulate the iCustom calls as one simple function. Detailed explanation of iCustom - MQL4 forum
- Why are you looking at two bars back?
- Why are you not doing it as a standard bidirectional crossover?
- or unidirectional crossover?
- Why did you not factor the code into a function since the only thing changing is the TF?
i'm not a programmer, just learning slowly...
1- yes 2 bars back, others conditions come @ current+1
2-3 just don't know how to do all that
4- looks interresting, same thing, don't know how to...
i'm not a programmer, just learning slowly...
4- looks interresting, same thing, don't know how to...
Hi, here is a link about using function parameters. https://book.mql4.com/basics/functions
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
i'm trying to code an ea that will notify me if some conditions occurs on multitimeframe.
I m using it on M15, M30 and H1, the ea work BUT as i'm attaching it to the m15 charts, when the H1 conditions occurs, it send me the same notification on every new m15 bar until a new H1 bar appear.
how can i have it working on 3 differents cycles independently, so a new bar on smaller timeframe doesn't re-check higher timeframe conditions that have already been notified ?
PS: hope you understand what i mean, english isn't my first language ;-)