Page 1 of 1
Year calculation in MT4
Posted: Sun Apr 02, 2017 5:55 am
by fxover
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
Posted: Sun Apr 02, 2017 6:17 am
by mladen
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
Posted: Sun Apr 02, 2017 6:27 am
by fxover
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
Re: Year calculation in MT4
Posted: Sun Apr 02, 2017 6:44 am
by mladen
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);
Re: Year calculation in MT4
Posted: Sun Apr 02, 2017 6:46 am
by fxover
thank you so much master
will check it out ...
Re: Year calculation in MT4
Posted: Sun Apr 02, 2017 4:14 pm
by mladen
Happy trading
