Why can't EA run at other broker?

 

I have just written my first EA and have done some back testing which looks promising and am running it on a demo account with one broker. I have heard that EA's can perform differently at different brokers so have opened another demo account with a different broker. I have placed the EA and its include files in the correct folders and the EA appears under the experts on the MT4 platform, but when I want to drag and drop it onto a chart it does not want to function. It does not open the screen for inputs, etc. As a matter of fact nothing happens.

Can anybody please tell me why this EA is not working at a different broker?

 

Did you enable EAs in your other copy of MetaTrader under Tools -> Options -> Expert Advisors?

 
roy7:

Did you enable EAs in your other copy of MetaTrader under Tools -> Options -> Expert Advisors?

Absolutely! Makes no difference!
 
  1. Does the EA just for 5 digit brokers, TP, SL, AND slippage. On ECN brokers you must open the order and THEN set tp/sl
    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
    

  2. Does the EA have hard coded broker specific values such as minlot and lotstep, or does it compute lot size correctly.
        double  minLot  = MarketInfo(Symbol(), MODE_MINLOT),
                lotStep = MarketInfo(Symbol(), MODE_LOTSTEP),
                perLotPerPoint  = PointValuePerLot(),
    size=???
            size = MathFloor(size/lotStep)*lotStep;
            if (size < minLot){ ...
        return(size);   // We're good to go.
    }   // LotSize
    double  PointValuePerLot() { // Value in account currency of a Point of Symbol.
        /* In tester I had a sale: open=1.35883 close=1.35736 (0.00147)
         * gain$=97.32/6.62 lots/147 points=$0.10/point or $1.00/pip.
         * IBFX demo/mini       EURUSD TICKVALUE=0.1 MAXLOT=50 LOTSIZE=10,000
         * IBFX demo/standard   EURUSD TICKVALUE=1.0 MAXLOT=50 LOTSIZE=100,000
         *                                  $1.00/point or $10.00/pip.
         *
         * https://forum.mql4.com/33975 CB: MODE_TICKSIZE will usually return the
         * same value as MODE_POINT (or Point for the current symbol), however, an
         * example of where to use MODE_TICKSIZE would be as part of a ratio with
         * MODE_TICKVALUE when performing money management calculations which need
         * to take account of the pair and the account currency. The reason I use
         * this ratio is that although TV and TS may constantly be returned as
         * something like 7.00 and 0.00001 respectively, I've seen this
         * (intermittently) change to 14.00 and 0.00002 respectively (just example
         * tick values to illustrate). */
        return(  MarketInfo(Symbol(), MODE_TICKVALUE)
               / MarketInfo(Symbol(), MODE_TICKSIZE) ); // Not Point.
    }
    

 

William,

I don't hard code.

The following snippets show how i am trying to code generically

Here is my verification of the lotsize

                   // Verify Lotsize
                   if(dLotSize < MarketInfo(Symbol(),MODE_MINLOT))
                           {
                                  dLotSize = MarketInfo(Symbol(),MODE_MINLOT);
                           }
                    else if(dLotSize > MarketInfo(Symbol(),MODE_MAXLOT))
                           {
                                  dLotSize = MarketInfo(Symbol(),MODE_MAXLOT);
                           }    
                        
                    if(MarketInfo(Symbol(),MODE_LOTSTEP) == 0.1)
                           {
                                  dLotSize = NormalizeDouble(dLotSize,1);
                           }
                    else dLotSize = NormalizeDouble(dLotSize,2); 

And here is my function to address the different decimal places in prices for different brokers and securities/instruments

     double PipPoint(string Currency)
        {
                int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
                if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
                else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
                return(CalcPoint);
        }
 
WHRoeder:
  1. Does the EA just for 5 digit brokers, TP, SL, AND slippage. On ECN brokers you must open the order and THEN set tp/sl
  2. Does the EA have hard coded broker specific values such as minlot and lotstep, or does it compute lot size correctly.

I had another look at your answer to see if I missed something.

I take note of your info that ECN brokers operate differently and the tp/sl must be set AFTER the order has been placed.

Is this true for market orders AS WELL AS Pending Orders?