+ Reply to Thread
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,455

    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?

+ Reply to Thread

Similar Threads

  1. The most popular MT4 brokers
    By funyoo in forum Metatrader brokers
    Replies: 37
    Last Post: 01-06-2012, 22:09
  2. Peter EA
    By peter1977 in forum Ideas for expert advisors
    Replies: 1
    Last Post: 10-30-2009, 17:44
  3. Funyoo could you modify this ea
    By peter1977 in forum MQL programming
    Replies: 1
    Last Post: 10-30-2009, 16:13
  4. Modify indicator
    By seek3 in forum MQL programming
    Replies: 0
    Last Post: 10-02-2009, 07:45
  5. Brokers Time Conversion
    By Passion Trader in forum Metatrader brokers
    Replies: 10
    Last Post: 07-21-2009, 21:57

Posting Permissions

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