why getting a volume repeats itself

 

I encountered with this error in pretty complex scripts. In some scripts it worked okay, but in the some scripts even the simple one like this one, it just repeats itself. Same volume is shown constantly. 

//+------------------------------------------------------------------+

//|                                                   Miracle0.8.mq4 |

//|                        Copyright 2016, MetaQuotes Software Corp. |

//|                                             https://www.mql4.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2016, MetaQuotes Software Corp."

#property link      "https://www.mql4.com"

#property version   "1.00"

#property strict

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+


extern   string indName = "Miracle77.0";

             

//+----------------------------------------------------------------------------------------------+

//| expert initialization function                                                               |

//+----------------------------------------------------------------------------------------------+

int OnInit()

   Print("Starting");

   

   return INIT_SUCCEEDED;   

}


//+----------------------------------------------------------------------------------------------+

//| expert start function                                                                        |

//+----------------------------------------------------------------------------------------------+

int start()

{  

   int k = 1;

   while(k != -1){

      

      Sleep(1000);

      checkIfToAdd();

   }

   return 0;

}



void checkIfToAdd(){

   //Print("Check if come over here");

    Print("Volume " + DoubleToStr(iVolume("NZDJPY.I", PERIOD_M1,0)) + " for " + "NZDJPY.I");               

}

 

 And the results is:

2016.03.30 00:48:19.487 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:18.484 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:17.481 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:16.479 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:15.477 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:14.474 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:13.470 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:12.466 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:11.465 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:10.461 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:09.458 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:08.456 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:07.453 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:06.450 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:05.447 Miracle 0 AUDUSD.I,H1: Volume 44.00000000 for NZDJPY.I

2016.03.30 00:48:04.442 Miracle 0 AUDUSD.I,H1: initialized

2016.03.30 00:48:04.442 Miracle 0 AUDUSD.I,H1: Starting


 
I tried with giving a variable and using extern variable. I tried to make it wait like 10 seconds after each request. Same thing. 
 
jkmaks:
I tried with giving a variable and using extern variable. I tried to make it wait like 10 seconds after each request. Same thing. 
You should issue RefreshRates() after the Sleep(), but anyway, this is not quite the best design how to use the EA.
 
 
Thank you very much!!
Reason: