Download MetaTrader 5

chart objects

To add comments, please log in or register
bbm24
235
bbm24 2016.09.28 06:29 

Hello,

Some of the objects that typically appear in Strategy Tester are not appearing in my live account.

More specifically,  the entry arrows do appear but the exit arrows and the lines joining the entry and exit arrows do not appear.

Also, the red dashes that mark the stop loss price and the blue dashes that mark the take profit price ALL appear EXCEPT the very first ones.

Can anyone suggest a solution.

Thanks.

BBM 

Marco vd Heijden
Moderator
4728
Marco vd Heijden 2016.09.28 10:11  
bbm24:

Hello,

Can anyone suggest a solution.

Thanks.

BBM 

How about some code?
bbm24
235
bbm24 2016.09.28 10:24  
Marco vd Heijden:
How about some code?

I will ask the guy doing the EA for me for a screen shot. 

bbm24
235
bbm24 2016.09.28 11:49  
bbm24:

I will ask the guy doing the EA for me for a screen shot. 

 Hi Marco,

I am not a coder so I have tried to send part of the EA.

I think the problem will be somewhere in here.

If it is too long I apologize.

Thanks 

 

double LastStop(int type)
   {
      double temp=0;
      datetime tempT=0;
      for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&OrderType()==type&&OrderCloseTime()>tempT)
                     {
                        temp=OrderStopLoss();
                        tempT=OrderCloseTime();
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
// Last open order
double LastOrder()
   {
      double temp=0;
      datetime tempT=0;
      for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&(OrderType()==OP_BUY||OrderType()==OP_SELL)&&OrderCloseTime()>tempT)
                     {
                              temp=OrderProfit();
                              tempT=OrderCloseTime();
                              LastOpenType=OrderType();
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
int InitOrderCount(int Type)
   {
      int temp=0;
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == Type&&OrderMagicNumber()==Magic_Number)
                     {
                              temp++;
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
int InitAllOrderCount()
   {
      int temp=0;
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number)
                     {
                              temp++;
                     }
               }
         }
      return(temp);
   }
//===================================================================================================
void ClearObjects(string name)
   {
      ObjectDelete(0,name);
   }
//===================================================================================================
double CalculateLots(double risk,int stop)
   {  
      double lot=Lot_Size;
      if(Lot_Size==0)
         {
            lot=MarketInfo(Symbol(),MODE_MINLOT);
            double steplot=MarketInfo(Symbol(),MODE_LOTSTEP);
            double monyrisk=NormalizeDouble(AccountEquity()/100*risk,2);
            double calcpips=NormalizeDouble(monyrisk/stop,2);
            double lotpipcost=MarketInfo(Symbol(),MODE_TICKVALUE); 
             lot=calcpips/lotpipcost;
            if(lot<=MarketInfo(Symbol(),MODE_MINLOT)){lot=MarketInfo(Symbol(),MODE_MINLOT);}
               else if(lot>=MarketInfo(Symbol(),MODE_MAXLOT)){lot=MarketInfo(Symbol(),MODE_MAXLOT);}
               else if(lot>MarketInfo(Symbol(),MODE_MINLOT)&&lot<MarketInfo(Symbol(),MODE_MAXLOT))
                  {
                     int k=(int)((lot-MarketInfo(Symbol(),MODE_MINLOT))/steplot);
                     lot=NormalizeDouble(MarketInfo(Symbol(),MODE_MINLOT)+k*steplot,2);
                  }
         }
      return(lot);
   }
