iMomentum in a loop

 

Hello, I'm new here and trying to develop a simple tool using imomentum.

I am trying to check the Momentum value every candle, using this loop

 

for(int i=1; i <= 10; i++) {

            

         double momentum = iMomentum(NULL,0,14,PRICE_OPEN,0);

         double value = NormalizeDouble(momentum,4);

         Print (value);

         Sleep (60000);

}


But it gives me ten times the same value, even if the indicator is of course changing. In this example I put sleep(60000) because I checked at M1 period.

And the same happens whith RSI or copy/pasting the two command lines with iMomentum function after time pauses, without the loop.


What am I missing?

 
jollyboss: What am I missing?

You are getting the same value each time. The for variable is not used.

 

SOLVED:


I needed to use the function Refreshrates();

because when an agent is working, it copy current datas from the selected graph window to another area, and works on those ones.

Reason: