Creating an EA for use on Ultimate Renko charts that have been purchased from the MQL5 market is no different from creating an EA for use on standard time based charts.

There is however one small modification that needs to be done to the boilerplate code that is needed in each and every EA you create.


The problem that needs to be dealt with is the fact that all MQL5 Market products have restricted use of DLL calls. However, a few Windows API calls are needed to fire the OnTick() event by the Utimate Renko indicator.

This is where all of the trading decisions and calculations are made by your EA whenever price quotes of the traded asset change. 

Without DLL calls the Ultimate Renko indicator cannot cause the OnTick() event to trigger on "offline charts" and your EA will simply not do anything.


Fortunately there is an easy workaround via use of the OnTimer() event. Below is a commented EA skeleton example that is capable of running directly on the offline chart. Please make sure you read all of the comments in the code.


#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   // You need to initialize a time to call the OnTimer event.
   // It is used to call OnTick whenever the Bid price changes.
   // The check is made every 250 ms, which should be sufficient.
   
   EventSetMillisecondTimer(250);
      
   //---
   
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   // Remember to destroy timer in the OnDeinit event.
   
   EventKillTimer();

   //---      
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   //
   // This is where all of your EA trading logic resides.
   // I just write to the log in this example...
   //
   
   Print("OnTick function call - bid = "+(string)Bid);
}
//+------------------------------------------------------------------+
//| The OnTimer function is used to call OnTick()                    |
//| whenever the Bid price changes.                                  |
//+------------------------------------------------------------------+
void OnTimer()
{
   RefreshRates();
   static double prevBid = 0; 
   
   if(Bid != prevBid)
   {
      prevBid = Bid;
      OnTick();
   }         
}
//+------------------------------------------------------------------+