do not trade if spread is higher as max spread? - page 2

 
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)
       Alert("OrderModify failed: ", GetLastError());
     */
}
:
extern double MaxSpread = 5.0; // Unit here is pips
:
double Spread = Ask-Bid;       // Unit here is price
if(Spread >= MaxSpread * pips2dbl) { return(0);}
 

I tried to simply write it into my buy and sell ie.

((SMA1>SMA2)&&(Ask-Bid<.007) ) 

However I just got traded where the spread was .0244

Can anyone explain why when it is in my buy conditions....how could it have issued a trade?

 
joesheedy: I tried to simply write it into my buy and sell ie. ((SMA1>SMA2)&&(Ask-Bid<.007) ) However I just got traded where the spread was .0244 Can anyone explain why when it is in my buy conditions....how could it have issued a trade?

Show your actual code. We cannot help if we are unable to verify what your code is really doing!

Reason: