Profit in Month

Price Data Components
Series array that contains open time of each bar
0 Views
0 Downloads
0 Favorites
Profit in Month
ÿþ//+------------------------------------------------------------------+

//|                                                      ProjectName |

//|                                      Copyright 2020, CompanyName |

//|                                       http://www.companyname.net |

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



#property script_show_inputs



input datetime From_date = 0;

input datetime To_date = 0;







#include <Trade\\DealInfo.mqh>

CDealInfo deal;





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

//| Script program start function                                    |

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



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

//|                                                                  |

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

double All_Ballance = 0;

double Profit_month = 0;

double Profit_All = 0;

double Total_Dep_Width = 0;



double Bal = 0;

double Dep_width = 0;

bool flag = true;

double MaxProfit = 0;

double All_pr = 0;



datetime from_date  =  From_date;

datetime to_date  =    TimeCurrent();





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

//|                                                                  |

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

void OnStart()

{





   if (To_date > 0) to_date = To_date;



   string stime;

   datetime lastdate = 0;



   HistorySelect(from_date, to_date);

   for (int i = 0; i < HistoryDealsTotal(); i++)

   {

      deal.SelectByIndex(i);



      datetime dealtime = deal.Time();

      MqlDateTime dt;

      TimeToStruct (dealtime, dt);

      if (dt.day >= 1 && dt.day <= 27 && dt.day_of_week > 0 && dt.day_of_week <= 5 && flag && dt.hour >= 12)

      {

         flag = false;



         string slastdate = TimeToString(lastdate);

         stime = TimeToString(dealtime);



         if (MaxProfit < All_pr)

            MaxProfit = All_pr;







         if (i > 0)

         {

            PrintFormat ("c %s 4> %s  0 ?5@8>4:  @81K;L = %.2f  >?>;=5=85/A=OB85  = %.2f   A53>  = %.2f   =0 AG5B5 = %.2f 1I0O @81K;L %.2f", slastdate, stime, Profit_month, Dep_width, All_Ballance, Bal, All_pr);

         }

         All_Ballance  = 0;

         Dep_width = 0;

         lastdate = dealtime;

         Profit_month = 0;

      }



      if (dt.day > 27)

         flag = true;





      if (deal.Symbol() == "")

      {

         Bal += deal.Profit() + deal.Commission() + deal.Swap();

         All_Ballance += deal.Profit() + deal.Commission() + deal.Swap();

         Dep_width += deal.Profit() + deal.Commission() + deal.Swap();

         Total_Dep_Width += deal.Profit() + deal.Commission() + deal.Swap();



         //Print (i, "   ", deal.Time(), "   ", deal.Profit(), "   ", deal.Symbol(), "   ", Bal);

      }

      else

      {



         Bal += deal.Profit() + deal.Commission() + deal.Swap();



         Profit_month += deal.Profit() + deal.Commission() + deal.Swap();

         All_Ballance += deal.Profit() + deal.Commission() + deal.Swap();

         Profit_All += deal.Profit() + deal.Commission() + deal.Swap();

         All_pr += deal.Profit() + deal.Commission() + deal.Swap();



      }





   }



   string slastdate = TimeToString(lastdate);

   stime = TimeToString(TimeCurrent());

   PrintFormat ("c %s 4> %s  0 ?5@8>4:  @81K;L = %.2f  >?>;=5=85/A=OB85  = %.2f   A53>  = %.2f   =0 AG5B5 = %.2f 1I0O @81K;L %.2f", slastdate, stime, Profit_month, Dep_width, All_Ballance, Bal, All_pr);



   // Print (All_pr, "   ", MaxProfit, "  ", MaxProfit - All_pr);

   double dolg = All_pr - MaxProfit;

   PrintFormat ("                    B>3>:  10;0=A = %.2f   @81K;L = %.2f >?>;=5=8O/A=OB8O = %.2f  >E>4/?@>A04:0 = %.2f", Bal, Profit_All, Total_Dep_Width, dolg);







   Print ("********************************************************");

}



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

Comments