Aliff102:
Hi,
I have tried this code but I seems to get errors:
I want my EA to only put new entry at the next open candle bar. Do note when click on the error, it refers to the Time[0] inside the if(...) function
Have you tried this?
void OnTick() { static datetime oldTime; if(oldTime != Time[0]) { m_Trade.Buy(lot_size,_Symbol,Ask,(Ask-300*_Point),(Ask+500*_Point),NULL); oldTime = Time[0]; } }
I have solved it by made some changes to the code:
datetime oldTime; void OnTick() { if(oldTime!=iTime(Symbol(),_Period,0)) { m_Trade.Buy(lot_size,_Symbol,Ask,(Ask-300*_Point),(Ask+500*_Point),NULL); oldTime=iTime(Symbol(),_Period,0); } }
Forgot to mention I am using MQL5.

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
Hi,