English

Modifying the TP

 86 heyarn 2010.07.02 00:42 #   talsabiri: hi all am trying to find a way to modify the TP in several orders to average +20 pips any help? What do you mean? if you want them to all average at 20 pips, then just make them 20 pips. Maybe you mean distributing the 20 pips to all open positions? If you mean the latter, the code below might help.. Gdluck ```//first count the number of orders for(int i=0;i
 3 talal222 2010.07.02 10:17 #   ```//Calculatin the average of the open price for all orders    double counter=0;    double average1=0;    int cnt=0;       for (int i=1; i<=OrdersTotal(); i++)       //Cycle for all orders..      {                                        //displayed in the terminal       if(OrderSelect(i-1,SELECT_BY_POS)==true)//If there is the next one         {               double Price=OrderOpenPrice();                    counter = counter+Price;           cnt++;         average1=counter/cnt;                                         if (cnt== OrdersTotal())         {                  MessageBox("Average is "+average1);                      } } } //Order Modification code f (OrdersTotal() > 0 )      {             } //----    int total,cnt;             total = OrdersTotal();             for(cnt=0;cnt 0 )             {             double x=average1;                          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);             if(OrderType()==OP_BUY) // long position is opened             {                                       OrderModify(OrderTicket(),OrderOpenPrice(),0,x+0.0020,0,Red);             }             }             }```