Download MetaTrader 5
To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
Opengates
165
Opengates 2015.11.23 04:46 

Hi everyone in the house,

I have this challenge in my modification code but what baffled me most is that it only occurs on XAGUSD (SILVER) and works fine on other currencies. Please help check and tell me what I am doing wrong. However, I noticed the XAGUSD is having 2 digits point value i. e 24.23 as currency quote, can this cause it and how do I handle it?

//----------------------------------------------------------------- 
   if(UseBEnTS==true) {
        Symb=Symbol();       
        for(Ticket=OrdersTotal()-1; Ticket>=0; Ticket--) {      
        if(OrderSelect(Ticket,SELECT_BY_POS,MODE_TRADES)) {     
        if(OrderSymbol()==Symb) {
        OP=OrderOpenPrice(); Tip=OrderType(); RefreshRates(); SL=OrderStopLoss();     
//-----  MoveStopLoss Strategies by Levels  --------              
            double Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL); // 
            if(bBE<Min_Dist) bBE=Min_Dist;                     // 
            Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL); //
            if(tTS<Min_Dist) tTS=Min_Dist; 
            //--------------------------------------------------- 4 --
            bool Modify=false;                  // 
            switch(Tip) {
                  case 0 :                          // Buy                
                  if(NormalizeDouble(OP,Digits)>NormalizeDouble(SL,Digits) && 
                  NormalizeDouble(Bid-bBE,Digits)>NormalizeDouble(OP,Digits)) {
                     SL=OP+sPrd; Text="Buy "; Modify=true; }
                    if(NormalizeDouble(OP,Digits)<NormalizeDouble(Bid-tTS,Digits)) {
                     SL=Bid-tTS; Text="Buy "; Modify=true; } break;                         
                  case 1 :                          //  Sell
                   if(NormalizeDouble(OP,Digits)<NormalizeDouble(SL,Digits) && 
                   NormalizeDouble(Ask+bBE,Digits)<NormalizeDouble(OP,Digits)) {
                     SL=OP-sPrd; Text="Sell "; Modify=true;  }
                     if(NormalizeDouble(Ask+tTS,Digits)<NormalizeDouble(OP,Digits)) {
                     SL=Ask+tTS; Text="Sell "; Modify=true;  } }                                
            if (Modify==false) break;                           // while
           //----------------------------------------------------
             TP=OrderTakeProfit(); double Price=OrderOpenPrice(); Ticket=OrderTicket();
             bool Ans=OrderModify(Ticket,Price,SL,TP,0);//
            //--------------------------------------------------- 
             if(Ans==true) { Print("Order ",Text," ", Ticket," has been modified!");
             break; RefreshRates(); } } } } }
 //========================================
qjol
3243
qjol 2015.11.26 13:20  
Opengates:

 

and works fine on other currencies.

 

i wonder how it works at all

 

bool Ans=OrderModify(Ticket???,Price,SL,TP,0);//

OrderModify()

 

bool  OrderModify(
   int        ticket,      // ticket no. not the index in the order pool
   double     price,       // price
   double     stoploss,    // stop loss
   double     takeprofit,  // take profit
   datetime   expiration,  // expiration
   color      arrow_color  // color
   );
/
To add comments, please log in or register