QuestionYear calculation in MT4

1
Dear Mladen,
just wanna know if it possible to make this code calculate for one year

Code: Select all

int start() {
   if (Period() > PERIOD_D1) {
      Print("Error - Chart period is greater than 1 day.");
      return (-1);
   }
   string Ls_unused_8 = "";
   ArrayCopyRates(Gda_352, Symbol(), PERIOD_D1);
   if (ManualCalculation == FALSE) {
      Gd_96 = Gda_352[1][4];
      Gd_80 = Gda_352[1][3];
      Gd_88 = Gda_352[1][2];


Re: Year calculation in MT4

2
fxover wrote:Dear Mladen,
just wanna know if it possible to make this code calculate for one year

Code: Select all

 int start() { if (Period() > PERIOD_D1) { Print("Error - Chart period is greater than 1 day."); return (-1); } string Ls_unused_8 = ""; ArrayCopyRates(Gda_352, Symbol(), PERIOD_D1); if (ManualCalculation == FALSE) { Gd_96 = Gda_352[1][4]; Gd_80 = Gda_352[1][3]; Gd_88 = Gda_352[1][2]; 

It is possible but you are using bad example (that is decompiled code)
Better to use some clean code and then it can be made to calculate for a year (but that can not be done using the copy rates - the code must be completely customized)

Re: Year calculation in MT4

4
fxover wrote:ok forget the posted code which used to draw support and resistance lines and the max i can put is MN1 ONE month but i need the customized one that calculate for one year please
Here is a code that finds out minimal and maximal price for the current year

Code: Select all

   double ymax=0,ymin=0; MqlRates rates[];
   
      //
      //
      //
      //
      //
      
      int size = ArrayCopyRates(rates,_Symbol, PERIOD_MN1);
      if (size>0)
      {
         ymax=rates[0].high;
         ymin=rates[0].low;
         for (int k=1; k<size && TimeYear(rates[k].time)==TimeYear(TimeCurrent()); k++)
         {
            ymax=MathMax(ymax,rates[k].high);
            ymin=MathMin(ymin,rates[k].low);
         }
      }      
      Comment(ymax,"    ",ymin);               





Who is online

Users browsing this forum: No registered users and 12 guests