EA - iStochastic reading value from multiple time frames

 

Hi everyone,

I am sure I am missing something basic here but after all online search still not sure why this would not work...

I am trying to read iStochastic values from multiple time frames (i.e. M5,M15,H1) and then store them in global variables for later use. I am testing the cose on M5 chart and while it ready properly M5 values I get all 0.0000 returned when trying to read any other time frame (i.e. M15).

Is there a limitation of reading other time frame indicator values from EA or I am missing something basic here?

Thanks in advance...

Here is the code:

//+------------------------------------------------------------------+
//|                                                         Test.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

double g_d_Main_M5;
double g_d_Signal_M5;

double g_d_Main_M15;
double g_d_Signal_M15;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   //----
   double d_Current_Main;
   double d_Current_Signal;
   
   //M5
   Print("M5 TO BE Retrieved");
   d_Current_Main=iStochastic(NULL,PERIOD_M5,8,5,3,MODE_SMA,1,MODE_MAIN,0);
   d_Current_Signal=iStochastic(NULL,PERIOD_M5,8,5,3,MODE_SMA,1,MODE_SIGNAL,0);
   Print("M5 Retrieved");
   Print("d_Current_Main = "+d_Current_Main);
   Print("d_Current_Signal "+d_Current_Signal);
   Print("");
   
   g_d_Main_M5=d_Current_Main;
   g_d_Signal_M5=d_Current_Signal;
   d_Current_Main=0;
   d_Current_Signal=0;
   Print("M5 Print globals");
   Print("g_d_Main_M5 = "+g_d_Main_M5);
   Print("g_d_Signal_M5 "+g_d_Signal_M5);
   Print("****");
   
   
   //M15
   Print("M15 TO BE Retrieved");
   d_Current_Main=iStochastic(NULL,PERIOD_M15,8,5,3,MODE_SMA,1,MODE_MAIN,0);
   d_Current_Signal=iStochastic(NULL,PERIOD_M15,8,5,3,MODE_SMA,1,MODE_SIGNAL,0);
   Print("M15 Retrieved");
   Print("d_Current_Main = "+d_Current_Main);
   Print("d_Current_Signal "+d_Current_Signal);
   Print("");
   
   g_d_Main_M15=d_Current_Main;
   g_d_Signal_M15=d_Current_Signal;
   d_Current_Main=0;
   d_Current_Signal=0;
   Print("M15 Print globals");
   Print("g_d_Main_M15 = "+g_d_Main_M15);
   Print("g_d_Signal_M15 "+g_d_Signal_M15);
   Print("****");
   //----
   return(0);
  }
//+------------------------------------------------------------------+

and here is a screen capture of my execution log:

 
Zoran:

Hi everyone,

I am sure I am missing something basic here but after all online search still not sure why this would not work...

I am trying to read iStochastic values from multiple time frames (i.e. M5,M15,H1) and then store them in global variables for later use. I am testing the cose on M5 chart and while it ready properly M5 values I get all 0.0000 returned when trying to read any other time frame (i.e. M15).

Is there a limitation of reading other time frame indicator values from EA or I am missing something basic here?

Thanks in advance...

Here is the code:

and here is a screen capture of my execution log:

I have tried using the int values for Period but no difference.
 
Zoran: I have tried using the int values for Period but no difference. Of course not
You don't have M15 history for your testing period.
 
WHRoeder:
You don't have M15 history for your testing period.

Thanks a lot for a suggestion but I am getting the same result even when I connect to my demo account and then run the EA.

Also, I looked at the data available for testing on my machine and it seems to be there... or do I need to do something else to make the M15 availabe?

Thanks again...

 
Bump
 
Zoran:

Thanks a lot for a suggestion but I am getting the same result even when I connect to my demo account and then run the EA.

Also, I looked at the data available for testing on my machine and it seems to be there... or do I need to do something else to make the M15 availabe?

Thanks again...

Open a M15 chart for the date in question to make certain that you have the M15 data, check for gaps.
 

Thanks for helping.... As expected it was a "user error"

Just in a case someone else is looking for the same answer in future here are screens and explanations:

1. I looked at the list of data available offline and confirmed that EURUSD is available for both M5 and M15 for Sept 6th 2-13. I have opened both chars offline.

2. I selected proper date, EA, and M5 timeframe and run the backtes.

3. It worked!!!

Thanks again RaptorUK, and WHRoeder

Reason: