Download MetaTrader 5

Experts: ORDER MANAGEMENT FOR EA DEVELOPMENT - v1.5

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
185418
MetaQuotes Software Corp.  

ORDER MANAGEMENT FOR EA DEVELOPMENT - v1.5:

ORDER MANAGEMENT FOR EA DEVELOPMENT - v1.5

Author: ardiansyah

whroeder1
15591
whroeder1  
  1. stoploss = NormalizeDouble(Bid-sl*Point,Digits);
    takeprofit = NormalizeDouble(Ask+tp*Point,Digits);
    
    Does not adjust for 5 digit brokers (TP, SL, AND slippage)
    //++++ These are adjusted for 5 digit brokers.
    double  pips2points,    // slippage  3 pips    3=points    30=points
            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
    
    On ECN brokers you must orderSend and then set tp/sl
  2.              for(i=0; i<total; i++)
                  {
                 if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
                      {
                         if(Symbol() == OrderSymbol())
    
    When closeing in the presence of multiple orders (multiple charts) you MUST count down.
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
    

  3. Doesn't use a magic number, so in incompatible with all other EAs and manual trading.
To add comments, please log in or register