//+------------------------------------------------------------------+
//|          Free and OpenSource code under MIT License              |
//|              (https://opensource.org/licenses/MIT)               |
//|                    ButtonTrading_2.11.mq4                        |
//|                 Copyright 2020 penyuperwira                      |
//|          (https://www.forexfactory.com/penyuperwira)             |
//|                  updated : 24.06.2020                            |
//+------------------------------------------------------------------+
#property copyright "Created by PenyuPerwira https://www.forexfactory.com/showthread.php?t=785645"
#property link      "https://www.forexfactory.com/showthread.php?t=785645"
#property description "Last updated : 24.06.2020"
//#property version   "2.08"
#property strict
string versionName = "EA ButtonTradingV2.11";
//+------------------------------------------------------------------+
//|             Expert initialization function                       |
//+------------------------------------------------------------------+
int              Slippage=5;
extern string    Mode3="Percentage % lot/TP/SL by balance";
extern double    MM_Risk_Percent_Lots=0.10;
extern bool      ProfitPercen =true;
extern double    ProfitPercent=1.0;
extern bool      StopPercen =true;
extern double    StopPercent=1.0;
extern bool      BreakEvenPercen=true;
extern double  BreakEvenPercent = 0.03;
extern string ExitBehaviour = "Choose how to manually exit trade";
extern bool CloseProfitOnly=true;
extern bool CloseOnlyCurrentSymbol=true;
//+------------------------------------------------------------------+
//|                Button General Settings                            |
//+------------------------------------------------------------------+
extern string    Setting="Buttons Arrangement";
extern bool ArrangeButtonVertical=true;
extern bool    Corner_RIGHT_TOP=true;
extern int buttonsHorizontalPosition = 59;
extern int buttonsVerticalPosition = 217;
extern int ButtonWidth=56;
extern int ButtonHeight=15;
extern int ButtonFontSize=8;
extern color ButtonFontColor=White;
extern color BuyButtonColor=Green;
extern color HedgeButtonColor=Blue;
extern color SellButtonColor=Maroon;
extern color BuyNetTPButtonColor=DarkOliveGreen;
extern color HedgeNetTPButtonColor=SteelBlue;
extern color SellNetTPButtonColor=SaddleBrown;
extern color CloseButtonColor=Red;
extern color VersionButtonColor=Gray;
extern color ButtonOutlineColor=White;
int gap=5; //gap for button
//+------------------------------------------------------------------+
//|               Indicator's General Settings                       |
//+------------------------------------------------------------------+
extern string     settings="Indicator on Charts";
extern bool    Corner_of_Chart_RIGHT_TOP=true;
extern int        Shift_UP_DN=0;
extern int        Adjust_Side_to_side=150;
extern bool       ShowComment=false;
string     separator_01="----  General  Settings  ----";
bool       SendLotsAlert=false;
bool       HedgeLotsAlert=false;
int        TimeDelayAlertinSec=60;
string     Position_Info="Left True--------Right False";
bool       Position=true;
color      BarLabel_color=C'200,200,200';
color      CommentLabel_color=C'200,200,200';
color       color_HedgLOT;
color       color_ProfitNet;
color       color_TPLOT;
color       color_Bnet;
color       color_ProfitEq, color_ProfitBal;
color       color_Tnet;
color       color_BProfitNet;
color       color_Snet;
color       color_SProfitNet;
color      Lot_color_pip;
color      TBcount_color;
color      TScount_color;
color      STP_color;
color      BTP_color;
double     BTPipsValue;
double     STPipsValue;
double     STPoints;
double     BTPoints;
double     BTP;
double     STP;
color      color_TProfit;
double     TProfit;
double     TProfitP;
string     note3="Font Size";
int        FontSize=8;
string     note4="Font Type";
string     FontType="Arial Bold";
string     note5 = "Display the price in what corner?";
string     note6 = "Upper left=0; Upper right=1";
string     note7 = "Lower left=2; Lower right=3";
int        WhatCorner=1;
string tagInputs="---- parameters water marks ----";
extern bool ShowWatermark=false;
bool tagDisplayText=false;
string tagText="";
int tagFontSize=70;
string tagFontName="Tahoma";
int tagRed=50;
int tagGreen= 50;
int tagBlue = 50;
//string    Position="----  WaterMark ----";
int tagXPos = 440;
int tagYPos = 250;
//------
int sidFontSize=8;
string sidFontName="Ariel Bold";
string NoteRedGreenBlue="Red/Green/Blue each 0..255";
int sidRed=200;
int sidGreen= 200;
int sidBlue = 200;
int sidXPos = 270;
int sidYPos = 0;
//---- data
string SID = "Symbol";
int sidRGB = 0;
string TAG = "Tag";
int tagRGB = 0;
string tf;
//------input parameters water marks
bool t_day[5];
double pt;
double t_profit=0;
int i;
int ticket;
double tp_m,tp_m2,sl_m,sl_m2;
string line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8,line_9,line_10;
double PipsB4MCvalue,PerctTPD,PerctTPDAE;
double Credit;
double Balance;
double balance;
double GetoLots;
double ProfitPercentage;
double StopPercentage;
double StopPipsMath;
double ProfitPipsMath;
double account_type;
int err,Total;
double AE;
double pip;
double bal_2=0;
double Price;
//+------------------------------------------------------------------+
//|             Button Initialize                                    |
//+------------------------------------------------------------------+
int OnInit()
  {
   account_type=1;
   if(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_CONTRACT_SIZE)==1000)
      account_type=10;
   if(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_CONTRACT_SIZE)==10000)
      account_type=1;
   if(SymbolInfoDouble(Symbol(), SYMBOL_TRADE_CONTRACT_SIZE)==100000)
      account_type=0.1;
//------Balance for Info indicator-------
   if(!GlobalVariableGet("bal_2"+Symbol()))
      GlobalVariableSet("bal_2"+Symbol(),0);
   if(GlobalVariableGet("bal_2"+Symbol())>0)
      bal_2=GlobalVariableGet("bal_2"+Symbol());
