why getting a volume repeats itself

Back to topics list To post a new topic, please log in or register
avatar
11
jkmaks 2016.03.30 09:49
 

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


avatar
11
jkmaks 2016.03.30 09:52 #
 
I tried with giving a variable and using extern variable. I tried to make it wait like 10 seconds after each request. Same thing. 
avatar
1109
Ovo 2016.03.30 10:52 #
 
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.
avatar
12988
WHRoeder 2016.03.30 14:23 #
 
avatar
11
jkmaks 2016.03.30 16:43 #
 
Thank you very much!!
Back to topics list  

To add comments, please log in or register