Read Indicator value in other time frames than the current time frame

 

 Hi friends,

   When I read an indicator value in a time frame other than the chart current time frame I get wrong values! Is there any consideration to follow to avoid this problem?

 Thanks,

 Shahram

 
eshahas:

 Hi friends,

   When I read an indicator value in a time frame other than the chart current time frame I get wrong values! Is there any consideration to follow to avoid this problem?

 Thanks,

 Shahram

you need to post your code so that we can look at what you are doing... otherwise there is no information to go on.

 
Just to add that I have faced this problem within Strategy Tester...
 
Paul Anscombe:

you need to post your code so that we can look at what you are doing... otherwise there is no information to go on.

For instance assuming my current time frame is on 5 min within strategy tester I try to read Bollinger Band on 15 min and I use below code:


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

                  _iBands_Lower[i] = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_LOWER,i);              

                  _iBands_Upper[i] = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_UPPER,i);              


                  Print(" Lower = ", _iBands_Lower[i], "  Upper", _iBands_Upper[i]);

             }  


  while I get wrong values when I compare them with Bollinger Band 15 min values.
 
eshahas:

Your code appears to be for mql4 but you have not posted in the MQL4 and Metatrader 4 section.

If you are referring to mql4, then please confirm and I will move this topic to the correct section.

If your code is supposed to be mql5, then please read the documentation.

 
That is correct, my code is on MQL4! Sorry for posting in wrong section.
 
eshahas:
That is correct, my code is on MQL4! Sorry for posting in wrong section.

Then Paul's reply does not apply and I will remove it.

Please post in the correct section in future.

 
Noted, thanks for clarification.
 
  1. Post in the correct place.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3.              for(int i=1; i<=4; i++) {
                      _iBands_Lower[i] = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_LOWER,i);
                      _iBands_Upper[i] = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_UPPER,i);              
    You are mixing apples and oranges.

  4. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

 
eshahas:

I have deleted your other topic which is also about different timeframes.

Don't duplicate topics.

 
Any answer on this please!
Reason: