anything better than "MarketInfo"?

 
I use the following MQL code to keep me out of the market when the spread is greater than 1pip (allowing slippage of 3):

"MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_BID)<=1.0"

My Question is: why am I still observing my EA take trades when spreads are higher than 4 pips?

Can anyone suggest anything better than "MarketInfo" above?



 
If you trade GBPUSD then Ask - Bid will give a result in the region of 0.00020 (2 pips) this is always <=1.0
 
trueresource:
I use the following MQL code to keep me out of the market when the spread is greater than 1pip (allowing slippage of 3):

"MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_BID)<=1.0"

My Question is: why am I still observing my EA take trades when spreads are higher than 4 pips?

Can anyone suggest anything better than "MarketInfo" above?
  1. MarketInfo(Symbol(),MODE_ASK) will ALWAYS equal Ask. Just use Ask/Bid
  2. On the non JPY pairs Ask-Bid will always be something like 0.00020 (i.e. 2 pips) always less than 1.0 (10000 pips)
  3. EA's must adjust for 4/5 digit brokers
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    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(...)
        if (ticket < 0)
           Alert("OrderSend failed: ", GetLastError());
        else if (!OrderSelect(ticket, SELECT_BY_POS))
           Alert("OrderSelect failed: ", GetLastError());
        else if (!OrderModify(OrderTicket()...)
           Alert("OrderModify failed: ", GetLastError());
         */
    ==========
    if (Ask-Bid <= 1.0*pips2dbl){ //ok
  4. What non-commission broker has fractional pip spreads? You might like to add a comment printing the spread and watch it.