//+---------button arangement-------------------------+
   int Button_Horizontal=buttonsHorizontalPosition;
   int Button_Vertical=buttonsVerticalPosition;
   int x=Button_Horizontal;
   int y=Button_Vertical;
   int x2=Button_Horizontal;
   int y2=gap+ButtonHeight+Button_Vertical;
   int x3=Button_Horizontal;
   int y3=gap*2+ButtonHeight*2+Button_Vertical;
   int x4=Button_Horizontal;
   int y4=gap*3+ButtonHeight*3+Button_Vertical;
   int x5=Button_Horizontal;
   int y5=gap*4+ButtonHeight*4+Button_Vertical;
   int x6=Button_Horizontal;
   int y6=gap*5+ButtonHeight*5+Button_Vertical;
   int x7=Button_Horizontal;
   int y7=gap*6+ButtonHeight*6+Button_Vertical;
   int x8=Button_Horizontal;
   int y8=gap*7+ButtonHeight*7+Button_Vertical;
   if(Corner_RIGHT_TOP)
      x8=Button_Horizontal+132;
   if(!ArrangeButtonVertical)
     {
      CreateButton("button1","Buy Net",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button2","Net % TP",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button3","Net % SL",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button4","Net % BE",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button5","Delete TP",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button6","Delete SL",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button7","Close",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy

      CreateButton("button8", "HedgeNet",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button9", "Net % TP",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button10", "Net % SL",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button11","Net % BE",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button12","Delete TP",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button13","Delete SL",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button14","Close",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge

      CreateButton("button15","Sell Net",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button16","Net % TP",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button17","Net % SL",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button18","Net % BE",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button19","Delete TP",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button20","Delete SL",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);
      CreateButton("button21","Close",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);

      CreateButton("button22",versionName,x4,y4,ButtonWidth*7+gap*12,ButtonHeight,ButtonFontColor,VersionButtonColor,ButtonOutlineColor,ButtonFontSize);//title box
     }
   else
     {
      CreateButton("button1","Buy Net",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,BuyButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button8","HedgeNet",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button15","Sell Net",x,y,ButtonWidth,ButtonHeight,ButtonFontColor,SellButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button2","Net % TP",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy;
      CreateButton("button9","Net % TP",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button16","Net % TP",x2,y2,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button3","Net % SL",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy;
      CreateButton("button10","Net % SL",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button17","Net % SL",x3,y3,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button4","Net % BE",x4,y4,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button11","Net % BE",x4,y4,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button18","Net % BE",x4,y4,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button5","Delete TP",x5,y5,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button12","Delete TP",x5,y5,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button19","Delete TP",x5,y5,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button6","Delete SL",x6,y6,ButtonWidth,ButtonHeight,ButtonFontColor,BuyNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button13","Delete SL",x6,y6,ButtonWidth,ButtonHeight,ButtonFontColor,HedgeNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button20","Delete SL",x6,y6,ButtonWidth,ButtonHeight,ButtonFontColor,SellNetTPButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button7","Close",x7,y7,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);//Buy
      CreateButton("button14","Close",x7,y7,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);//hedge
      CreateButton("button21","Close",x7,y7,ButtonWidth,ButtonHeight,ButtonFontColor,CloseButtonColor,ButtonOutlineColor,ButtonFontSize);//sell

      CreateButton("button22",versionName,x8,y8,ButtonWidth*3+gap*4,ButtonHeight,ButtonFontColor,VersionButtonColor,ButtonOutlineColor,ButtonFontSize);//title box
     }
//+------------------------------------------------------------------+
//|                  Indicators Initialize                           |
//+------------------------------------------------------------------+
   if(Digits==3 || Digits==5)
      pt=10*Point;
   else
      pt=Point;
//-------------water marks
   switch(Period())
     {
      case PERIOD_D1:
         tf="d1";
         break;
      case PERIOD_H1:
         tf="h1";
         break;
      case PERIOD_H4:
         tf="h4";
         break;
      case PERIOD_M1:
         tf="m1";
         break;
      case PERIOD_M15:
         tf="m15";
         break;
      case PERIOD_M30:
         tf="m30";
         break;
      case PERIOD_M5:
         tf="m5";
         break;
      case PERIOD_MN1:
         tf="mn1";
         break;
      case PERIOD_W1:
         tf="w1";
         break;
      default:
         tf="Unknown";
         break;
     }
   if(tagRed>255 || tagGreen>255 || tagBlue>255 || sidRed>255 || sidGreen>255 || sidBlue>255)
     {
      Alert("Watermark Red/Green/Blue components must each be in range 0..255");
     }
   tagRGB=(tagBlue<<16);
   tagRGB |= (tagGreen << 8);
   tagRGB |= tagRed;
   sidRGB=(sidBlue<<16);
   sidRGB |= (sidGreen << 8);
   sidRGB |= sidRed;
//-------------water marks
   if(ShowWatermark)
     {
      double chartHi,chartLo;
      double range;
      static double prevRange;
      chartHi = WindowPriceMax(0);
      chartLo = WindowPriceMin(0);
      range=chartHi-chartLo;
      // need only draw the watermark if the chart range has changed
      if(prevRange!=range)
        {
         ObjectsDeleteAll(0,OBJ_LABEL);
         ObjectDelete(SID);
         ObjectDelete(TAG);
         prevRange=range;
         watermark(SID,tf+Symbol(),sidFontSize,sidFontName,sidRGB,sidXPos,sidYPos);
         if(tagDisplayText && StringLen(tagText)>0)
           {
            watermark(TAG,tagText,tagFontSize,tagFontName,tagRGB,tagXPos,tagYPos);
           }
        }
     }
//-------------water marks
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0,OBJ_LABEL);
   ObjectDelete(SID);
   ObjectDelete(TAG);
//---
   DeleteButtons();
  }
//+------------------------------------------------------------------+
//| Expert tick function  (Indicator)                                |
//+------------------------------------------------------------------+
void OnTick()
  {
   DisplayINFO();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CreateButton(string btnName,string btnText,int &x,int y,int w,int h,color clrText,color clrBg,color clrBorder,int fontSize)
  {
   ObjectCreate(0,btnName,OBJ_BUTTON,0,0,0);
   ObjectSetInteger(0,btnName,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,btnName,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,btnName,OBJPROP_XSIZE,w);
   ObjectSetInteger(0,btnName,OBJPROP_YSIZE,h);
   ObjectSetString(0,btnName,OBJPROP_TEXT,btnText);
   ObjectSetInteger(0,btnName,OBJPROP_COLOR,clrText);
   ObjectSetInteger(0,btnName,OBJPROP_BGCOLOR,clrBg);
   ObjectSetInteger(0,btnName,OBJPROP_BORDER_COLOR,clrBorder);
   ObjectSetInteger(0,btnName,OBJPROP_BORDER_TYPE,BORDER_FLAT);
   ObjectSetInteger(0,btnName,OBJPROP_HIDDEN,true);
   ObjectSetInteger(0,btnName,OBJPROP_STATE,false);
   ObjectSetInteger(0,btnName,OBJPROP_FONTSIZE,fontSize);
   ObjectSetInteger(0,btnName,OBJPROP_BACK,false);
   ObjectSetInteger(0,btnName,OBJPROP_CORNER,Corner_RIGHT_TOP);
   x=x+w+10;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DeleteButtons()
  {
   for(i=ObjectsTotal()-1; i>-1; i--)
     {
      if(StringFind(ObjectName(i),"button")>=0)
         ObjectDelete(ObjectName(i));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(sparam=="button1") // Buy Net
     {
      Action_Button1();
      ObjectSetInteger(0,"button1",OBJPROP_STATE,false);
     }
   else
      if(sparam=="button2") // Net %  TP (Buy)
        {
         Action_Button2();
         ObjectSetInteger(0,"button2",OBJPROP_STATE,false);
        }
      else
         if(sparam=="button3") //Net % Sl (Buy)
           {
            Action_Button3();
            ObjectSetInteger(0,"button3",OBJPROP_STATE,false);
           }
         else
            if(sparam=="button4") //BreakEven  Net (Buy)
              {
               Action_Button4();
               ObjectSetInteger(0,"button4",OBJPROP_STATE,false);
              }
            else
               if(sparam=="button5") // Delete TP (Buy)
                 {
                  Action_Button5();
                  ObjectSetInteger(0,"button5",OBJPROP_STATE,false);
                 }
               else
                  if(sparam=="button6") // Delete SL (Buy)
                    {
                     Action_Button6();
                     ObjectSetInteger(0,"button6",OBJPROP_STATE,false);
                    }
                  else
                     if(sparam=="button7") // Close All (Buy)
                       {
                        Action_Button7();
                        ObjectSetInteger(0,"button7",OBJPROP_STATE,false);
                       }
                     else
                        if(sparam=="button8") // Hedge Net
                          {
                           Action_Button8();
                           ObjectSetInteger(0,"button8",OBJPROP_STATE,false);
                          }
                        else
                           if(sparam=="button9") // Net %  TP (Hedge)
                             {
                              Action_Button9();
                              ObjectSetInteger(0,"button9",OBJPROP_STATE,false);
                             }
                           else
                              if(sparam=="button10") //Net % Sl (Hedge)
                                {
                                 Action_Button10();
                                 ObjectSetInteger(0,"button10",OBJPROP_STATE,false);
                                }
                              else
                                 if(sparam=="button111") //BreakEven  Net TP/Sl (Hedge)
                                   {
                                    Action_Button11();
                                    ObjectSetInteger(0,"button11",OBJPROP_STATE,false);
                                   }
                                 else
                                    if(sparam=="button12") // Delete TP (Hedge)
                                      {
                                       Action_Button12();
                                       ObjectSetInteger(0,"button12",OBJPROP_STATE,false);
                                      }
                                    else
                                       if(sparam=="button13") // Delete SL (Hedge)
                                         {
                                          Action_Button13();
                                          ObjectSetInteger(0,"button13",OBJPROP_STATE,false);
                                         }
                                       else
                                          if(sparam=="button14") // Close All (Hedge)
                                            {
                                             Action_Button14();
                                             ObjectSetInteger(0,"button14",OBJPROP_STATE,false);
                                            }
                                          else
                                             if(sparam=="button15") // Sell Net
                                               {
                                                Action_Button15();
                                                ObjectSetInteger(0,"button15",OBJPROP_STATE,false);
                                               }
                                             else
                                                if(sparam=="button16") // Net %  TP (Sell)
                                                  {
                                                   Action_Button16();
                                                   ObjectSetInteger(0,"button16",OBJPROP_STATE,false);
                                                  }
                                                else
                                                   if(sparam=="button17") //Net %  Sl (Sell)
                                                     {
                                                      Action_Button17();
                                                      ObjectSetInteger(0,"button17",OBJPROP_STATE,false);
                                                     }
                                                   else
                                                      if(sparam=="button18") //BreakEven Net TP/Sl (Sell)
                                                        {
                                                         Action_Button18();
                                                         ObjectSetInteger(0,"button18",OBJPROP_STATE,false);
                                                        }
                                                      else
                                                         if(sparam=="button19") // Delete TP (Sell)
                                                           {
                                                            Action_Button19();
                                                            ObjectSetInteger(0,"button19",OBJPROP_STATE,false);
                                                           }
                                                         else
                                                            if(sparam=="button20") // Delete SL (Sell)
                                                              {
                                                               Action_Button20();
                                                               ObjectSetInteger(0,"button20",OBJPROP_STATE,false);
                                                              }
                                                            else
                                                               if(sparam=="button21") // Close All (Sell)
                                                                 {
                                                                  Action_Button21();
                                                                  ObjectSetInteger(0,"button21",OBJPROP_STATE,false);
                                                                 }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button1()
  {
   OrderBuyNet();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button2()
  {
   BuyNetTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button3()
  {
   BuyNetSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button4()
  {
   BuyNetBE();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button5()
  {
   BuyDeleteTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button6()
  {
   BuyDeleteSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button7()
  {
   CloseBuy();
   if(CloseProfitOnly && ProfitPercen)
     {
      BuyNetTP();
     }
   if(CloseProfitOnly && StopPercen)
     {
      BuyNetSL();
     }
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button8()
  {
   OrderBuyNet();
   OrderSellNet();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button9()
  {
   BuyNetTP();
   SellNetTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button10()
  {
   BuyNetSL();
   SellNetSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button11()
  {
   BuyNetBE();
   SellNetBE();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button12()
  {
   BuyDeleteTP();
   SellDeleteTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button13()
  {
   BuyDeleteSL();
   SellDeleteSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button14()
  {
   CloseBuy();
   CloseSell();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button15()
  {
   OrderSellNet();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button16()
  {
   SellNetTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button17()
  {
   SellNetSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button18()
  {
   SellNetBE();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button19()
  {
   SellDeleteTP();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button20()
  {
   SellDeleteSL();
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Action_Button21()
  {
   CloseSell();
   if(CloseProfitOnly && ProfitPercen)
     {
      SellNetTP();
     }
   if(CloseProfitOnly && StopPercen)
     {
      SellNetSL();
     }
   PlaySound("ok.wav");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OrderBuyNet()
  {
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   Price=Bid;
//---------------buy order-------------
   ticket=OrderSend(Symbol(),OP_BUY,GetLots(),Price,30,0,0,"BuyOrder-L"+IntegerToString(Total+1),0,0,Green);
   if(ticket<0)
     {
      err=GetLastError();
      Alert(Symbol()+":BUY FAILED : ErrorDescription("+IntegerToString(err)+")");
     }
   else
     {
      Alert(Symbol()+":BUY at "+DoubleToStr(Price,Digits)+" TP="+DoubleToStr(0,Digits)+",SL="+DoubleToStr(0,Digits));
      if(ProfitPercen)
        {
         BuyNetTP();
        }
      if(StopPercen)
        {
         BuyNetSL();
        }
     }
//+------------------------------------------------------------------+
   Alert("--- END "+WindowExpertName()+" "+Symbol());
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OrderSellNet()
  {
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   Price=Ask;
//------------sell order----------
   ticket=OrderSend(Symbol(),OP_SELL,GetLots(),Price,30,0,0,"SellOrder-L"+IntegerToString(Total+1),0,0,Green);
   if(ticket<0)
     {
      err=GetLastError();
      Alert(Symbol()+":SELL FAILED : ErrorDescription("+IntegerToString(err)+"");
     }
   else
     {
      Alert(Symbol()+":SELL at "+DoubleToStr(Price,Digits)+" TP="+DoubleToStr(0,Digits)+",SL="+DoubleToStr(0,Digits));
      if(ProfitPercen)
        {
         SellNetTP();
        }
      if(StopPercen)
        {
         SellNetSL();
        }
     }
//+------------------------------------------------------------------+
   Alert("--- END "+WindowExpertName()+" "+Symbol());
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BuyNetTP()
  {
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   double BLotsSymbol=0,SL=0,TP=0,PriceAvg=0;
   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
        {
         BLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   getpip();
   Credit=AccountCredit();
   Balance=AccountBalance();
   ProfitPercentage=(Balance+Credit) *(ProfitPercent/100);
   ProfitPipsMath=NormalizeDouble((ProfitPercentage)/((BLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   if(ProfitPercent>0)
      TP=Price+ProfitPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && BLotsSymbol!=0)
              {
               SL = OrderStopLoss();
               int ticket4=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BuyNetSL()
  {
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   double BLotsSymbol=0,SL=0,TP=0,PriceAvg=0;
   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
        {
         BLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   getpip();
   Credit=AccountCredit();
   Balance=AccountBalance();
   StopPercentage=(Balance+Credit) *(StopPercent/100);
   StopPipsMath=NormalizeDouble((StopPercentage)/((BLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   if(StopPercent  >0)
      SL=Price-StopPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && BLotsSymbol!=0)
              {
               TP=OrderTakeProfit();
               int ticket4=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BuyNetBE()
  {
   double BLotsSymbol=0,SL=0, TP=0,PriceAvg=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+

   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
        {
         BLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   Credit=AccountCredit();
   Balance=AccountBalance();
   StopPercentage=(Balance+Credit) *(BreakEvenPercent/100);
   StopPipsMath=NormalizeDouble((StopPercentage)/((BLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   getpip();
   if(BreakEvenPercent  >0)
      SL=Price+StopPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && BLotsSymbol!=0)
              {
               TP=OrderTakeProfit();
               int ticket4=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SellNetTP()
  {
   double SLotsSymbol=0,SL=0,TP=0,PriceAvg=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
        {
         SLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   Credit=AccountCredit();
   Balance=AccountBalance();
   ProfitPercentage=(Balance+Credit) *(ProfitPercent/100);
   ProfitPipsMath=NormalizeDouble((ProfitPercentage)/((SLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   getpip();
   if(ProfitPercent>0)
      TP = Price-ProfitPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {

            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && SLotsSymbol!=0)
              {
               SL = OrderStopLoss();
               int ticket5=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SellNetSL()
  {
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   double SLotsSymbol=0,SL=0,TP=0,PriceAvg=0;
   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
        {
         SLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   Credit=AccountCredit();
   Balance=AccountBalance();
   StopPercentage=(Balance+Credit) *(StopPercent/100);
   StopPipsMath=NormalizeDouble((StopPercentage)/((SLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   getpip();
   if(StopPercent  >0)
      SL = Price+StopPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {

            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && SLotsSymbol!=0)
              {
               TP = OrderTakeProfit();
               int ticket5=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SellNetBE()
  {
   double SLotsSymbol=0,SL=0,TP=0,PriceAvg=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   for(int j=0; j<OrdersTotal(); j++)
     {
      int ticket2=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
      if(ticket2<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
        {
         SLotsSymbol+=OrderLots();
         PriceAvg+=OrderOpenPrice();
        }
     }
//+------------------------------------------------------------------+
   Credit=AccountCredit();
   Balance=AccountBalance();
   StopPercentage=(Balance+Credit) *(BreakEvenPercent/100);
   StopPipsMath=NormalizeDouble((StopPercentage)/((SLotsSymbol)/account_type),0);
   Price=NormalizeDouble(PriceAvg/Total,5);
   getpip();
   if(BreakEvenPercent  >0)
      SL = Price-StopPipsMath*pip;
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {

            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && SLotsSymbol!=0)
              {
               TP = OrderTakeProfit();
               int ticket5=OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   RefreshRates();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BuyDeleteTP()
  {
   double SL=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
              {
               SL=OrderStopLoss();
               int ticket4=OrderModify(OrderTicket(),OrderOpenPrice(),SL,0,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BuyDeleteSL()
  {
   double TP=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY)
              {
               TP=OrderTakeProfit();
               int ticket4=OrderModify(OrderTicket(),OrderOpenPrice(),0,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SellDeleteTP()
  {
   double SL=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
              {
               SL=OrderStopLoss();
               int ticket5=OrderModify(OrderTicket(),OrderOpenPrice(),SL,0,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SellDeleteSL()
  {
   double TP=0;
   Total=OrdersTotal();
//+------------------------------------------------------------------+
   if(Total>0)
     {
      for(i=Total-1; i>=0; i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
           {
            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL)
              {
               TP=OrderTakeProfit();
               int ticket5=OrderModify(OrderTicket(),OrderOpenPrice(),0,TP,OrderExpiration(),CLR_NONE);
              }
           }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseBuy()
  {
   bool closed=false;
   for(i=OrdersTotal(); i>=0; i--)
     {
      ticket=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      while(IsTradeContextBusy())
         Sleep(100);
      RefreshRates();
      if(!CloseOnlyCurrentSymbol)
        {
         if(OrderType()==OP_BUY && !CloseProfitOnly)
           {
            closed=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
           }
         else
            if(OrderType()==OP_BUY && CloseProfitOnly && OrderProfit()>0)
              {
               closed=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
              }
        }
      else
        {
         if(OrderType()==OP_BUY && Symbol()==OrderSymbol() && !CloseProfitOnly)
           {
            closed=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
           }
         else
            if(OrderType()==OP_BUY && Symbol()==OrderSymbol() && CloseProfitOnly && OrderProfit()>0)
              {
               closed=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);
              }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseSell()
  {
   bool closed=false;
   for(i=OrdersTotal(); i>=0; i--)
     {
      ticket=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      while(IsTradeContextBusy())
         Sleep(100);
      RefreshRates();
      if(!CloseOnlyCurrentSymbol)
        {
         if(OrderType()==OP_SELL && !CloseProfitOnly)
           {
            closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
           }
         else
            if(OrderType()==OP_SELL && CloseProfitOnly && OrderProfit()>0)
              {
               closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
              }
        }
      else
        {
         if(OrderType()==OP_SELL && Symbol()==OrderSymbol() && !CloseProfitOnly)
           {
            closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
           }
         else
            if(OrderType()==OP_SELL && Symbol()==OrderSymbol() && CloseProfitOnly && OrderProfit()>0)
              {
               closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
              }
        }
     }
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void watermark(string obj,string text,int fontSize,string fontName,color colour,int xPos,int yPos)
  {
   ObjectCreate(obj,OBJ_LABEL,0,0,0);
   ObjectSetText(obj,text,fontSize,fontName,colour);
   ObjectSet(obj,OBJPROP_CORNER,0);
   ObjectSet(obj,OBJPROP_XDISTANCE,xPos);
   ObjectSet(obj,OBJPROP_YDISTANCE,yPos);
   ObjectSet(obj,OBJPROP_BACK,true);
  }
//+------------------------------------------------------------------+
//|           indicator ButtonTradingINFO_V2.06                      |
//+------------------------------------------------------------------+
void DisplayINFO()
  {
//Risk% Lot Size
   string PERCLOT="",PERCLOT2="",PERCLOT3="";
   PERCLOT=(DoubleToStr((MM_Risk_Percent_Lots),2));
   PERCLOT2=(DoubleToStr((MM_Risk_Percent_Lots*5),2));
   PERCLOT3=(DoubleToStr((MM_Risk_Percent_Lots*10),2));
   ObjectCreate("Risk%LOT",OBJ_LABEL,0,0,0);
   ObjectSetText("Risk%LOT","Risk %LOT",FontSize,FontType,CommentLabel_color);
   ObjectSet("Risk%LOT",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("Risk%LOT",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("Risk%LOT",OBJPROP_YDISTANCE,75+Shift_UP_DN);
   ObjectCreate("PERCLOT__V",OBJ_LABEL,0,0,0);
   ObjectSetText("PERCLOT__V",""+PERCLOT+" %",FontSize,FontType,White);
   ObjectSet("PERCLOT__V",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PERCLOT__V",OBJPROP_XDISTANCE,-73+Adjust_Side_to_side);
   ObjectSet("PERCLOT__V",OBJPROP_YDISTANCE,75+Shift_UP_DN);
//MM Lot size
   string MM__LOTS="", MM__LOTS2="", MM__LOTS3="";
   double GetiLots=GetLots();
   MM__LOTS =(DoubleToStr((GetiLots),2));
   MM__LOTS2=(DoubleToStr((GetiLots*5),2));
   MM__LOTS3=(DoubleToStr((GetiLots*10),2));
   ObjectCreate("MM_LOT",OBJ_LABEL,0,0,0);
   ObjectSetText("MM_LOT","MM_-_LOT",FontSize,FontType,CommentLabel_color);
   ObjectSet("MM_LOT",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("MM_LOT",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("MM_LOT",OBJPROP_YDISTANCE,85+Shift_UP_DN);
   ObjectCreate("MM__LOTS__V",OBJ_LABEL,0,0,0);
   ObjectSetText("MM__LOTS__V",""+MM__LOTS+"",FontSize,FontType,clrYellow);
   ObjectSet("MM__LOTS__V",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("MM__LOTS__V",OBJPROP_XDISTANCE,-60+Adjust_Side_to_side);
   ObjectSet("MM__LOTS__V",OBJPROP_YDISTANCE,85+Shift_UP_DN);
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   AE=AccountEquity();
//+------------------------------------------------------------------+
   double BTP_points=0,STP_points=0,profit=0,BLots=0,SLots=0,BLotsSymbol=0,SLotsSymbol=0,TLots=0,BProfit=0,BProfitOnly=0,SProfit=0,SProfitOnly=0;
   int T=0,TB=0,TS=0,TBsymbol=0,TSsymbol=0;
   for(i=0; i<OrdersTotal(); i++)
     {
      ticket=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-849 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-853 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      profit+=OrderProfit();
      if(OrderType()==0 && OrderSymbol()==Symbol())
         BLotsSymbol+=OrderLots();
      if(OrderType()==0 && OrderSymbol()==Symbol())
         BTP_points = OrderTakeProfit();
      if(OrderType()==0)
         BLots+=OrderLots();
      if(OrderType()==0)
         BProfit+=OrderProfit();
      if(OrderType()==0 && (OrderProfit()>0))
         BProfitOnly+=OrderProfit();
      if(OrderType()==0)
         TB++;
      if(OrderType()==1)
         TS++;
      if(OrderType()==0 && OrderSymbol()==Symbol())
         TBsymbol++;
      if(OrderType()==1 && OrderSymbol()==Symbol())
         TSsymbol++;
      if(OrderType()==1)
         SLots+=OrderLots();
      if(OrderType()==1 && OrderSymbol()==Symbol())
         SLotsSymbol+=OrderLots();
      if(OrderType()==1)
         SProfit+=OrderProfit();
      if(OrderType()==1 && (OrderProfit()>0))
         SProfitOnly+=OrderProfit();
      if(OrderType()==1 && OrderSymbol()==Symbol())
         STP_points = OrderTakeProfit();
     }
//+------------------------------------------------------------------+
   balance=0;
   for(i=0; i<OrdersHistoryTotal(); i++)
     {
      ticket=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-865 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-869 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderType()>1)
         continue; //|| OrderMagicNumber()!=magic
      balance+=OrderProfit();
     }
//---- Profit percentage
   ProfitPercentage=(AccountBalance()+Credit) *(ProfitPercent/100);
   tp_m=ProfitPercentage;
   tp_m2=profit;//equity profit *pl_factor
//---- Drawdown percentage
   double DrawDownPercentage=(AccountBalance()+Credit) *(StopPercent/100);
   sl_m=DrawDownPercentage;
   sl_m2=profit;//equity profit *pl_factor
//+------------------------------------------------------------------+
   if(t_profit==0 || balance+profit>t_profit)
      t_profit=balance;
   double SBalance=AccountBalance();
   Credit=AccountCredit();
   double getDepo=getDeposit();
   double getDWD=getWithdrawal();
   double PerctBal=t_profit/(getDepo+Credit)*100;
   double perctTarget=tp_m2 /(SBalance+Credit)*100;
   double PerctBalEA = (tp_m2+t_profit)/ (getDepo+Credit)*100;
   double percentBProfit=BProfit /(SBalance+Credit) *100;
   double percentSProfit=SProfit /(SBalance+Credit) *100;
   TLots=BLots-SLots;
   T = TB+TS;
//Total Buy Lot/count
   if(TB>0)
     {
      TBcount_color=clrLime;
     }
   else
     {
      TBcount_color = clrDimGray;
     }
   ObjectCreate("BuyLot",OBJ_LABEL,0,0,0);
   ObjectSetText("BuyLot","Buy Odr",FontSize,FontType,TBcount_color);//TBcount_color
   ObjectSet("BuyLot",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BuyLot",OBJPROP_XDISTANCE,-147+Adjust_Side_to_side);
   ObjectSet("BuyLot",OBJPROP_YDISTANCE,45+Shift_UP_DN);
   ObjectCreate("TLotsV3",OBJ_LABEL,0,0,0);
   ObjectSetText("TLotsV3",""+DoubleToStr(BLots,2)+" Lot",FontSize,FontType,TBcount_color);
   ObjectSet("TLotsV3",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TLotsV3",OBJPROP_XDISTANCE,-145+Adjust_Side_to_side);
   ObjectSet("TLotsV3",OBJPROP_YDISTANCE,55+Shift_UP_DN);
   ObjectCreate("PairPLOTs3",OBJ_LABEL,0,0,0);
   ObjectSetText("PairPLOTs3",""+IntegerToString(TB)+" Lyr",FontSize,FontType,TBcount_color);
   ObjectSet("PairPLOTs3",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PairPLOTs3",OBJPROP_XDISTANCE,-145+Adjust_Side_to_side);
   ObjectSet("PairPLOTs3",OBJPROP_YDISTANCE,65+Shift_UP_DN);
//Total Sell Lot/count
   if(TS>0)
     {
      TScount_color=clrRed;
     }
   else
     {
      TScount_color = clrDimGray;
     }
   ObjectCreate("SellLot",OBJ_LABEL,0,0,0);
   ObjectSetText("SellLot","Sell Odr",FontSize,FontType,TScount_color);//TScount_color
   ObjectSet("SellLot",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SellLot",OBJPROP_XDISTANCE,-147+Adjust_Side_to_side);
   ObjectSet("SellLot",OBJPROP_YDISTANCE,85+Shift_UP_DN);
   ObjectCreate("TLotsV2",OBJ_LABEL,0,0,0);
   ObjectSetText("TLotsV2",""+DoubleToStr(SLots,2)+" Lot",FontSize,FontType,TScount_color);
   ObjectSet("TLotsV2",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TLotsV2",OBJPROP_XDISTANCE,-145+Adjust_Side_to_side);
   ObjectSet("TLotsV2",OBJPROP_YDISTANCE,95+Shift_UP_DN);
   ObjectCreate("PairPLOTs2",OBJ_LABEL,0,0,0);
   ObjectSetText("PairPLOTs2",""+IntegerToString(TS)+" Lyr",FontSize,FontType,TScount_color);
   ObjectSet("PairPLOTs2",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PairPLOTs2",OBJPROP_XDISTANCE,-145+Adjust_Side_to_side);
   ObjectSet("PairPLOTs2",OBJPROP_YDISTANCE,105+Shift_UP_DN);
   if(SendLotsAlert && !HedgeLotsAlert && AlertDelay() && (TLots>=GetiLots || TLots<=-GetiLots))
     {
      Alert("HedgLot = "+DoubleToStr(TLots,2)+"");
      PlaySound("Alert.wav");
      SendNotification("HedgLot = "+DoubleToStr(TLots,2)+"");
     }
   if(SendLotsAlert && HedgeLotsAlert && AlertDelay() && (TLots>=0.01 || TLots<=-0.01))
     {
      Alert("HedgLot = "+DoubleToStr(TLots,2)+"");
      PlaySound("Alert.wav");
      SendNotification("HedgLot = "+DoubleToStr(TLots,2)+"");
     }
//Pips before Acc. MC
   double TooLots=TLots/account_type;
//NormalizeDouble(TooLots,2);
   double LevelStopOut=AE -(AE *0.2);// 20% XM broker stop out by margin requirement
   if(TooLots==0)
     {
      PipsB4MCvalue=LevelStopOut/(GetiLots/account_type);
     }
   else
     {
      PipsB4MCvalue=LevelStopOut/TooLots;
     }
   ObjectCreate("PipsB4MC",OBJ_LABEL,0,0,0);
   ObjectSetText("PipsB4MC","Pips B4MC",FontSize,FontType,CommentLabel_color);
   ObjectSet("PipsB4MC",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PipsB4MC",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("PipsB4MC",OBJPROP_YDISTANCE,45+Shift_UP_DN);
   ObjectCreate("PipsB4MCvalue",OBJ_LABEL,0,0,0);
   ObjectSetText("PipsB4MCvalue",""+DoubleToStr(PipsB4MCvalue,0)+"",FontSize,FontType,Red);
   ObjectSet("PipsB4MCvalue",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PipsB4MCvalue",OBJPROP_XDISTANCE,-60+Adjust_Side_to_side);
   ObjectSet("PipsB4MCvalue",OBJPROP_YDISTANCE,45+Shift_UP_DN);
//Total Hedge lot = Buy Lot - Sell Lot
   double TPLots=BLotsSymbol-SLotsSymbol;
   if(TLots>0)
     {
      color_HedgLOT=clrLime;
     }
   if(TLots<0)
     {
      color_HedgLOT=clrRed;
     }
   if(TLots==0)
     {
      color_HedgLOT=clrDimGray;
     }
   ObjectCreate("HedgLOT",OBJ_LABEL,0,0,0);
   ObjectSetText("HedgLOT","HedgeLOT",FontSize,FontType,CommentLabel_color);
   ObjectSet("HedgLOT",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("HedgLOT",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("HedgLOT",OBJPROP_YDISTANCE,55+Shift_UP_DN);
   ObjectCreate("TLotsV",OBJ_LABEL,0,0,0);
   ObjectSetText("TLotsV",""+DoubleToStr(TLots,2)+"",FontSize,FontType,color_HedgLOT);
   ObjectSet("TLotsV",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TLotsV",OBJPROP_XDISTANCE,-60+Adjust_Side_to_side);
   ObjectSet("TLotsV",OBJPROP_YDISTANCE,55+Shift_UP_DN);
//Total Pair LOT
   if(TPLots>0)
     {
      color_TPLOT=clrLime;
     }
   if(TPLots<0)
     {
      color_TPLOT=clrRed;
     }
   if(TPLots==0)
     {
      color_TPLOT=clrDimGray;
     }
   ObjectCreate("PairLOT",OBJ_LABEL,0,0,0);
   ObjectSetText("PairLOT","Pair_ _LOT",FontSize,FontType,CommentLabel_color);
   ObjectSet("PairLOT",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PairLOT",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("PairLOT",OBJPROP_YDISTANCE,65+Shift_UP_DN);
   ObjectCreate("PairPLOTs",OBJ_LABEL,0,0,0);
   ObjectSetText("PairPLOTs",""+DoubleToStr(TPLots,2)+"",FontSize,FontType,color_TPLOT);
   ObjectSet("PairPLOTs",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("PairPLOTs",OBJPROP_XDISTANCE,-60+Adjust_Side_to_side);
   ObjectSet("PairPLOTs",OBJPROP_YDISTANCE,65+Shift_UP_DN);
//Buy Net Profit
   double BuyNet=NormalizeDouble(percentBProfit,2);
   if(BuyNet>0)
     {
      color_Bnet=clrLime;
     }
   if(BuyNet<0)
     {
      color_Bnet=clrRed;
     }
   if(BuyNet==0)
     {
      color_Bnet=clrDimGray;
     }
   ObjectCreate("BuyNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("BuyNet%","Buy___Net",FontSize,FontType,CommentLabel_color);
   ObjectSet("BuyNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BuyNet%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("BuyNet%",OBJPROP_YDISTANCE,125+Shift_UP_DN);
   ObjectCreate("BuyNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("BuyNet%v",""+(DoubleToStr(percentBProfit,1))+" %",FontSize,FontType,color_Bnet);
   ObjectSet("BuyNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BuyNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("BuyNet%v",OBJPROP_YDISTANCE,125+Shift_UP_DN);
   ObjectCreate("BuyNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("BuyNet%v$",""+(DoubleToStr(BProfit,2))+" $",FontSize,FontType,color_Bnet);
   ObjectSet("BuyNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BuyNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("BuyNet%v$",OBJPROP_YDISTANCE,125+Shift_UP_DN);
//Buy Profit
   double BProfitNet=BProfitOnly;
   double BProfitperctTarget=NormalizeDouble(BProfitNet /(SBalance+Credit)*100,2);
   if(BProfitNet>0)
     {
      color_BProfitNet=clrLime;
     }
   if(BProfitNet<0)
     {
      color_BProfitNet=clrRed;
     }
   if(BProfitNet==0)
     {
      color_BProfitNet=clrDimGray;
     }
   ObjectCreate("BProfitNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("BProfitNet%","Buy_Profit",FontSize,FontType,CommentLabel_color);
   ObjectSet("BProfitNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BProfitNet%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("BProfitNet%",OBJPROP_YDISTANCE,135+Shift_UP_DN);
   ObjectCreate("BProfitNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("BProfitNet%v",""+(DoubleToStr(BProfitperctTarget,1))+" %",FontSize,FontType,color_BProfitNet);
   ObjectSet("BProfitNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BProfitNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("BProfitNet%v",OBJPROP_YDISTANCE,135+Shift_UP_DN);
   ObjectCreate("BProfitNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("BProfitNet%v$",""+(DoubleToStr(BProfitNet,2))+" $",FontSize,FontType,color_BProfitNet);
   ObjectSet("BProfitNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BProfitNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("BProfitNet%v$",OBJPROP_YDISTANCE,135+Shift_UP_DN);
//Sell Net Profit
   double SellNet=NormalizeDouble(percentSProfit,2);
   if(SellNet>0)
     {
      color_Snet=clrLime;
     }
   if(SellNet<0)
     {
      color_Snet=clrRed;
     }
   if(SellNet==0)
     {
      color_Snet=clrDimGray;
     }
   ObjectCreate("SellNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("SellNet%","Sell___Net",FontSize,FontType,CommentLabel_color);
   ObjectSet("SellNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SellNet%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("SellNet%",OBJPROP_YDISTANCE,145+Shift_UP_DN);
   ObjectCreate("SellNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("SellNet%v",""+DoubleToStr(percentSProfit,1)+" %",FontSize,FontType,color_Snet);
   ObjectSet("SellNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SellNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("SellNet%v",OBJPROP_YDISTANCE,145+Shift_UP_DN);
   ObjectCreate("SellNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("SellNet%v$",""+DoubleToStr(SProfit,2)+" $",FontSize,FontType,color_Snet);
   ObjectSet("SellNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SellNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("SellNet%v$",OBJPROP_YDISTANCE,145+Shift_UP_DN);
//Sell profit
   double SProfitNet=SProfitOnly;
   double SProfitperctTarget=NormalizeDouble(SProfitNet /(SBalance+Credit)*100,2);
   if(SProfitNet>0)
     {
      color_SProfitNet=clrLime;
     }
   if(SProfitNet<0)
     {
      color_SProfitNet=clrRed;
     }
   if(SProfitNet==0)
     {
      color_SProfitNet=clrDimGray;
     }
   ObjectCreate("SProfitNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("SProfitNet%","Sell_Profit",FontSize,FontType,CommentLabel_color);
   ObjectSet("SProfitNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SProfitNet%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("SProfitNet%",OBJPROP_YDISTANCE,155+Shift_UP_DN);
   ObjectCreate("SProfitNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("SProfitNet%v",""+DoubleToStr(SProfitperctTarget,1)+" %",FontSize,FontType,color_SProfitNet);
   ObjectSet("SProfitNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SProfitNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("SProfitNet%v",OBJPROP_YDISTANCE,155+Shift_UP_DN);
   ObjectCreate("SProfitNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("SProfitNet%v$",""+DoubleToStr(SProfitNet,2)+" $",FontSize,FontType,color_SProfitNet);
   ObjectSet("SProfitNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("SProfitNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("SProfitNet%v$",OBJPROP_YDISTANCE,155+Shift_UP_DN);
//Total Net
   double TotalNet=SProfit+BProfit;
   if(TotalNet>0)
     {
      color_Tnet=clrLime;
     }
   if(TotalNet<0)
     {
      color_Tnet=clrRed;
     }
   if(TotalNet==0)
     {
      color_Tnet=clrDimGray;
     }
   ObjectCreate("TotalNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("TotalNet%","Total__Net",FontSize,FontType,CommentLabel_color);
   ObjectSet("TotalNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TotalNet%",OBJPROP_XDISTANCE,-15+Adjust_Side_to_side);
   ObjectSet("TotalNet%",OBJPROP_YDISTANCE,165+Shift_UP_DN);
   ObjectCreate("TotalNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("TotalNet%v",""+DoubleToStr(perctTarget,1)+" %",FontSize,FontType,color_Tnet);
   ObjectSet("TotalNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TotalNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("TotalNet%v",OBJPROP_YDISTANCE,165+Shift_UP_DN);
   ObjectCreate("TotalNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("TotalNet%v$",""+(DoubleToStr(TotalNet,2))+" $",FontSize,FontType,color_Tnet);
   ObjectSet("TotalNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TotalNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("TotalNet%v$",OBJPROP_YDISTANCE,165+Shift_UP_DN);
//Net Profit
   double ProfitNet=NormalizeDouble(SProfitOnly+BProfitOnly,2);
   double ProfitperctTarget=ProfitNet /(SBalance+Credit)*100;
   if(ProfitNet>0)
     {
      color_ProfitNet=clrLime;
     }
   if(ProfitNet<0)
     {
      color_ProfitNet=clrRed;
     }
   if(ProfitNet==0)
     {
      color_ProfitNet=clrDimGray;
     }
   ObjectCreate("ProfitNet%",OBJ_LABEL,0,0,0);
   ObjectSetText("ProfitNet%","Net_Profit",FontSize,FontType,CommentLabel_color);
   ObjectSet("ProfitNet%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ProfitNet%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("ProfitNet%",OBJPROP_YDISTANCE,175+Shift_UP_DN);
   ObjectCreate("ProfitNet%v",OBJ_LABEL,0,0,0);
   ObjectSetText("ProfitNet%v",""+(DoubleToStr(ProfitperctTarget,1))+" %",FontSize,FontType,color_ProfitNet);
   ObjectSet("ProfitNet%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ProfitNet%v",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("ProfitNet%v",OBJPROP_YDISTANCE,175+Shift_UP_DN);
   ObjectCreate("ProfitNet%v$",OBJ_LABEL,0,0,0);
   ObjectSetText("ProfitNet%v$",""+(DoubleToStr(ProfitNet,2))+" $",FontSize,FontType,color_ProfitNet);
   ObjectSet("ProfitNet%v$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ProfitNet%v$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("ProfitNet%v$",OBJPROP_YDISTANCE,175+Shift_UP_DN);
//Balance
   double PerctBalvalue = NormalizeDouble(PerctBal*100/100,2);
   double dollarBalvalue=t_profit;
   if(PerctBalvalue > 0)
     {
      color_ProfitBal = clrLime;
     }
   if(PerctBalvalue < 0)
     {
      color_ProfitBal = clrRed;
     }
   if(PerctBalvalue == 0)
     {
      color_ProfitBal = clrDimGray;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   ObjectCreate("AllTime%",OBJ_LABEL,0,0,0);
   ObjectSetText("AllTime%","Balance",FontSize,FontType,CommentLabel_color);
   ObjectSet("AllTime%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("AllTime%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("AllTime%",OBJPROP_YDISTANCE,185+Shift_UP_DN);
   ObjectCreate("DollarTotalBAL$",OBJ_LABEL,0,0,0);
   ObjectSetText("DollarTotalBAL$",""+DoubleToStr(dollarBalvalue,2)+" $",FontSize,FontType,color_ProfitBal);
   ObjectSet("DollarTotalBAL$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("DollarTotalBAL$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("DollarTotalBAL$",OBJPROP_YDISTANCE,185+Shift_UP_DN);
   ObjectCreate("ProfitTotalBAL%",OBJ_LABEL,0,0,0);
   ObjectSetText("ProfitTotalBAL%",""+DoubleToStr(PerctBalvalue,1)+" %",FontSize,FontType,color_ProfitBal);
   ObjectSet("ProfitTotalBAL%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ProfitTotalBAL%",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("ProfitTotalBAL%",OBJPROP_YDISTANCE,185+Shift_UP_DN);
//Equity
   double PerctEQvalue =NormalizeDouble(PerctBalEA*100/100,2);
   double dollarEQvalue=balance+profit;
   if(PerctEQvalue > 0)
     {
      color_ProfitEq = clrLime;
     }
   if(PerctEQvalue < 0)
     {
      color_ProfitEq = clrRed;
     }
   if(PerctEQvalue == 0)
     {
      color_ProfitEq = clrDimGray;
     }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   ObjectCreate("ReturnProfit",OBJ_LABEL,0,0,0);
   ObjectSetText("ReturnProfit","Equity",FontSize,FontType,CommentLabel_color);
   ObjectSet("ReturnProfit",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ReturnProfit",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("ReturnProfit",OBJPROP_YDISTANCE,195+Shift_UP_DN);
   ObjectCreate("DollarTotalEQ$",OBJ_LABEL,0,0,0);
   ObjectSetText("DollarTotalEQ$",""+DoubleToStr(dollarEQvalue,2)+" $",FontSize,FontType,color_ProfitEq);
   ObjectSet("DollarTotalEQ$",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("DollarTotalEQ$",OBJPROP_XDISTANCE,-90+Adjust_Side_to_side);
   ObjectSet("DollarTotalEQ$",OBJPROP_YDISTANCE,195+Shift_UP_DN);
   ObjectCreate("ProfitTotalEQ%",OBJ_LABEL,0,0,0);
   ObjectSetText("ProfitTotalEQ%",""+DoubleToStr(PerctEQvalue,1)+" %",FontSize,FontType,color_ProfitEq);
   ObjectSet("ProfitTotalEQ%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("ProfitTotalEQ%",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("ProfitTotalEQ%",OBJPROP_YDISTANCE,195+Shift_UP_DN);
//Profit %
   ObjectCreate("Profit%",OBJ_LABEL,0,0,0);
   ObjectSetText("Profit%","Profit___%",FontSize,FontType,CommentLabel_color);
   ObjectSet("Profit%",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("Profit%",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("Profit%",OBJPROP_YDISTANCE,95+Shift_UP_DN);
   ObjectCreate("Profit%v",OBJ_LABEL,0,0,0);
   ObjectSetText("Profit%v",""+(DoubleToStr((ProfitPercent),2))+" %",FontSize,FontType,clrWhite);
   ObjectSet("Profit%v",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("Profit%v",OBJPROP_XDISTANCE,-73+Adjust_Side_to_side);
   ObjectSet("Profit%v",OBJPROP_YDISTANCE,95+Shift_UP_DN);
//Target $/%
   ObjectCreate("Target $",OBJ_LABEL,0,0,0);
   ObjectSetText("Target $","Target_-_$",FontSize,FontType,CommentLabel_color);
   ObjectSet("Target $",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("Target $",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("Target $",OBJPROP_YDISTANCE,105+Shift_UP_DN);
   ObjectCreate("TargetLots2",OBJ_LABEL,0,0,0);
   ObjectSetText("TargetLots2",""+DoubleToStr(tp_m,2)+" $",FontSize,FontType,clrYellow);
   ObjectSet("TargetLots2",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TargetLots2",OBJPROP_XDISTANCE,-70+Adjust_Side_to_side);
   ObjectSet("TargetLots2",OBJPROP_YDISTANCE,105+Shift_UP_DN);
//TP pips
   double pipsMath=NormalizeDouble((tp_m)/(GetiLots/account_type),0);
   ObjectCreate("TP=Pips",OBJ_LABEL,0,0,0);
   ObjectSetText("TP=Pips","TP == Pips",FontSize,FontType,CommentLabel_color);
   ObjectSet("TP=Pips",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("TP=Pips",OBJPROP_XDISTANCE,-13+Adjust_Side_to_side);
   ObjectSet("TP=Pips",OBJPROP_YDISTANCE,115+Shift_UP_DN);
   ObjectCreate("pipsMathv",OBJ_LABEL,0,0,0);
   ObjectSetText("pipsMathv",""+DoubleToStr(pipsMath,0)+"",FontSize,FontType,clrYellow);
   ObjectSet("pipsMathv",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("pipsMathv",OBJPROP_XDISTANCE,-60+Adjust_Side_to_side);
   ObjectSet("pipsMathv",OBJPROP_YDISTANCE,115+Shift_UP_DN);
   if(BTP_points != 0)
      BTP= BTP_points-Bid;
   else
      BTP = 0;
   BTPipsValue = NormalizeDouble(BTP*10000,0);
   if(TB!=0)
      BTP_color = clrLime;
   else
      BTP_color = clrGray;
   ObjectCreate("BTPointsV",OBJ_LABEL,0,0,0);
   ObjectSetText("BTPointsV",""+DoubleToStr(BTPipsValue,0)+" Gap",FontSize,FontType,BTP_color);
   ObjectSet("BTPointsV",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("BTPointsV",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("BTPointsV",OBJPROP_YDISTANCE,75+Shift_UP_DN);
//Gap Sell TP
   if(STP_points != 0)
     {
      STP= STP_points-Ask;
     }
   else
     {
      STP = 0;
     }
   STPipsValue = NormalizeDouble(STP*10000,0);
   if(TS!=0)
     {
      STP_color = clrRed;
     }
   else
     {
      STP_color = clrGray;
     }
   ObjectCreate("STPointsV",OBJ_LABEL,0,0,0);
   ObjectSetText("STPointsV",""+DoubleToStr(STPipsValue,0)+" Gap",FontSize,FontType,STP_color);
   ObjectSet("STPointsV",OBJPROP_CORNER,Corner_of_Chart_RIGHT_TOP);
   ObjectSet("STPointsV",OBJPROP_XDISTANCE,-148+Adjust_Side_to_side);
   ObjectSet("STPointsV",OBJPROP_YDISTANCE,115+Shift_UP_DN);
//----
   if(ShowComment)
     {
      line_1 ="                                      Total Layer  = "+IntegerToString(T)
              +" | Total Lot = "+DoubleToStr(TLots,2)+" | Total BLot  = "+DoubleToStr(BLots,2)+" | Total SLot = "+DoubleToStr(SLots,2)+"\n";
      line_2 ="                                      Equity   = $ "+DoubleToStr(AE,2)+" | Spread = "+DoubleToStr((Ask-Bid)/pt,2)+"   | Total Buy  = "+IntegerToString(TB)+"    | Total Sell   = "+IntegerToString(TS)+"\n";
      line_3 ="                                      Balance = $ "+DoubleToStr(SBalance,2)+" | Credit  =  $ "+DoubleToStr(Credit,2)+"  |  Deposit  =  $ "+DoubleToStr(getDepo,2)+"\n";
      line_4 ="                                      Profit   $ = "+DoubleToStr(balance+profit,2)+"  /  "+DoubleToStr(t_profit,2)+"  |  Withdrawal  =  $ "+DoubleToStr(getDWD,2)+" \n";
      line_5 ="                                      Profit   % = "+DoubleToStr(MathRound(PerctBalEA*100)/100,1)+"  /  "+DoubleToStr(MathRound(PerctBal*100)/100,1)+" \n";
      line_6 ="                                      Target $ = "+DoubleToStr(tp_m2,2)+"  /   "+DoubleToStr(tp_m,2)+"\n";
      line_7 ="                                      Target % = "+DoubleToStr(perctTarget,2)+"  /   "+DoubleToStr(ProfitPercent,2)+"\n";
      line_8 ="                                      Profit Buy = $ "+DoubleToStr(BProfit,2)+"   |   "+DoubleToStr(percentBProfit,2)+" %\n";
      line_9 ="                                      Profit Sell = $ "+DoubleToStr(SProfit,2)+"   |   "+DoubleToStr(percentSProfit,2)+" %\n";
      line_10="                                      #Buy = "+IntegerToString(TBsymbol)+"   LotBuy = "+DoubleToStr(BLotsSymbol,2)+"  |  #Sell = "+IntegerToString(TSsymbol)+"   LotSell =  "+DoubleToStr(SLotsSymbol,2)+"  |  TPairLot = "+DoubleToStr(TPLots,2)+"\n";
      Comment(line_1,line_2,line_3,line_4,line_5,line_6,line_7,line_8,line_9,line_10);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getDeposit()
  {
   int total,cnt;
   double deposits=0;
   total=OrdersHistoryTotal();
   for(cnt=0; cnt<total; cnt++)
     {
      ticket=OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-493 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-497 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderType()==6 && OrderProfit()>0)
        {
         deposits+=OrderProfit();
        }
     }
   return(deposits);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getWithdrawal()
  {
   int total,cnt;
   double withdrawal=0;
   total=OrdersHistoryTotal();
   for(cnt=0; cnt<total; cnt++)
     {
      ticket=OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);
      if(ticket<0)//----added by tradercapaym
        {
         // Print("CL-493 , OrderSelect Error: ", GetLastError());
        }
      else
        {
         // Print("CL-497 , Order Select Successfully, Ticket # is : " + OrderTicket());
        }
      if(OrderType()==6 && OrderProfit()<0)
        {
         withdrawal+=OrderProfit();
        }
     }
   return(withdrawal);
  }
//+------------------------------------------------------------------+
//|                       Alert Notifications                                     |
//+------------------------------------------------------------------+
bool AlertDelay()
  {
   static datetime last_time;
   if(TimeCurrent()-last_time<TimeDelayAlertinSec)
     {
      // delay for 60 seconds
      return(false);
     }
   else
     {
      last_time=TimeCurrent();
      return(true);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void getpip()
  {
   if(Digits==2 || Digits==4)
     {
      pip=Point;
     }
   if(Digits==3 || Digits==5)
     {
      pip = 10*Point;
     }
   if(Digits==6)
     {
      pip = 100*Point;
     }
  }
//+------------------------------------------------------------------+
//|                       Money Management                           |
//+------------------------------------------------------------------+
//Only suitable for Forex (major, minor and exortic pair)...
//GetLots() calculation not not supported for metals and CFD/USDX/Oil
double GetLots()
  {
   double MM_lots=0;
   Credit=AccountCredit();
   Balance=AccountBalance();
   double MM_minlot = MarketInfo(Symbol(), MODE_MINLOT);
   double MM_maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
   double MM_leverage= AccountLeverage();
   double MM_lotsize = MarketInfo(Symbol(),MODE_LOTSIZE);
   double MM_stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
   double xecn=1;
   if(Digits==5 || Digits==3)
     {
      xecn=10;
     }
//+------------------------------------------------------------------+
//Percentage Lots but Lot fixed with balance and only decrease/increase if balance changed
   MM_lots=NormalizeDouble(((Balance+Credit)*MM_leverage*MM_Risk_Percent_Lots*Point*xecn*100/(Ask*MM_lotsize*MM_minlot)*MM_minlot),2);
   if(MM_lots < MM_minlot)
      MM_lots = MM_minlot;
   if(MM_lots > MM_maxlot)
      MM_lots = MM_maxlot;
   if(AccountFreeMargin()<Ask*MM_lots*MM_lotsize/MM_leverage)
     {
      Print("We have no money. Lots = ",MM_lots," , Free Margin = ",AccountFreeMargin());
      Comment("We have no money. Lots = ",MM_lots," , Free Margin = ",AccountFreeMargin());
     }
   return(MM_lots);
  }
//+------------------------------------------------------------------+
