Hi,
Declare pipsMa global variable probably will solve.
int pipsMa; void OnTimer() { if(pipsMA< Tradepip &&useMA && checkMA(0,true) && isAvailableOrder()) { double lot = _get_lot_size(Stop_Loss); OpenTrade(Symbol(), OP_BUY, lot); } if(pipsMA< Tradepip && useMA && checkMA(1,true)&& isAvailableOrder()) { double lot = _get_lot_size(Stop_Loss); OpenTrade(Symbol(), OP_SELL, lot); } } bool checkMA(int ty, bool cross=false, int shift=1) { if(!useMA) return true; //HideTestIndicators(false); double ma1=iMA(Symbol(),0,Movingaverage1,sma,mma,apma,shift); double ma2=iMA(Symbol(),0,Movingaverage2,sma1,mma1,apma1,shift); double ma11=iMA(Symbol(),0,Movingaverage1,sma,mma,apma,shift+1); double ma21=iMA(Symbol(),0,Movingaverage2,sma1,mma1,apma1,shift+1); pipsMa = (int)MathFloor(MathAbs(ma1-ma2)/_Point); //HideTestIndicators(false); if(ty==0) { if(cross && ma1>=ma2 && ma11<ma21 ) return true; if(!cross && ma1>=ma2 ) return true; } else if(ty==1) { if(cross && ma1<=ma2 && ma11>ma21 ) return true; if(!cross && ma1<=ma2) return true; } return false; } //+------------------------------------------------------------------+

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 I have this problem that I don't understand how to fix it.
How to call PipsMa from the bool to the OnTimer?