Results 1 to 7 of 7
 0 Attachment(s)    

Thread: Modifications for ECN brokers

  1. #1
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default Modifications for ECN brokers

    Here is the required modifications for ECN brokers with my experts.

    You can replace "pt" and "dg" by the respective point and digits variables for other EAs.

    In the extern parameters, add :

    Code:
    extern bool brokerisecn=false;
    Before each sell Ordersend function, add :

    Code:
    if(brokerisecn==false)
    After each sell Ordersend function, copy the previous line but remove "==false", replace the stoploss and takeprofit by 0.

    For example :

    Code:
    if(brokerisecn)ticket=OrderSend(Symbol(),OP_SELL,lots,bid,slippage*mt,0,0,"",magic,0,Red);
    At the end of the start function, add :

    Code:
    if(brokerisecn){createstoploss(stoploss);createtakeprofit(takeprofit);}
    At the end of the code, add :

    Code:
    void createstoploss(int stoploss){
       RefreshRates();
       double ask=MarketInfo(Symbol(),MODE_ASK);
       double bid=MarketInfo(Symbol(),MODE_BID);
       int total=OrdersTotal();
       if(total>0){
          for(int i=0;i<total;i++){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber){
                if(OrderType()==OP_SELL){
                   if(OrderStopLoss()==0){                 
                      OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ask+stoploss*pt,dg),OrderTakeProfit(),0,Red);
                      return(0);
                   }
                }
             }
          }
       }
    }
    
    void createtakeprofit(int takeprofit){
       RefreshRates();
       double ask=MarketInfo(Symbol(),MODE_ASK);
       double bid=MarketInfo(Symbol(),MODE_BID);
       int total=OrdersTotal();
       if(total>0){
          for(int i=0;i<total;i++){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber){
                if(OrderType()==OP_SELL){
                   if(OrderTakeProfit()==0){                 
                      OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(ask-takeprofit*pt,dg),0,Red);
                      return(0);
                   }
                }
             }
          }
       }
    }

  2. #2
    Junior Member
    Join Date
    Sep 2009
    Posts
    16

    Default ECN Coding

    Hi Funyoo
    I am currently trading with the donchian scalper with an ECN broker should I add this coding into the EA if so I have no idea where to start
    regards Lee

  3. #3
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by leeroy66 View Post
    Hi Funyoo
    I am currently trading with the donchian scalper with an ECN broker should I add this coding into the EA if so I have no idea where to start
    regards Lee
    Hi leeroy66,

    You can let hidesl and hidetp on true for this one. It should be enough.

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    16

    Default

    Thanks Funyoo
    regards
    Lee

  5. #5

    Default

    Very nice template Funyoo...much appreciated.

    I guess we need to add the OP_BUY routines as well here...

    Note to all:

    Some EAs do have dynamic TP and SL: make sure you're referring to the correct variable names in the two functions "void createstoploss()" and "void createtakeprofit()".

    Cheers, S.
    Last edited by Snowski; 12-07-2009 at 15:24.

  6. #6

    Default

    hi funyoo

    would it be possible to just add an ecn true/false option in your experts?

    thanks for all your work

  7. #7
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by AHF896 View Post
    hi funyoo

    would it be possible to just add an ecn true/false option in your experts?

    thanks for all your work
    Hi AHF896,

    There is this option in the last codes.

Similar Threads

  1. Price Bounce Off of MA EA - Excellent Potential Needs Modifications
    By kneal in forum Ideas for expert advisors
    Replies: 4
    Last Post: 12-07-2010, 16:16
  2. Modifications for a 5 digits broker
    By funyoo in forum MQL programming
    Replies: 25
    Last Post: 11-30-2010, 23:18
  3. Replies: 3
    Last Post: 06-14-2010, 16:49

Tags for this Thread

add, broker, brokers, coding, copy, donchian, eas, ecn, experts, magic, scalper, slippage, stoploss, trading

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •