Indicator stops firing events after period change by SetSymbolPeriod()

 

I open chart, add custom indicator.

Next I change period by calling SetSymbolPeriod() method.


If the change is for example from PERIOD_M1 to PERIOD_H1 and back to PERIOD_M1 there is no problem.


But if the change is for example from PERIOD_H4 to PERIOD_MN1 and back to PERIOD_H4 indicator stops firing events. Method OnChartEvent() is not called. When I by hand open from Indicator List properties for that custom indicator and only click on OK – indicator starts firing events again (method OnChartEvent() is called).


So the first solution I think would by refresh that indicator. But I don’t know how to do it from code.


Or am I missing something?

Any help will be welcome!

bool CJFSnifferCore::InitViewCharts(void)
  {
   for(int i=0;i<PERIODS_IN_VIEW;i++)
     {
      if(m_view_charts[i].Open(SymbolName(0,true),v_viewOnePeriods[i])==0)
        {
         LOG(LOG_LEVEL_FATAL,"View chart not created");
         return(false);
        }
      
      if((m_hViewIndis[i]=iCustom(SymbolName(0,true),v_viewOnePeriods[i],"joeef\\JFSniffer\\JFView",m_container_chart.ChartId()))==INVALID_HANDLE)
        {
         LOG(LOG_LEVEL_FATAL,"Error initializing JFView object");
         return(false);
        }
      if(!m_view_charts[i].IndicatorAdd(0,m_hViewIndis[i]))
        {
         LOG(LOG_LEVEL_FATAL,"Add an indicator with the specified handle into a specified chart window fails");
         return(false);
        }       
       
      m_view_charts[i].Redraw();       
     }
//--- ok
   return(true); 
  } 
CJFSnifferCore::ManageView(int view,string symbol)
  {  
   int i;
  
   //--- Set View Charts
   ENUM_TIMEFRAMES tf;  
   for(i=0;i<PERIODS_IN_VIEW;i++)
     {
      if(view==2)
        {
         tf=v_viewTwoPeriods[i];
        }
      else
        {
         tf=v_viewOnePeriods[i];
        }

      m_view_charts[i].SetSymbolPeriod(symbol,tf);      
      m_view_charts[i].Redraw();
     }  
  }  
Reason: