martin test

Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersChecks for the total of closed ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
martin test
ÿþ//+------------------------------------------------------------------+

//|                                                      Martin Test |

//+------------------------------------------------------------------+

extern double Exp=1.3;

extern int Interval=20;

extern int TakeProfit=20;

extern int Equity_per_lot=5000;

extern int MaxTrades=50;

extern bool Comment_for_cent=true;

extern double Usd_per_Rub=57;

int LimitOrders=99999999;

int timeprev,In,Tp,OrdTot,DateTime;

double ordprof,l,bl,sl,b,s,PriceLot,Count,SwapCom,AverageBuyPrice,PriceBuyTarget,

AverageSellPrice,PriceSellTarget,Balance,ordprof1,ordprof2,ordprof3,Deposit1,Withdraw1,

Deposit2,Withdraw2,Deposit3,Withdraw3;

bool OSd,OSt,OCe,OMy;

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int OnInit()

  {

   if(Digits==5 || Digits==3)

     {

      TakeProfit*=10;

      Interval*=10;

     }

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int start()

  {

   if(timeprev == Time[0]) return (0);

   timeprev=Time[0];

   if(AccountFreeMargin()<10)

     {

      if(Balance!=AccountBalance() || OrdTot!=OrdersTotal())

        {

         DateTime = TimeCurrent(); ordprof1 = 0;

         ordprof2 = 0; ordprof3 = 0;

         Deposit1 = 0; Withdraw1 = 0;

         Deposit2 = 0; Withdraw2 = 0;

         Deposit3 = 0; Withdraw3 = 0;

         for(int cnt=0; cnt<OrdersHistoryTotal(); cnt++)

           {

            OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);

            if(OrderCloseTime()<TimeCurrent()-2629800) continue;

            if(StringFind(OrderComment(),"Deposit")>=0) Deposit3+=OrderProfit()+OrderCommission();

            if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw3+=OrderProfit()+OrderCommission();

            ordprof3+=OrderProfit()+OrderCommission()+OrderSwap();

            if(OrderCloseTime()<TimeCurrent()-604800) continue;

            if(StringFind(OrderComment(),"Deposit")>=0) Deposit2+=OrderProfit()+OrderCommission();

            if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw2+=OrderProfit()+OrderCommission();

            ordprof2+=OrderProfit()+OrderCommission()+OrderSwap();

            if(OrderCloseTime()<TimeCurrent()-86400) continue;

            if(StringFind(OrderComment(),"Deposit")>=0) Deposit1+=OrderProfit()+OrderCommission();

            if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw1+=OrderProfit()+OrderCommission();

            ordprof1+=OrderProfit()+OrderCommission()+OrderSwap();

           }

         ordprof1 = ordprof1 - Deposit1 - Withdraw1;

         ordprof2 = ordprof2 - Deposit2 - Withdraw2;

         ordprof3 = ordprof3 - Deposit3 - Withdraw3;

         Balance=AccountBalance(); OrdTot=OrdersTotal();

        }

      ObjectDelete(ChartID(),"buyline");

      ObjectDelete(ChartID(),"sellline");

      ObjectDelete(ChartID(),"fon1");

      ObjectDelete(ChartID(),"fon2");

      ObjectCreate(ChartID(),"buyline",OBJ_HLINE,0,0,b);

      ObjectSetInteger(ChartID(),"buyline",OBJPROP_COLOR,Blue);

      ObjectSetInteger(ChartID(),"buyline",OBJPROP_STYLE,STYLE_DASH);

      ObjectCreate(ChartID(),"sellline",OBJ_HLINE,0,0,s);

      ObjectSetInteger(ChartID(),"sellline",OBJPROP_COLOR,Red);

      ObjectSetInteger(ChartID(),"sellline",OBJPROP_STYLE,STYLE_DASH);

      ObjectCreate(ChartID(),"fon1",OBJ_RECTANGLE_LABEL,0,0,0);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_XDISTANCE,100);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_YDISTANCE,12);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_XSIZE,700);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_YSIZE,30);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_BGCOLOR,Gray);

      ObjectSetInteger(ChartID(),"fon1",OBJPROP_BACK,false);

      ObjectCreate(ChartID(),"fon2",OBJ_RECTANGLE_LABEL,0,0,0);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_XDISTANCE,100);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_YDISTANCE,45);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_XSIZE,300);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_YSIZE,70);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_BGCOLOR,Gray);

      ObjectSetInteger(ChartID(),"fon2",OBJPROP_BACK,false);

      ChartSetInteger(ChartID(),CHART_FOREGROUND,0,false);

      if(Comment_for_cent==true)

        {

         Comment("                                  0;0=A: ",DoubleToString(NormalizeDouble(AccountBalance()*Usd_per_Rub/100,2),2),

                 "@., !@54AB20: ",DoubleToString(NormalizeDouble(AccountEquity()*Usd_per_Rub/100,2),2),"@., @81K;L: ",

                 DoubleToString(NormalizeDouble(AccountProfit()*Usd_per_Rub/100,2),2),"@., !2>1>4=>: ",

                 DoubleToString(NormalizeDouble(AccountFreeMargin()*Usd_per_Rub/100,2),2),"@., Lot: ",l,", ",bl,", ",sl,", A53> >@45@>2: ",

                 OrdersTotal(),", @45@>2 ?> A8<2>;C: ",CountTrades(),"\n                                  ;5G>: ",AccountLeverage(),", 0B0 >1=>2;5=8O: ",

                 TimeToStr(TimeCurrent()),"\n\n                                                                       AB>@8O AG5B0\n    ",

                 "                              ------------------------------------------------------------------------------------------------",

                 "\n                                    !53>4=O: ",DoubleToString(NormalizeDouble(ordprof1*Usd_per_Rub/100,2),2),

                 "@., >?>;=5=85: ",DoubleToString(NormalizeDouble(Deposit3*Usd_per_Rub/100,2),2),"@. (70 <5AOF)\n                                    545;O: ",

                 DoubleToString(NormalizeDouble(ordprof2*Usd_per_Rub/100,2),2),"@., !=OB85: ",DoubleToString(NormalizeDouble(Withdraw3*Usd_per_Rub/100,2),2),

                 "@. (70 <5AOF)\n                                    5AOF: ",DoubleToString(NormalizeDouble(ordprof3*Usd_per_Rub/100,2),2),"@., 0B0 >1=>2;5=8O: ",

                 TimeToStr(DateTime));

        }

      if(Comment_for_cent==false)

        {

         Comment("                                  0;0=A: ",DoubleToString(NormalizeDouble(AccountBalance()*Usd_per_Rub,2),2),

                 "@., !@54AB20: ",DoubleToString(NormalizeDouble(AccountEquity()*Usd_per_Rub,2),2),"@., @81K;L: ",

                 DoubleToString(NormalizeDouble(AccountProfit()*Usd_per_Rub,2),2),"@., !2>1>4=>: ",

                 DoubleToString(NormalizeDouble(AccountFreeMargin()*Usd_per_Rub,2),2),"@., Lot: ",l,", ",bl,", ",sl,", A53> >@45@>2: ",

                 OrdersTotal(),", @45@>2 ?> A8<2>;C: ",CountTrades(),"\n                                  ;5G>: ",AccountLeverage(),", 0B0 >1=>2;5=8O: ",

                 TimeToStr(TimeCurrent()),"\n\n                                                                       AB>@8O AG5B0\n    ",

                 "                              ------------------------------------------------------------------------------------------------",

                 "\n                                    !53>4=O: ",DoubleToString(NormalizeDouble(ordprof1*Usd_per_Rub,2),2),

                 "@., >?>;=5=85: ",DoubleToString(NormalizeDouble(Deposit3*Usd_per_Rub,2),2),"@. (70 <5AOF)\n                                    545;O: ",

                 DoubleToString(NormalizeDouble(ordprof2*Usd_per_Rub,2),2),"@., !=OB85: ",DoubleToString(NormalizeDouble(Withdraw3*Usd_per_Rub,2),2),

                 "@. (70 <5AOF)\n                                    5AOF: ",DoubleToString(NormalizeDouble(ordprof3*Usd_per_Rub,2),2),"@., 0B0 >1=>2;5=8O: ",

                 TimeToStr(DateTime));

        }

      return (0);

     }

   In= Interval+MarketInfo(Symbol(),14); Tp = TakeProfit+MarketInfo(Symbol(),14);

   l = MathFloor(AccountEquity()/Equity_per_lot) * MarketInfo(Symbol(),24);

   if(l < MarketInfo(Symbol(), 23)) l = MarketInfo(Symbol(), 23);

   if(l > MarketInfo(Symbol(), 25)) l = MarketInfo(Symbol(), 25);

   bl=NormalizeDouble(l*MathPow(Exp,CountBuyTrades()),2);

   if(bl < MarketInfo(Symbol(), 23)) bl = MarketInfo(Symbol(), 23);

   if(bl > MarketInfo(Symbol(), 25)) bl = MarketInfo(Symbol(), 25);

   sl=NormalizeDouble(l*MathPow(Exp,CountSellTrades()),2);

   if(sl < MarketInfo(Symbol(), 23)) sl = MarketInfo(Symbol(), 23);

   if(sl > MarketInfo(Symbol(), 25)) sl = MarketInfo(Symbol(), 25);

   if(CountBuyTrades()>0) b=FindLastBuyPrice()-In*Point;

   if(AccountFreeMarginCheck(Symbol(),OP_BUY,bl)>=0)

     {

      if(CountBuyTrades()==0) b=Ask;

      if(b>=Ask)

        {

         RefreshRates();

         OSd=OrderSend(Symbol(),OP_BUY,bl,Ask,In,0,0,"Martin ("+In+")",In,0,Blue);

         b=FindLastBuyPrice()-In*Point;

        }

     }

   if(CountSellTrades()>0) s=FindLastSellPrice()+In*Point;

   if(AccountFreeMarginCheck(Symbol(),OP_SELL,sl)>=0)

     {

      if(CountSellTrades()==0) s=Bid;

      if(s<=Bid)

        {

         RefreshRates();

         OSd=OrderSend(Symbol(),OP_SELL,sl,Bid,In,0,0,"Martin ("+In+")",In,0,Red);

         s=FindLastSellPrice()+In*Point;

        }

     }

   for(cnt=0; cnt<OrdersTotal(); cnt++)

     {

      OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

      if(TimeCurrent()>OrderOpenTime()+31557600)

        {

         if(OrderSymbol()==Symbol())

           {

            if(OrderType()==OP_BUY)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Bid,In,White);

              }

            if(OrderType()==OP_SELL)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Ask,In,White);

              }

           }

        }

      ordprof = 0;

      ordprof = OrderProfit() + OrderSwap() + OrderCommission();

      if(OrderMagicNumber()!=In && ordprof>0)

        {

         if(OrderSymbol()==Symbol())

           {

            if(OrderType()==OP_BUY)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Bid,In,White);

              }

            if(OrderType()==OP_SELL)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Ask,In,White);

              }

           }

        }

     }

   if(CountTrades()>MaxTrades)

     {

      for(int pos=0; pos<OrdersTotal(); pos++)

        {

         OSt=OrderSelect(pos,SELECT_BY_POS);

         if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)

           {

            RefreshRates();

            OCe = OrderClose(OrderTicket(), OrderLots(), Bid, In, White);

            pos = OrdersTotal();

           }

         if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)

           {

            RefreshRates();

            OCe = OrderClose(OrderTicket(), OrderLots(), Ask, In, White);

            pos = OrdersTotal();

           }

        }

     }

   if(GetLastError()== 148) LimitOrders = OrdersTotal();

   if(OrdersTotal()>=LimitOrders)

     {

      for(pos=0; pos<OrdersTotal(); pos++)

        {

         OSt=OrderSelect(pos,SELECT_BY_POS);

         if(OrderType()==OP_BUY)

           {

            RefreshRates();

            OCe = OrderClose(OrderTicket(), OrderLots(), Bid, In, White);

            pos = OrdersTotal();

           }

         if(OrderType()==OP_SELL)

           {

            RefreshRates();

            OCe = OrderClose(OrderTicket(), OrderLots(), Ask, In, White);

            pos = OrdersTotal();

           }

        }

     }

   if(CountBuyTrades()>0)

     {

      PriceLot=0;

      Count=0; SwapCom=0;

      for(cnt=OrdersTotal()-1; cnt>=0; cnt--)

        {

         OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

         if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)

           {

            PriceLot+= OrderOpenPrice() * OrderLots();

            SwapCom += OrderSwap() + OrderCommission();

            Count+=OrderLots();

           }

        }

      AverageBuyPrice=NormalizeDouble(PriceLot/Count,Digits);

      if(SwapCom>=0 || MarketInfo(Symbol(),16)==0) PriceBuyTarget=AverageBuyPrice+Tp*Point;

      if(SwapCom<0 && MarketInfo(Symbol(),16)==0) PriceBuyTarget=AverageBuyPrice+Tp*Point;

      if(SwapCom<0 && MarketInfo(Symbol(),16)!=0)

         PriceBuyTarget=AverageBuyPrice+Tp*Point-MathFloor(SwapCom/(MarketInfo(Symbol(),16)*Count))*Point;

      for(cnt=OrdersTotal()-1; cnt>=0; cnt--)

        {

         OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

         if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)

           {

            if(PriceBuyTarget<=Bid)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Bid,In,White);

              }

            if(PriceBuyTarget-Bid<MarketInfo(Symbol(),14)*Point) continue;

            if(OrderTakeProfit()!=PriceBuyTarget)

               OMy=OrderModify(OrderTicket(),OrderOpenPrice(),0,NormalizeDouble(PriceBuyTarget,Digits),0,Yellow);

           }

        }

     }

   if(CountSellTrades()>0)

     {

      PriceLot=0;

      Count=0; SwapCom=0;

      for(cnt=OrdersTotal()-1; cnt>=0; cnt--)

        {

         OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

         if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)

           {

            PriceLot+= OrderOpenPrice() * OrderLots();

            SwapCom += OrderSwap() + OrderCommission();

            Count+=OrderLots();

           }

        }

      AverageSellPrice=NormalizeDouble(PriceLot/Count,Digits);

      if(SwapCom>=0 || MarketInfo(Symbol(),16)==0) PriceSellTarget=AverageSellPrice-Tp*Point;

      if(SwapCom<0 && MarketInfo(Symbol(),16)==0) PriceSellTarget=AverageSellPrice-Tp*Point;

      if(SwapCom<0 && MarketInfo(Symbol(),16)!=0)

         PriceSellTarget=AverageSellPrice-Tp*Point+MathFloor(SwapCom/(MarketInfo(Symbol(),16)*Count))*Point;

      for(cnt=OrdersTotal()-1; cnt>=0; cnt--)

        {

         OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

         if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)

           {

            if(PriceSellTarget>=Ask)

              {

               RefreshRates();

               OCe=OrderClose(OrderTicket(),OrderLots(),Ask,In,White);

              }

            if(Ask-PriceSellTarget<MarketInfo(Symbol(),14)*Point) continue;

            if(OrderTakeProfit()!=PriceSellTarget)

               OMy=OrderModify(OrderTicket(),OrderOpenPrice(),0,NormalizeDouble(PriceSellTarget,Digits),0,Yellow);

           }

        }

     }

   l=MathFloor(AccountEquity()/Equity_per_lot)*MarketInfo(Symbol(),24);

   if(l < MarketInfo(Symbol(), 23)) l = MarketInfo(Symbol(), 23);

   if(l > MarketInfo(Symbol(), 25)) l = MarketInfo(Symbol(), 25);

   bl=NormalizeDouble(l*MathPow(Exp,CountBuyTrades()),2);

   if(bl < MarketInfo(Symbol(), 23)) bl = MarketInfo(Symbol(), 23);

   if(bl > MarketInfo(Symbol(), 25)) bl = MarketInfo(Symbol(), 25);

   sl=NormalizeDouble(l*MathPow(Exp,CountSellTrades()),2);

   if(sl < MarketInfo(Symbol(), 23)) sl = MarketInfo(Symbol(), 23);

   if(sl > MarketInfo(Symbol(), 25)) sl = MarketInfo(Symbol(), 25);

   if(CountBuyTrades()>0) b=FindLastBuyPrice()-In*Point;

   if(CountSellTrades()>0) s=FindLastSellPrice()+In*Point;

   if(Balance!=AccountBalance() || OrdTot!=OrdersTotal())

     {

      DateTime = TimeCurrent(); ordprof1 = 0;

      ordprof2 = 0; ordprof3 = 0;

      Deposit1 = 0; Withdraw1 = 0;

      Deposit2 = 0; Withdraw2 = 0;

      Deposit3 = 0; Withdraw3 = 0;

      for(cnt=0; cnt<OrdersHistoryTotal(); cnt++)

        {

         OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);

         if(OrderCloseTime()<TimeCurrent()-2629800) continue;

         if(StringFind(OrderComment(),"Deposit")>=0) Deposit3+=OrderProfit()+OrderCommission();

         if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw3+=OrderProfit()+OrderCommission();

         ordprof3+=OrderProfit()+OrderCommission()+OrderSwap();

         if(OrderCloseTime()<TimeCurrent()-604800) continue;

         if(StringFind(OrderComment(),"Deposit")>=0) Deposit2+=OrderProfit()+OrderCommission();

         if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw2+=OrderProfit()+OrderCommission();

         ordprof2+=OrderProfit()+OrderCommission()+OrderSwap();

         if(OrderCloseTime()<TimeCurrent()-86400) continue;

         if(StringFind(OrderComment(),"Deposit")>=0) Deposit1+=OrderProfit()+OrderCommission();

         if(StringFind(OrderComment(),"Withdraw")>=0) Withdraw1+=OrderProfit()+OrderCommission();

         ordprof1+=OrderProfit()+OrderCommission()+OrderSwap();

        }

      ordprof1 = ordprof1 - Deposit1 - Withdraw1;

      ordprof2 = ordprof2 - Deposit2 - Withdraw2;

      ordprof3 = ordprof3 - Deposit3 - Withdraw3;

      Balance=AccountBalance(); OrdTot=OrdersTotal();

     }

   ObjectDelete(ChartID(),"buyline");

   ObjectDelete(ChartID(),"sellline");

   ObjectDelete(ChartID(),"fon1");

   ObjectDelete(ChartID(),"fon2");

   ObjectCreate(ChartID(),"buyline",OBJ_HLINE,0,0,b);

   ObjectSetInteger(ChartID(),"buyline",OBJPROP_COLOR,Blue);

   ObjectSetInteger(ChartID(),"buyline",OBJPROP_STYLE,STYLE_DASH);

   ObjectCreate(ChartID(),"sellline",OBJ_HLINE,0,0,s);

   ObjectSetInteger(ChartID(),"sellline",OBJPROP_COLOR,Red);

   ObjectSetInteger(ChartID(),"sellline",OBJPROP_STYLE,STYLE_DASH);

   ObjectCreate(ChartID(),"fon1",OBJ_RECTANGLE_LABEL,0,0,0);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_XDISTANCE,100);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_YDISTANCE,12);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_XSIZE,700);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_YSIZE,30);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_BGCOLOR,Gray);

   ObjectSetInteger(ChartID(),"fon1",OBJPROP_BACK,false);

   ObjectCreate(ChartID(),"fon2",OBJ_RECTANGLE_LABEL,0,0,0);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_XDISTANCE,100);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_YDISTANCE,45);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_XSIZE,300);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_YSIZE,70);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_BGCOLOR,Gray);

   ObjectSetInteger(ChartID(),"fon2",OBJPROP_BACK,false);

   ChartSetInteger(ChartID(),CHART_FOREGROUND,0,false);

   if(Comment_for_cent==true)

     {

      Comment("                                  0;0=A: ",DoubleToString(NormalizeDouble(AccountBalance()*Usd_per_Rub/100,2),2),

              "@., !@54AB20: ",DoubleToString(NormalizeDouble(AccountEquity()*Usd_per_Rub/100,2),2),"@., @81K;L: ",

              DoubleToString(NormalizeDouble(AccountProfit()*Usd_per_Rub/100,2),2),"@., !2>1>4=>: ",

              DoubleToString(NormalizeDouble(AccountFreeMargin()*Usd_per_Rub/100,2),2),"@., Lot: ",l,", ",bl,", ",sl,", A53> >@45@>2: ",

              OrdersTotal(),", @45@>2 ?> A8<2>;C: ",CountTrades(),"\n                                  ;5G>: ",AccountLeverage(),", 0B0 >1=>2;5=8O: ",

              TimeToStr(TimeCurrent()),"\n\n                                                                       AB>@8O AG5B0\n    ",

              "                              ------------------------------------------------------------------------------------------------",

              "\n                                    !53>4=O: ",DoubleToString(NormalizeDouble(ordprof1*Usd_per_Rub/100,2),2),

              "@., >?>;=5=85: ",DoubleToString(NormalizeDouble(Deposit3*Usd_per_Rub/100,2),2),"@. (70 <5AOF)\n                                    545;O: ",

              DoubleToString(NormalizeDouble(ordprof2*Usd_per_Rub/100,2),2),"@., !=OB85: ",DoubleToString(NormalizeDouble(Withdraw3*Usd_per_Rub/100,2),2),

              "@. (70 <5AOF)\n                                    5AOF: ",DoubleToString(NormalizeDouble(ordprof3*Usd_per_Rub/100,2),2),"@., 0B0 >1=>2;5=8O: ",

              TimeToStr(DateTime));

     }

   if(Comment_for_cent==false)

     {

      Comment("                                  0;0=A: ",DoubleToString(NormalizeDouble(AccountBalance()*Usd_per_Rub,2),2),

              "@., !@54AB20: ",DoubleToString(NormalizeDouble(AccountEquity()*Usd_per_Rub,2),2),"@., @81K;L: ",

              DoubleToString(NormalizeDouble(AccountProfit()*Usd_per_Rub,2),2),"@., !2>1>4=>: ",

              DoubleToString(NormalizeDouble(AccountFreeMargin()*Usd_per_Rub,2),2),"@., Lot: ",l,", ",bl,", ",sl,", A53> >@45@>2: ",

              OrdersTotal(),", @45@>2 ?> A8<2>;C: ",CountTrades(),"\n                                  ;5G>: ",AccountLeverage(),", 0B0 >1=>2;5=8O: ",

              TimeToStr(TimeCurrent()),"\n\n                                                                       AB>@8O AG5B0\n    ",

              "                              ------------------------------------------------------------------------------------------------",

              "\n                                    !53>4=O: ",DoubleToString(NormalizeDouble(ordprof1*Usd_per_Rub,2),2),

              "@., >?>;=5=85: ",DoubleToString(NormalizeDouble(Deposit3*Usd_per_Rub,2),2),"@. (70 <5AOF)\n                                    545;O: ",

              DoubleToString(NormalizeDouble(ordprof2*Usd_per_Rub,2),2),"@., !=OB85: ",DoubleToString(NormalizeDouble(Withdraw3*Usd_per_Rub,2),2),

              "@. (70 <5AOF)\n                                    5AOF: ",DoubleToString(NormalizeDouble(ordprof3*Usd_per_Rub,2),2),"@., 0B0 >1=>2;5=8O: ",

              TimeToStr(DateTime));

     }

   return(0);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int CountTrades()

  {

   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)

     {

      OSt=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

      if(OrderSymbol()==Symbol()) count++;

     }

   return (count);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int CountBuyTrades()

  {

   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)

     {

      OSt=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) count++;

     }

   return (count);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int CountSellTrades()

  {

   int count=0;

   for(int trade=OrdersTotal()-1; trade>=0; trade--)

     {

      OSt=OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) count++;

     }

   return (count);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double FindLastBuyPrice()

  {

   double oldorderopenprice;

   int oldticketnumber;

   int ticketnumber=0;

   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--)

     {

      OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)

        {

         oldticketnumber=OrderTicket();

         if(oldticketnumber>ticketnumber)

           {

            oldorderopenprice=OrderOpenPrice();

            ticketnumber=oldticketnumber;

           }

        }

     }

   return (oldorderopenprice);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double FindLastSellPrice()

  {

   double oldorderopenprice;

   int oldticketnumber;

   int ticketnumber=0;

   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--)

     {

      OSt=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)

        {

         oldticketnumber=OrderTicket();

         if(oldticketnumber>ticketnumber)

           {

            oldorderopenprice=OrderOpenPrice();

            ticketnumber=oldticketnumber;

           }

        }

     }

   return (oldorderopenprice);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---