Results 1 to 2 of 2
 0 Attachment(s)    

Thread: Modify ticket for ECN brokers

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

    Default Modify ticket for ECN brokers

    Modification of the ticket once generated to add SL and TP :

    In the extern parameters :

    Code:
    extern bool modifyafter=false;
    If you modify one of my code, after each hidesl==false and hidetp==false, add :

    Code:
    modifyafter==false
    Before the return(0); at the end of the start() function, add :

    Code:
    if(modifyafter){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()==magic){
                if(OrderType()==OP_BUY){
                   if(OrderStopLoss()==0){
                      OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(bid-stoploss*pt,dg),OrderTakeProfit(),0,Blue);
                      return(0);
                   }
                }
                else{
                   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()==magic){
                if(OrderType()==OP_BUY){
                   if(OrderTakeProfit()==0){
                      OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(bid+takeprofit*pt,dg),0,Blue);
                      return(0);
                   }
                }
                else{
                   if(OrderTakeProfit()==0){                 
                      OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(ask-takeprofit*pt,dg),0,Red);
                      return(0);
                   }
                }
             }
          }
       }
    }

  2. #2
    Junior Member
    Join Date
    Oct 2009
    Posts
    11

    Default

    Can you make a ea for example?

Similar Threads

  1. modify SSL_fast_sBar_alert_mtf.mq4
    By tpwd64 in forum Indicators
    Replies: 0
    Last Post: 08-18-2011, 16:46
  2. BB modify - report
    By Roberto76 in forum Ideas for expert advisors
    Replies: 17
    Last Post: 11-20-2009, 18:59

Tags for this Thread

add, broker, brokers, ecn, make a ea

Posting Permissions

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