Need Help with imomentum

 

Hello,

I am trying to calculate the HIGEST and LOWEST imomentum value over a set period on a given timeframe.

For example how do I get the higest imomentum value that was reached on EUR/USD on the 1 hour time frame over the last 50 bars.

Any help would be much appreciated.

Thanks,

Knewday

 
5577:

Hello,

I am trying to calculate the HIGEST and LOWEST imomentum value over a set period on a given timeframe.

For example how do I get the higest imomentum value that was reached on EUR/USD on the 1 hour time frame over the last 50 bars.

Any help would be much appreciated.

Thanks,

Knewday

Hi,

Have a look to hose instructions : iHighest and iHigh.

Then you can get to something like : HighestHigh = iHigh("EURUSD",PERIOD_H1,iHighest("EURUSD",PERIOD_H1,MODE_HIGH,50,0));

Hope that's help, I'm not sure of the word 'imomentum'.

 
Jacques366 wrote >>

Hi,

Have a look to hose instructions : iHighest and iHigh.

Then you can get to something like : HighestHigh = iHigh("EURUSD",PERIOD_H1,iHighest("EURUSD",PERIOD_H1,MODE_HIGH,50,0));

Hope that's help, I'm not sure of the word 'imomentum'.

Hi Jacques366,

Thanks for the suggestion but that's not what I'm after. I am working with the Momentum Indicator. That is where imomentum comes from.

Any other suggestions would be much appreciated.

Thanks,

Knewday

 
5577:

Hi Jacques366,

Thanks for the suggestion but that's not what I'm after. I am working with the Momentum Indicator. That is where imomentum comes from.

Any other suggestions would be much appreciated.

Thanks,

Knewday

Oh ok. So may be something like this will be of better help:

double HighestM = 0, LowestM = 0;
for(int shift = 1; shift <= 50; shift++) 
   {double M = iMometum(currency,...your parameters with PERIOD_H1 for the 50 bars...,shift);
    if (HighestM = 0)    
       {HighestM = M;
        LowestM  = M;
        continue;
       }
    if (M > HighestM)
       HighestM = M;
    if (M < LowestM)
       LowestM = M;
   }
LowestM: the lowest value of the indicator for the last 50 bars on H1.
HighestM: the Highest.
 
Jacques366 wrote >>

Oh ok. So may be something like this will be of better help:

Thanks again Jacques,

We are getting close but my code is still not displaying thecorrect values on the chart (see code below)

//--------------------------------------------------------------------
// Momentum_Val.mq4
//--------------------------------------------------------------------
int start() // start
{
double HighestM =0, LowestM=0;
for(int shift = 1; shift <= 50; shift++)
{
double M = iMomentum(NULL,0,50,PRICE_CLOSE,0);
if (M > HighestM)
HighestM = M;
Comment("MHigh - ",HighestM," over 50 bars." );// High Comment
if (M < LowestM)
LowestM = M;

Comment("MLow - ",LowestM," over 50 bars." );// LOW Comment
}
return; // Exit
}
//--------------------------------------------------------------------
//LowestM: the lowest value of the indicator for the last 50 bars on H1.
//HighestM: the Highest.

 
5577:

Thanks again Jacques,

We are getting close but my code is still not displaying thecorrect values on the chart (see code below)

//--------------------------------------------------------------------
// Momentum_Val.mq4
//--------------------------------------------------------------------
int start() // start
{
double HighestM =0, LowestM=0;
for(int shift = 1; shift <= 50; shift++)
{
double M = iMomentum(NULL,0,50,PRICE_CLOSE,0);
if (M > HighestM)
HighestM = M;
Comment("MHigh - ",HighestM," over 50 bars." );// High Comment
if (M < LowestM)
LowestM = M;

Comment("MLow - ",LowestM," over 50 bars." );// LOW Comment
}
return; // Exit
}
//--------------------------------------------------------------------
//LowestM: the lowest value of the indicator for the last 50 bars on H1.
//HighestM: the Highest.

You have the correct values at the end of the loop (outsite the { ... } of the 'for' loop ( '{' are delimiters), because, in fact, this loop is setting the values. Soooo sorry not to have explained.

Just use your 2 Comment commands after the loop and it should be ok. (be careful the second comment command may erase the comment left by the first one as it is coded)

double HighestM = 0, LowestM = 0;
for(int shift = 1; shift <= 50; shift++) 
   {double M = iMometum(currency,...your parameters with PERIOD_H1 for the 50 bars...,shift);
    if (HighestM = 0)    
       {HighestM = M;
        LowestM  = M;
        continue;
       }
    if (M > HighestM)
       HighestM = M;
    if (M < LowestM)
       LowestM = M;
   }
Comment("MLow: ",LowestM,"   MHigh: ",HighestM,"  over 50 bars." );
 
Jacques366 wrote >>

You have the correct values at the end of the loop (outsite the { ... } of the 'for' loop ( '{' are delimiters), because, in fact, this loop is setting the values. Soooo sorry not to have explained.

Just use your 2 Comment commands after the loop and it should be ok. (be careful the second comment command may erase the comment left by the first one as it is coded)

Thanks again. I'm getting errors upon compiling. I have attached the File so you can test it. I really appreciate your help.

Files:
 
5577:

Thanks again. I'm getting errors upon compiling. I have attached the File so you can test it. I really appreciate your help.

double HighestM = 0, LowestM = 0;
for(int shift = 1; shift <= 50; shift++) 
   {double M = iMomentum(NULL,0,50,PRICE_CLOSE,0);
    if (HighestM == 0) 
       {HighestM = M;
        LowestM  = M;
        continue;
       }
    if (M > HighestM)
       HighestM = M;
    if (M < LowestM)
       LowestM = M;
   }
Comment("MLow: ",LowestM,"   MHigh: ",HighestM,"  over 50 bars."); 

 //--------------------------------------------------------------------
//LowestM: the lowest value of the indicator for the last 50 bars on H1.
//HighestM: the Highest.
 
Jacques366 wrote >>

Your loop always read same value of iMomentum.

Change:

double M = iMomentum(NULL,0,50,PRICE_CLOSE,0);

to:

double M = iMomentum(NULL,0,50,PRICE_CLOSE,shift);
and "50" to "period of momentum".
 
rafaell:

Your loop always read same value of iMomentum.

Change:

to:

and "50" to "period of momentum".

Yes that's right rafaell. Thanks.

5577 ??? What did happen?

 
Jacques366 wrote >>

Yes that's right rafaell. Thanks.

5577 ??? What did happen?

I don't know what I'm doing wrong. It is still not working. Both High and low now give the same value. I have attached the EA so you can test it on your chart.

Files:
Reason: