Real time multiple chart analysis using EA

 

Hi.

I am creating EA that is built on strategy that requires information from other charts. I wanted to ask what is best solution to start with, because I am pretty new at this.

Example 1.

Create external database and store information there, it means that I have to build 2 EA s. One that collects information from other charts and put that inside db, and

second one do actual information analysis and trades ?

Example 2.

One EA that can can do all this without saving information outside trading platform. There comes new question, is that actually possible to create such EA ?

Thanks, Any advice would be appreciated!

 
edgars.rworks: I am creating EA that is built on strategy that requires information from other charts. I wanted to ask what is best solution to start with,

My suggestion is to use ArrayCopyRates for each other charts (in init) You then have instant access via the arrays, instead of the slower iTime(), iHigh() functions.
   #define ACR_TIME     0  // Array Copy Rates
   #define ACR_OPEN     1
   #define ACR_LOW      2
   #define ACR_HIGH     3
   #define ACR_CLOSE    4
// #define ACR_VOLUME   5
      #define ACR_COUNT    6
double   acr.arr[][ACR_COUNT];                   // Export to NewTrade/Masar
int init(){ ...
   //{https://forum.mql4.com/36470/page2 says ArrayCopyRates is a nonreentrant,
   // non-thread-safe call. Therefor you must put a mutex around the call in
   // case of multiple EAs on multiple charts. Alteratively, since init() is
   // single threaded across all charts, put all ACRs there.
   ArrayCopyRates(acr.arr, market.pair, PERIOD_M1);          // I'm in an OnInit.
}
#define iCB 0  // Current Bar
#define iPB 1  // Previous Bar
datetime GetTime( int iBar=iCB){          return( GetMkt(ACR_TIME,   iBar) ); }
//double GetOpen( int iBar=iCB){          return( GetMkt(ACR_OPEN,   iBar) ); }
double   GetHigh( int iBar=iCB){          return( GetMkt(ACR_HIGH,   iBar) ); }
double   GetLow(  int iBar=iCB){          return( GetMkt(ACR_LOW,    iBar) ); }
double   GetClose(int iBar=iCB){          return( GetMkt(ACR_CLOSE,  iBar) ); }
//double GetVolume(int iBar=iCB){         return( GetMkt(ACR_VOLUME, iBar) ); }
double   acr.arr[][ACR_COUNT];
int      GetBars(){                       return( ArrayRange(acr.arr, 0)   ); }
double   GetMkt(int eACR, int iBar=iCB){  return( acr.arr[iBar][eACR]      ); }
int start(){ ...
   if(m1.acr[iCB][ACR_TIME] == 0.){                         // Verify M1 data.
      int      gle   = GetLastError();
      if (gle != ERR_HISTORY_WILL_UPDATED){  DisableTrading("No M1 history: "
                                          + GetLastError());   return(false); }
      Print("Updating history for M1 chart");                                    // Log("Updating history for M1 chart");
      Sleep(15000);  SetNeedToRefresh();
      if(m1.acr[iCB][ACR_TIME] == 0.){
         DisableTrading("Updating history for Minute chart failed: "
                                          + GetLastError());   return(false); }
      Print("Updating history for Minute chart Succeeded");                      // Log("Updating history for Minute chart Succeeded");
   }  // M1 data
 
WHRoeder:
My suggestion is to use ArrayCopyRates for each other charts (in init) You then have instant access via the arrays, instead of the slower iTime(), iHigh() functions.


But I FOUND some bug in here https://www.mql5.com/en/forum/129734/page2 So that still can work out ?

Or it means that I have to do like suggested in that error topic?

 
edgars.rworks:

But I FOUND some bug in here https://www.mql5.com/en/forum/129734/page2 So that still can work out ?

Or it means that I have to do like suggested in that error topic?

Did you bother to look at my posted code? Where I had a link to that page and where I said
put all ACRs there.
Reason: