Trade Strategy Evaluation

I’ve been mind-sketching an experimental EA for a few weeks now.
i’m currently working on some sort of intelligence and learning abilities of the EA.
so that it gets better and better on each trade it makes and each signal it finds.
have done similar programs in other languages but MQL is still kinda strange to my mind. (as you need to know other things beside your algorithm and code skills)
since i think MT4 is gonna be forced to get abandoned, gonna use MQL5 for my EA.

So far have these questions , please suggest ideas on the following problems :

  1. The EA acts on new bar formation, but my part of calculations is for the last 5 bars only. (when a new bar #0 is opened, EA works on bar #1, #2, … , #5)
    to make this easier to code, I think using an array of five elements is ok, which stores the OHLC data of the last five bars. (like this : double TheBarsData[5][4] )
    and each time a new bar is closed, the array elements get shifted one index, and the data for oldest bar is lost. (since it’s not needed anymore)
    Is there a better (faster?) way to do this ? is the array an unnecessary addition ?
  2. since the EA considers it’s past trades info (overall win/lose rate, reliability factor for each signal type, trade success rates per week day etc.) to learn from it’s mistakes,
    it needs to save data other than RAM variables. a reliable permanent-ish storage. that’s either Terminal Global Variables, or File.
    which one do yo suggest to use for this purpose ? (or probably there’s other ways i’m not aware of)
  3. is it really better to write in MQL5 ? or MQL4 can still be a good candidate ?
    considering it’s gonna be a multi-K lined program, and re-writing from lang to lang is a pain in tha ass, if you it were you, which language do you code in ?


Your project seems very interesting.

Self learning experts are precious, it avoid repetitive re-synchronization with markets conditions - there’s no standard method to conceive it, each one doing it its own way.

First, about the OHLC datas, arrays are kinda a must, since unavoidable when grabbing these datas …

int  CopyHigh( 
   string           symbol_name,      // symbol name 
   ENUM_TIMEFRAMES  timeframe,        // period 
   int              start_pos,        // start position 
   int              count,            // data count to copy 
   double           high_array[]      // target array to copy 

This method suits MQL4 and MQL5. There is other where arrays aren’t used like :

iHigh, iLow, iOpen, iClose

… but this method suits only MQL4.

Second, for the safety of your stats, I recommend files since global variable expires after 1 month - plus it may stress your server’s cpu/mem - depending on how you’ll collect & analyze all past trades infos.

Finally, if you’re just starting, start directly with MQL5.

  1. You can’t avoid arrays (of course you can by using BarData1, BarData2… but it is nonsense). I would think of using one dimensional arrays (OpenData[5], HighData[5]…) instead of BarsData[5][4] because then you just use on opening a new bar something like this:
   int copied=CopyOpen(symbol,timeframe,1,5,OpenData);
   if(copied!=5) printf("Error: %d",_LastError);
   int copied=CopyHigh(symbol,timeframe,1,5,HighData);
   if(copied!=5) printf("Error: %d",_LastError);
   int copied=CopyLow(symbol,timeframe,1,5,LowData);
   if(copied!=5) printf("Error: %d",_LastError);
   int copied=CopyClose(symbol,timeframe,1,5,CloseData);
   if(copied!=5) printf("Error: %d",_LastError);
  1. Definitely the file.

  2. It depends on your broker. But MQL5 has a future. You can write code that is compatible both with MQL5 and MQL4. Except trading functions it usually isn’t a problem with it.

Thanks, actually when reading Michelina De Banke’s reply just leaned toward your idea of using multiple arrays.

Hmmm… Interesting…