//===================================================================================================
//OrderSendSellStop--------------------------------------------------------
void OrderSendSellStop(double priceStop,double stop)
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=NormalizeDouble(priceStop,Digits);
   double stt=NormalizeDouble(stop,Digits);
   if(stop==0){stt=0;}
   double tpp=NormalizeDouble(price-Take_Profit*Point,Digits);
   if(Take_Profit==0){tpp=0;}
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   tik = OrderSend(Symbol(),OP_SELLSTOP,ltt,price,sleep,stt,tpp,"TrendLine",Magic_Number,0,Red);
   if(tik==-1)
      {
         Print("error sell - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
}
//OrderSendBuyStop--------------------------------------------------------
void OrderSendBuyStop(double priceStop,double stop)
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=NormalizeDouble(priceStop,Digits);
   double stt=NormalizeDouble(stop,Digits);
   if(stop==0){stt=0;}
   double tpp=NormalizeDouble(price+Take_Profit*Point,Digits);
   if(Take_Profit==0){tpp=0;}
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   tik = OrderSend(Symbol(),OP_BUYSTOP,ltt,price,sleep,stt,tpp,"TrendLine",Magic_Number,0,Green);
   if(tik==-1)
      {
         Print("error buy - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
}
//===================================================================================================
//OrderSendSell--------------------------------------------------------
void OrderSendSell()
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=MarketInfo(Symbol(),MODE_BID);
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   P=price;
   tik = OrderSend(Symbol(),OP_SELL,ltt,price,sleep,0,0,"TrendLine",Magic_Number,0,Red);
   if(tik==-1)
      {
         Print("error sell - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
  if(tik!=-1)
      {
         SendMail("TrendLine",(string)tik+" "+Symbol()+" SELL "+(string)P);
         ModifySellTPSL();
      }
}
//OrderSendBuy--------------------------------------------------------
void OrderSendBuy()
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=MarketInfo(Symbol(),MODE_ASK);
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   P=price;
   tik = OrderSend(Symbol(),OP_BUY,ltt,price,sleep,0,0,"TrendLine",Magic_Number,0,Green);
   if(tik==-1)
      {
         Print("error buy - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
  if(tik!=-1)
      {
         SendMail("TrendLine",(string)tik+" "+Symbol()+" BUY "+(string)P);
         ModifyBuyTPSL();
      }
}
//=======================================================================================================
void ModifyBuySL(double stop)
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_BUY&&OrderMagicNumber()==Magic_Number)
                     {
                        double sl=stop;
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrNONE);
                     }
               }
         }
   }
void ModifySellSL(double stop)
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_SELL&&OrderMagicNumber()==Magic_Number)
                     {
                        double sl=stop;
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrNONE);
                     }
               }
         }
   }
//=======================================================================================================
void ModifyBuyTPSL()
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_BUY&&OrderMagicNumber()==Magic_Number)
                     {
                        double tp=NormalizeDouble(OrderOpenPrice()+Take_Profit*Point,Digits);
                        double sl=NormalizeDouble(OrderOpenPrice()-X_Stop_Loss*Point,Digits);
                        if(Take_Profit==0){tp=0;}
                        if(X_Stop_Loss==0){tp=0;}
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE);
                     }
               }
         }
   }
void ModifySellTPSL()
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_SELL&&OrderMagicNumber()==Magic_Number)
                     {
                        double tp=NormalizeDouble(OrderOpenPrice()-Take_Profit*Point,Digits);
                        double sl=NormalizeDouble(OrderOpenPrice()+X_Stop_Loss*Point,Digits);
                        if(Take_Profit==0){tp=0;}
                        if(X_Stop_Loss==0){tp=0;}
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE);
                     }
               }
         }
   }
Marco vd Heijden
Moderator
4728
Marco vd Heijden 2016.09.28 23:10  
bbm24:

 Hi Marco,

I am not a coder so I have tried to send part of the EA.

I think the problem will be somewhere in here.

If it is too long I apologize.

Thanks 

 

There is not a single
ObjectCreate()
In your code.
bbm24
235
bbm24 2016.09.29 09:38  
Marco vd Heijden:
There is not a single In your code.

Hello Marco,

I have now included all the code that makes any mension of the word Object including ObjectCreate and ObjectDelete

Thanks

//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   ClearObjectsAll();
   trade=true;
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
 
