reinit the indicator

 

Hi friends

sometimes my indicator get stuck and need to reinit it to show new arrows, how can i reinit my indicator automatically in sertain amount of peridos? is it possible using system32 dll? or any alternative approach?

 

bool NeedReinit=false;

int OnInit()
   {
   ReInit();
   return(INIT_SUCCEEDED);
   }

void ReInit()
   {
   //reinit code
   }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   {
   if(NeedReinit) ReInit();
   //indicator code  
   return(0);
   }
 
Milad Ahmadpanah:

Hi friends

sometimes my indicator get stuck and need to reinit it to show new arrows, how can i reinit my indicator automatically in sertain amount of peridos? is it possible using system32 dll? or any alternative approach?

https://www.mql5.com/en/docs/chart_operations/chartsetsymbolperiod

Note

The symbol/period change leads to the re-initialization of the Expert Advisor attached to a chart.

The call of ChartSetSymbolPeriod with the same symbol and timeframe can be used to update the chart (similar to the terminal's Refresh command). In its turn, the chart update triggers re-calculation of the indicators attached to it. Thus, you are able to calculate an indicator on the chart even if there are no ticks (e.g., on weekends).


Documentation on MQL5: Chart Operations / ChartSetSymbolPeriod
Documentation on MQL5: Chart Operations / ChartSetSymbolPeriod
  • www.mql5.com
Changes the symbol and period of the specified chart. The function is asynchronous, i.e. it sends the command and does not wait for its execution completion. The command is added to chart messages queue and will be executed after processing of all previous commands. The call of ChartSetSymbolPeriod with the same symbol...
 
But the best way, if you have the code, is to fix your broken indicator. Are you really going to rely on a broken one for trading?
 
William Roeder:
But the best way, if you have the code, is to fix your broken indicator. Are you really going to rely on a broken one for trading?

indicator is mine and coded by myself, when i use iMA with negative shift

iMA(NULL, PERIOD_CURRENT, (int)floor(period/2), -3, MODE_LWMA, 6, i)

like above example, is it repaint?

 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. iMA doesn't repaint, it doesn't "get stuck."
  3. It is your i loop that is the problem. Post all relevant code if you want help.
Reason: