How to make the MT4 auto refresh itself? - page 3

 
fxewen:
Some of the indicators repaint and always need to refresh to get the result. How to make the MT4 auto refresh itself?

Try this indicator That I created, just load it on the graphic choose how often you want it to reaload M1 or H4 or D1   and save that new template with thename "My_Template".

good luck


<*.ex* file has been removed>

 
forextrader1313 #:

if you want an indicator or EA to reload a template, add this code lines to your indicator or EA code.

add this 2 lines of code to your code on top of the code where the functions are

//**********************Put this 2 lines on top of the code*********************************************//
extern   string            TemplateName               = "My_Template";          //Template File Name
extern   ENUM_TIMEFRAMES   TemplateLoadTime           = PERIOD_M1;   //Template Load Time
//******************************************************************************************************//

the add theses lines on void OnDeInit

//******************************Put this at the End of int OnInit ()********************//
void OnDeinit(const int reason)
{
// ObjectsDeleteAll();
 ChartRedraw();
}
//*------------------------------------------------------------------*
bool NewBar(int tf=PERIOD_CURRENT)
{
   static datetime BarsRef = iTime(_Symbol, tf, 0); //pass first time or set it to 0
   
   if( BarsRef == 0 || BarsRef < iTime(_Symbol, tf, 0))
   {
      BarsRef = iTime(_Symbol, tf, 0);
      return (true);
   }
   return(false);
}
//****************************************************************************************//

then add these lines on int OnCalculate for indicators or on void Ontick for EAs.

//***********************Put this on int OnCalculate( for indicators) or on void OnTick () (For EAs) *******************************************//      
          if(NewBar(TemplateLoadTime))
   {
      
      if(StringLen(TemplateName)>1)
      {
         Print("Change template result: ",ChartApplyTemplate(0,TemplateName));
      }
   }
 //**********************************************************************************************************************************************//

you are done you have your indicator or EA reloading every M1 to NM new bar you choose..

just make sure you have the indicador reloader loaded on Graphic before save the template with the name "My_Template ".

good luck


<ex4 file deleted>

what do you exactly insert or add if there is no void OnDeInit and int OnCalculate sections?