_Period Not Updating

 

Friends,

I am experiencing a bit of a frustrating problem... probably simple but any advice appreciated.

When running my custom indicator, the default window period (when the chart pops up) is always 1 hour.  I change it within my OnInit function as follows:

int OnInit()
   {
      // Set the chart period
      ChartSetSymbolPeriod(0,NULL,PERIOD_M1);   // <====== Set chart period here - default to 1 minute
   
      //--- Get the handle for alligator indicator
      gator_handle = iAlligator(_Symbol,PERIOD_CURRENT,jaw_period,jaw_shift,teeth_period,teeth_shift,lips_period,lips_shift,MODE_EMA,PRICE_CLOSE);
      
      //--- What if handle returns Invalid Handle
      if(gator_handle<0 || gator_handle<0)
      {
         Alert("Error Creating Handles for indicators - error: ",GetLastError(),"!");
      }
      
      AddIndicator(gator_handle,_Symbol,PERIOD_CURRENT);
      
   //---
   return(INIT_SUCCEEDED);
   }

However, from that point on, even after the current chart updates to the new period (1 minute), _Period persists as showing as 1 hour, no matter what, even after the ChartSetSymbolPeriod call.  This is problematic when adding indicators to my chart and avoiding Error 4114.  

1.  What am I missing?  How do I get the _Period to reflect the current chart?

2. How do I change the default chart period from the 1 hour?  I cannot locate the setting that accomplishes this.  


Thanks in advance.

 
ABingaman:

Friends,

I am experiencing a bit of a frustrating problem... probably simple but any advice appreciated.

When running my custom indicator, the default window period (when the chart pops up) is always 1 hour.  I change it within my OnInit function as follows:

However, from that point on, even after the current chart updates to the new period (1 minute), _Period persists as showing as 1 hour, no matter what, even after the ChartSetSymbolPeriod call.  This is problematic when adding indicators to my chart and avoiding Error 4114.  

1.  What am I missing?  How do I get the _Period to reflect the current chart?

2. How do I change the default chart period from the 1 hour?  I cannot locate the setting that accomplishes this.  


Thanks in advance.

How are you getting the value of _Period ?

For M1 chart, _Period is 1

For H1 chart, _Period is 16385

Set up a chart as you like with the time-frame as you want for default. Save the template and name it default.

 

Thanks for the response.  I am looking at the _Period in my Debug window.  Before OnInit ever runs, it loads up the 1H chart, and _Period is perpetually 16385.  This occurs after loading my default chart of 1M.

My steps:

1.  Close all charts.  Load default chart, whose period is set to 1M.

2.  Start debug on realtime data

3.  1H chart pops up/loads up on over top of the 1M default chart and in debug window: _Period = PERIOD_1H (16385).  It stays that way for the remainder, even after I let the OnInit run.  


What am I missing?  Thanks.

 
ABingaman :

Thanks for the response.  I am looking at the _Period in my Debug window.  Before OnInit ever runs, it loads up the 1H chart, and _Period is perpetually 16385.  This occurs after loading my default chart of 1M.

My steps:

1.  Close all charts.  Load default chart, whose period is set to 1M.

2.  Start debug on realtime data

3.  1H chart pops up/loads up on over top of the 1M default chart and in debug window: _Period = PERIOD_1H (16385).  It stays that way for the remainder, even after I let the OnInit run.  


What am I missing?  Thanks.

If you enable debugging, you must configure the chart period and symbol:

 
ABingaman:

What am I missing?  Thanks.

I never use debug mode so I cannot comment.

 
Vladimir Karputov:

If you enable debugging, you must configure the chart period and symbol:

Vladimir,

That is exactly what I was missing.  Not sure how I missed that before, but problem solved!  Thank you very much for your assistance.  

Thank you as well, Keith.

You guys rock.