use static with time, try some search
Samuel Akinbowale:
use static with time, try some search
https://www.mql5.com/en/forum/129048
use static with time, try some search
I tried with new code:
But why when e = 0, condition for if function is not ok, but it still Alert repeatedly?!!
void OnTick()
{
double a = iHigh(Symbol(), PERIOD_M15 ,0);
double b = iLow (Symbol(), PERIOD_M15,0);
double candle = a - b;
double e = 1;
if ( candle > 0.20 && e > 0)
{ e = e -1;
Alert( "Candle Alert on: ", candle);
};
return;
}
double candle = a - b; if ( candle > 0.20 ){ Alert( "Candle Alert on: ", candle);
You're running that code every tick. Why do you expect it to not repeatedly alert, once the current M15 bar becomes larger than 20 pips on JPY pair or 2000 pips on others.
What is a TICK? - MQL4 and MetaTrader 4 - MQL4 programming forum- Either only check once on a new bar or Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
New candle - MQL4 and MetaTrader 4 - MQL4 programming forum - Stop opening new posts. This is the fourth time you have been answered. The others have been deleted.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear pro,
I try to code EA to alert if bar length > 20pip in M15 chart. But when running, alert is continuous and cannot stop. I just need alert 1 time/1 bar. Pls help me to check code below. Thanks a lot!
void OnTick()
{
double a = iHigh(Symbol(), PERIOD_M15 ,0);
double b = iLow (Symbol(), PERIOD_M15,0);
double candle = a - b;
double e = 2;
if ( candle > 0.20 && e > 0)
{ e = e -1;};
if ( e ==1)
{
Alert( "Candle Alert on: ", candle);
};
return;
}