//--------------------------------------------------------------------------------------------------------------------------
   if(trade==true)
      {
            //value definition lines
            uplineBuy=NormalizeDouble(InitLine(buy),Digits);if(uplineBuy!=0){ObjectSet(buy,OBJPROP_COLOR,Buy_Line_Clor);}
            dwlineBuyBounce=NormalizeDouble(InitLine(buybounce),Digits);if(dwlineBuyBounce!=0){ObjectSet(buybounce,OBJPROP_COLOR,Buy_Line_Clor);}
            dwlineSell=NormalizeDouble(InitLine(sell),Digits);if(dwlineSell!=0){ObjectSet(sell,OBJPROP_COLOR,Sell_Line_Clor);}
            uplineSellBounce=NormalizeDouble(InitLine(sellbounce),Digits);if(uplineSellBounce!=0){ObjectSet(sellbounce,OBJPROP_COLOR,Sell_Line_Clor);}
//---------------------------------------------------------------------------------------------------------------------------
         //orders the opening of the lines
         if(uplineBuy!=0&&Close[0]>uplineBuy&&CountAttempts==0)
            {
               OrderSendBuy();
               ClearObjects(buy);
               ClearObjects(buybounce);
               ClearObjects(sell);
               ClearObjects(sellbounce);
               CountAttempts++;
               CountOrders++;
               buyy=true;
               buyModify=true;
            }
         if(dwlineBuyBounce!=0&&Close[0]<=dwlineBuyBounce&&CountAttempts==0)
            {
               OrderSendBuy();
               ClearObjects(buy);
               ClearObjects(buybounce);
               ClearObjects(sell);
               ClearObjects(sellbounce);
               CountAttempts++;
               CountOrders++;
               buyy=true;
               buyModify=true;
            }
            
         if(dwlineSell!=0&&Close[0]<dwlineSell&&CountAttempts==0)
            {
               OrderSendSell();
               ClearObjects(buy);
               ClearObjects(buybounce);
               ClearObjects(sell);
               ClearObjects(sellbounce);
               CountAttempts++;
               CountOrders++;
               selll=true;
               sellModify=true;
            }
         if(uplineSellBounce!=0&&Close[0]>=uplineSellBounce&&CountAttempts==0)
            {
               OrderSendSell();
               ClearObjects(buy);
               ClearObjects(buybounce);
               ClearObjects(sell);
               ClearObjects(sellbounce);
               CountAttempts++;
               CountOrders++;
               selll=true;
               sellModify=true;
            }
//----------------------------------------------------------------------------------------------------------
        
//-------------------------------------------------------------------------------------------------------------------------- 
         //Stop All cycles
         if(LastOrder()>=0&&InitOrderCount(OP_SELL)==0&&InitOrderCount(OP_BUY)==0)
            {
               //CountAttempts=0;
               selll=false;
               buyy=false;
            }
      }
//-----------------------
   DrawInfo();
//---
  }
//+------------------------------------------------------------------+
void DrawM()
   {
      string name="M"+(string)Time[0];
      if(ObjectFind(name)==-1)
         {
            ObjectCreate(0,name,OBJ_TEXT,0,Time[0],Close[0]); 
            ObjectSetString(0,name,OBJPROP_TEXT,M); 
            ObjectSetString(0,name,OBJPROP_FONT,"Arial"); 
            ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12); 
            ObjectSetInteger(0,name,OBJPROP_COLOR,M_Color); 
         }
   }
//=======================================================================================================
//Last Price P
double LastStop(int type)
   {
      double temp=0;
      datetime tempT=0;
      for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&OrderType()==type&&OrderCloseTime()>tempT)
                     {
                        temp=OrderStopLoss();
                        tempT=OrderCloseTime();
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
// Last open order
double LastOrder()
   {
      double temp=0;
      datetime tempT=0;
      for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&(OrderType()==OP_BUY||OrderType()==OP_SELL)&&OrderCloseTime()>tempT)
                     {
                              temp=OrderProfit();
                              tempT=OrderCloseTime();
                              LastOpenType=OrderType();
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
int InitOrderCount(int Type)
   {
      int temp=0;
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == Type&&OrderMagicNumber()==Magic_Number)
                     {
                              temp++;
                     }
               }
         }
      return(temp);
   }
