How to trigger EA's OnTick() or Start() on offline chart?

To add comments, please log in or register
cjtylor
71
cjtylor  

Hi, everyone - happy new year!

Is it possible to trigger the OnTick() or Start() function of a EA  - if I put this EA on an offline chart?

Seems it will not trigger.

Is there any workaround that can make it trigger OnTick() / Start()?

 

Thanks a lot!

SearchSurf
709
SearchSurf  
cjtylor:

Hi, everyone - happy new year!

Is it possible to trigger the OnTick() or Start() function of a EA  - if I put this EA on an offline chart?

Seems it will not trigger.

Is there any workaround that can make it trigger OnTick()?

 

Thanks a lot! 

 

https://www.mql5.com/en/docs/runtime/running

For what I understand, the execution are all based on event...means that there must be an Event to trigger whatever you want to process on your program.  

Unless you can create your own event that can be used on the terminal, or you can find other Event means that would trigger your codes -- such as instead using Ontick(), I would use OnChartEvent() to process my codes during offline mode. This way any chart based event like by just moving a mouse on chart would trigger to process my program:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,0,1);
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {      
     if(id==CHARTEVENT_MOUSE_MOVE)  
     {      
       Print("Lparm: ",lparam,"Dparm: ",dparam,"StateMouse: ", (uint)sparam);  
       // Place your codes here...
  
     }  
  }

 

... and for script on Start()... why not just create a certain controlled loop to continuously process whatever you want your program do. 

  

Documentation on MQL5: MQL5 programs / Program Running
Documentation on MQL5: MQL5 programs / Program Running
  • www.mql5.com
MQL5 programs / Program Running - Reference on algorithmic/automated trading language for MetaTrader 5
Trinh Dat
45672
Trinh Dat  

use Start() or  OnTimer()

with RefreshRates() to get new data

cjtylor
71
cjtylor  

thanks for your replies - does that mean offline chart CAN trigger Start() but not onTick()?

To add comments, please log in or register