TradingOnline:
hello,
I'm trying to use this EA https://www.mql5.com/en/forum/2910/page1
Why when I use the EA it open immediately a position and not wait for the first crossover?
How can fix it?
I want wait first crossover to open a new position
Can you help me with the code?
You need to modify code inside signalma.mqh
bool CSignalMA::CheckOpenLong(double& price,double& sl,double& tp,datetime& expiration) { price=0.0; sl =0.0; tp =0.0; //--- return(StateOpen(1)<0 && StateClose(1)>0 && StateMA(1)>0); } //+------------------------------------------------------------------+ //| Check conditions for long position close. | //| INPUT: price - refernce for price. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckCloseLong(double& price) { price=0.0; //--- return(StateOpen(1)>0 && StateClose(1)<0 && StateMA(1)<0); } //+------------------------------------------------------------------+ //| Check conditions for short position open. | //| INPUT: price - refernce for price, | //| sl - refernce for stop loss, | //| tp - refernce for take profit, | //| expiration - refernce for expiration. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckOpenShort(double& price,double& sl,double& tp,datetime& expiration) { price=0.0; sl =0.0; tp =0.0; //--- return(StateOpen(1)>0 && StateClose(1)<0 && StateMA(1)<0); } //+------------------------------------------------------------------+ //| Check conditions for short position close. | //| INPUT: price - refernce for price. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckCloseShort(double& price) { price=0.0; //--- return(StateOpen(1)<0 && StateClose(1)>0 && StateMA(1)>0); } //+------------------------------------------------------------------+
become (you can try this as another example of crossover MA)
bool CSignalMA::CheckOpenLong(double& price,double& sl,double& tp,datetime& expiration) { price=0.0; sl =0.0; tp =0.0; //--- return(StateOpen(2)<0 && StateOpen(1)>0 && StateClose(1)>0); } //+------------------------------------------------------------------+ //| Check conditions for long position close. | //| INPUT: price - refernce for price. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckCloseLong(double& price) { price=0.0; //--- return(StateOpen(2)>0 && StateOpen(1)<0 && StateClose(1)<0); } //+------------------------------------------------------------------+ //| Check conditions for short position open. | //| INPUT: price - refernce for price, | //| sl - refernce for stop loss, | //| tp - refernce for take profit, | //| expiration - refernce for expiration. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckOpenShort(double& price,double& sl,double& tp,datetime& expiration) { price=0.0; sl =0.0; tp =0.0; //--- return(StateOpen(2)>0 && StateOpen(1)<0 && StateClose(1)<0); } //+------------------------------------------------------------------+ //| Check conditions for short position close. | //| INPUT: price - refernce for price. | //| OUTPUT: true-if condition performed, false otherwise. | //| REMARK: no. | //+------------------------------------------------------------------+ bool CSignalMA::CheckCloseShort(double& price) { price=0.0; //--- return(StateOpen(2)<0 && StateOpen(1)>0 && StateClose(1)>0); } //+------------------------------------------------------------------+
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
hello,
I'm trying to use this EA https://www.mql5.com/en/forum/2910/page1
Why when I use the EA it open immediately a position and not wait for the first crossover?
How can fix it?
I want wait first crossover to open a new position
Can you help me with the code?