//=======================================================================================================
int InitAllOrderCount()
   {
      int temp=0;
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number)
                     {
                              temp++;
                     }
               }
         }
      return(temp);
   }
//===================================================================================================
void ClearObjects(string name)
   {
      ObjectDelete(0,name);
   }
//===================================================================================================
double CalculateLots(double risk,int stop)
   {  
      double lot=Lot_Size;
      if(Lot_Size==0)
         {
            lot=MarketInfo(Symbol(),MODE_MINLOT);
            double steplot=MarketInfo(Symbol(),MODE_LOTSTEP);
            double monyrisk=NormalizeDouble(AccountEquity()/100*risk,2);
            double calcpips=NormalizeDouble(monyrisk/stop,2);
            double lotpipcost=MarketInfo(Symbol(),MODE_TICKVALUE); 
             lot=calcpips/lotpipcost;
            if(lot<=MarketInfo(Symbol(),MODE_MINLOT)){lot=MarketInfo(Symbol(),MODE_MINLOT);}
               else if(lot>=MarketInfo(Symbol(),MODE_MAXLOT)){lot=MarketInfo(Symbol(),MODE_MAXLOT);}
               else if(lot>MarketInfo(Symbol(),MODE_MINLOT)&&lot<MarketInfo(Symbol(),MODE_MAXLOT))
                  {
                     int k=(int)((lot-MarketInfo(Symbol(),MODE_MINLOT))/steplot);
                     lot=NormalizeDouble(MarketInfo(Symbol(),MODE_MINLOT)+k*steplot,2);
                  }
         }
      return(lot);
   }
//===================================================================================================
//OrderSendSellStop--------------------------------------------------------
void OrderSendSellStop(double priceStop,double stop)
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=NormalizeDouble(priceStop,Digits);
   double stt=NormalizeDouble(stop,Digits);
   if(stop==0){stt=0;}
   double tpp=NormalizeDouble(price-Take_Profit*Point,Digits);
   if(Take_Profit==0){tpp=0;}
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   tik = OrderSend(Symbol(),OP_SELLSTOP,ltt,price,sleep,stt,tpp,"TrendLine",Magic_Number,0,Red);
   if(tik==-1)
      {
         Print("error sell - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
}
//OrderSendBuyStop--------------------------------------------------------
void OrderSendBuyStop(double priceStop,double stop)
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=NormalizeDouble(priceStop,Digits);
   double stt=NormalizeDouble(stop,Digits);
   if(stop==0){stt=0;}
   double tpp=NormalizeDouble(price+Take_Profit*Point,Digits);
   if(Take_Profit==0){tpp=0;}
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   tik = OrderSend(Symbol(),OP_BUYSTOP,ltt,price,sleep,stt,tpp,"TrendLine",Magic_Number,0,Green);
   if(tik==-1)
      {
         Print("error buy - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
}
//===================================================================================================
//OrderSendSell--------------------------------------------------------
void OrderSendSell()
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=MarketInfo(Symbol(),MODE_BID);
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   P=price;
   tik = OrderSend(Symbol(),OP_SELL,ltt,price,sleep,0,0,"TrendLine",Magic_Number,0,Red);
   if(tik==-1)
      {
         Print("error sell - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
  if(tik!=-1)
      {
         SendMail("TrendLine",(string)tik+" "+Symbol()+" SELL "+(string)P);
         ModifySellTPSL();
      }
}
//OrderSendBuy--------------------------------------------------------
void OrderSendBuy()
 {
 int tik=-1;
 int attempt = 0;
 while (tik == -1 && attempt <=15)
  {
  if (IsTradeAllowed() == true && IsTradeContextBusy() == false)
   {
   RefreshRates();
   double price=MarketInfo(Symbol(),MODE_ASK);
   int sleep=Slippage;
   if(Slippage==0){sleep=3;}
   double ltt=CalculateLots(Risk,X_Stop_Loss);
   P=price;
   tik = OrderSend(Symbol(),OP_BUY,ltt,price,sleep,0,0,"TrendLine",Magic_Number,0,Green);
   if(tik==-1)
      {
         Print("error buy - ",GetLastError());
         Sleep(1000);
      }
   attempt++;
   }
  }
  if(tik!=-1)
      {
         SendMail("TrendLine",(string)tik+" "+Symbol()+" BUY "+(string)P);
         ModifyBuyTPSL();
      }
}
//=======================================================================================================
void ModifyBuySL(double stop)
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_BUY&&OrderMagicNumber()==Magic_Number)
                     {
                        double sl=stop;
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrNONE);
                     }
               }
         }
   }
