ADX(14 day ago) ?

 

Hello,

Can somebody indicate me how is it possible to get an array with ADX(14 days ago) for all the bars of current chart (MQL4) ?

Thank you very much in advance !

Eric

 

You can use this :

int DayAgo = 14; // 14 Days ago
int ADXPeriod  = 14;
double ADXValue14Ago = iADX(Symbol(),PERIOD_D1,ADXPeriod,PRICE_CLOSE,MODE_MAIN,DayAgo);
 
Biantoro Kunarto:

You can use this :

int DayAgo = 14; // 14 Days ago
int ADXPeriod  = 14;
double ADXValue14Ago = iADX(Symbol(),PERIOD_D1,ADXPeriod,PRICE_CLOSE,MODE_MAIN,DayAgo);
How about ADX(dynamic) = changes with conditions that apply?
 
Biantoro Kunarto:

You can use this :

int DayAgo = 14; // 14 Days ago
int ADXPeriod  = 14;
double ADXValue14Ago = iADX(Symbol(),PERIOD_D1,ADXPeriod,PRICE_CLOSE,MODE_MAIN,DayAgo);

Thank you very much Biantoro,


Ok, I suppose this for the last bar of the current chart. For all the current chart I think the formula will be :


for (int i=Bars-1;i>=0;i--)

{

adx[i]=iADX(Symbol(),PERIOD_D1,ADXPeriod,PRICE_CLOSE,MODE_MAIN,i-14);

}

Is it right ?


But now, if I want the formula is applicable for all the timeframe :

How to write this formula ?

int 4HourAgo = ?

int HourAgo = ?

int 5MinuteAgo = ?

int MinuteAGo = ?

->

for (int i=Bars-1;i>=0;i--)

{

adx[i]=iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,i-???);

}  ?


Thank you  for your help and best regards,


Eric

 
Eric Tschumi:

Thank you very much Biantoro,


Ok, I suppose this for the last bar of the current chart. For all the current chart I think the formula will be :


for (int i=Bars-1;i>=0;i--)

{

adx[i]=iADX(Symbol(),PERIOD_D1,ADXPeriod,PRICE_CLOSE,MODE_MAIN,i-14);

}

Is it right ?


But now, if I want the formula is applicable for all the timeframe :

How to write this formula ?

int 4HourAgo = ?

int HourAgo = ?

int 5MinuteAgo = ?

int MinuteAGo = ?

->

for (int i=Bars-1;i>=0;i--)

{

adx[i]=iADX(Symbol(),0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,i-???);

}  ?


Thank you  for your help and best regards,


Eric

Yes, that would be the correct formula

For the rest : use this general formula

adx[i]=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,iBarShift(NULL,0,Time[i]-timeDifferenceInMinutes*60));

and (in that format) it will try to find the first bar with that desired time (approximations will happen if the exact time does not match) and return the value of adx for that bar

 
Mladen Rakic:

Yes, that would be the correct formula

For the rest : use this general formula

adx[i]=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MAIN,iBarShift(NULL,0,Time[i]-timeDifferenceInMinutes*60));

and (in that format) it will try to find the first bar with that desired time (approximations will happen if the exact time does not match) and return the value of adx for that bar

Everything is clear now ! thank you very much, Mladen !
 

hello everybody,

i want to change my adx too, where do i go to put this code ?

thanks a lot. 

 
squalle:

hello everybody,

i want to change my adx too, where do i go to put this code ?

thanks a lot. 

You have to have a custom indicator for that

You can not change the built in indicators