void ModifySellSL(double stop)
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_SELL&&OrderMagicNumber()==Magic_Number)
                     {
                        double sl=stop;
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrNONE);
                     }
               }
         }
   }
//=======================================================================================================
void ModifyBuyTPSL()
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_BUY&&OrderMagicNumber()==Magic_Number)
                     {
                        double tp=NormalizeDouble(OrderOpenPrice()+Take_Profit*Point,Digits);
                        double sl=NormalizeDouble(OrderOpenPrice()-X_Stop_Loss*Point,Digits);
                        if(Take_Profit==0){tp=0;}
                        if(X_Stop_Loss==0){tp=0;}
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE);
                     }
               }
         }
   }
void ModifySellTPSL()
   {
      for(int i = OrdersTotal() - 1; i >= 0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderType() == OP_SELL&&OrderMagicNumber()==Magic_Number)
                     {
                        double tp=NormalizeDouble(OrderOpenPrice()-Take_Profit*Point,Digits);
                        double sl=NormalizeDouble(OrderOpenPrice()+X_Stop_Loss*Point,Digits);
                        if(Take_Profit==0){tp=0;}
                        if(X_Stop_Loss==0){tp=0;}
                        int re=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,clrNONE);
                     }
               }
         }
   }
//===================================================================================================
void DrawInfo()
   {
      textinfo2("--",10,15,White,8,"--------------------------------------------------------"); 
    
   }
//---------------------------------------------------------------------------------------------------
void textinfo2(string objektname,int a,int b,color col,int w,string info)
  {
      if(ObjectFind(objektname)>=0)ObjectDelete(objektname);
      ObjectCreate(objektname,OBJ_LABEL,0,0,0);
      ObjectSet(objektname, OBJPROP_XDISTANCE, a);//h
      ObjectSet(objektname, OBJPROP_YDISTANCE, b);//v
      ObjectSet(objektname,OBJPROP_CORNER,1);
      ObjectSetText(objektname,info,w,"Arial",col);
  }
//=====================================================================================
double OpenPosition()
   {
      double temp=0;
      Stop_Price=0;
      Take_Profit_Price=0;
      Ticket_Number=0;
      for (int i=OrdersTotal()-1; i>=0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&(OrderType()==OP_BUY||OrderType()==OP_SELL))
                     {
                        temp=OrderOpenPrice();
                        Stop_Price=OrderStopLoss();
                        Take_Profit_Price=OrderTakeProfit();
                        Ticket_Number=OrderTicket();
                     }
               }
         }
      return(temp);
   }
//=====================================================================================
double OpenPendingPosition()
   {
      double temp=0;
      for (int i=OrdersTotal()-1; i>=0; i--)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
               {
                  if (OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic_Number&&(OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP))
                     {
                        temp=OrderOpenPrice();
                        Take_Profit_Price=OrderTakeProfit();
                        Ticket_Number=OrderTicket();
                     }
               }
         }
      return(temp);
   }
//=====================================================================================

//===============================================================================================
void ClearObjectsAll()
   {
      //ObjectDelete(0,"buy");
      //ObjectDelete(0,"sell");
           
  
   }
To add comments, please log in or register