Open project - tester-optimiser in-house

 
I have an idea to write my own tester in the form of an indicator. The requirement - with minimal rework the Expert Advisor must be suitable for both standard and self-written testers. This is achieved by adding the prefix my to the standard constants and functions. Optimization is also acceptable.
The template is written, it's necessary to implement trading functions by writing your own functions.
Who is good at it - join us. Trading functions through array manipulation. Also we need an expert in drawing of objects on the chart - use arrows/drawings to represent open, stop and take profit levels.
Also we need to organize the output of order history and numeric series in a file for opening charts in Excel. In general, everything is very serious :)

I have thought of everything in principle, but I am not a universalist.

I can suggest ideas, if someone would like to. Besides, it is possible that self-made variant in some cases of optimization by performance will be able to surpass built one.

//+------------------------------------------------------------------+
//|                                                   SelfTester.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 DarkBlue
#property indicator_color3 LawnGreen
//---- input parameters
extern int       mySpread=4;
extern int       BeginYear=2002;
extern int       BeginMonth=1;
extern int       BeginDay=1;
extern string    ReportName="report";
extern int       Param1=8;
extern int       Param2=13;
extern double    myDepo=10000.0;
extern double    mylots=0.1;
extern int       myTakeProfit=100.0;
extern int       myStopLoss=80.0;
extern int       myTrailingStop=20;
//---- buffers
double myBalance[];
double myEquity[];
double myProfit[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,myBalance);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,myEquity);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,myProfit);
   double TradeOrdersArray[100][14];
   double ClosedOrdersArray[2000][14];
   int myOrdersTotal=0;
   double myOrderOpenPrice=0.0;
   double myOrderLots=0.0; 
   string myOrderComment=""; 
   int myOrderMagicNumber;
   int myOrderOpenTime;
   double myOrderProfit=0.0;
   double myOrderStopLoss=0.0;
   double myOrderTakeProfit=0.0;
   int myOrderTicket;
   int myOrderType; 

   int myOP_BUY=0;
   int myOP_SELL=1;
   int myOP_BUYLIMIT=2;
   int myOP_BUYSTOP=3;
   int myOP_SELLLIMIT=4;
   int myOP_SELLSTOP=5;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+




 
I don't know what kind of gibberish has appeared. If anyone wants it, I'll post it somewhere else on another forum.
 
2 Rosh
I'm not quite sure what you want to say with this preset. In my opinion, you want to get a set of functions that will calculate profit and mark entry/stop points on the chart at the same time? And the decision engine will be different for each of them?

And a couple of tips:
extern int       BeginYear=2002


better to be replaced by

extern string       BeginDate="2002.01.01 18:00"


- it is possible to work immediately with a construction of the type

Time[i] > StrToTime(BeginDate)



Yes and probably things like

double myOrderOpenPrice=0.0;
double myOrderLots=0.0; 


would also be more convenient to store as

#define LOTS 0;
#define OPEN_PRICE 1;

double MyOrder[2] = {0.0, 0.0};
.....................
MyOrder[OPEN_PRICE] = Open[i];
.....................
 


but that's just the little things...

 
Filin, you are out of your depths. Why should you define the constant
?
#define LOTS 0;

This is the input variable for the tester.

Where did this come from?

#define OPEN_PRICE 1;


Have you noticed that all these variables (which might be better defined by functions)

double myOrderOpenPrice=0.0;
double myOrderLots=0.0; 

Are twins of the built in mql-4. I wrote that the goal is for our tester and the embedded tester to understand the
EA with minimal rework.

The decision engine is the EA code. And it will be easily integrated into this EA. And the engine of the tester is functions that I suggest
to "overrid" - i.e. we take the standard built-in function, for example OrderSend(), and using it, write a full similar function - myOrderSend(). And so on.
I will write this function tonight to make it clearer.

You have to be more thorough, more thorough... :)

 
I don't know what kind of gibberish has appeared. If anyone wants it, I'll post it on another forum somewhere.

This appeared not long ago. When transferring text from MQL, the Russian letters appear in this way. The same thing FronPage does with Russian letters.
 
I thought the cursive letters would be converted back to Russian letters when I copied and pasted into the indicator file. It turned out not so. I'll post it on another forum tonight
and I'll post the link.
 
Rosh,
can't you erase the rubbish?
It's impossible to watch.
It must be a glitch of forum, hosting or MT when copying scripts with Russian text.
 
Testing in this way is possible. And it's good enough. But, unfortunately, you won't get universalism.
I have spent a couple of weeks on such tests. At first glance it seems simple. You get a set of standard functions and go.
But this set is nothing but a seed: opening/closing, profit/loss calculation, drawing arrows/dashes.
The main and most important is the algorithm of opening/closing, which, say, has already been described in some Expert Advisor. You cannot drag and drop this algorithm
in its entirety. You can only do it in parts. And then tracking "error-free" of the resulting code... Plus, all sorts of twists and turns associated with this process...
all sorts of tinkering... In short, we end up writing a separate program on the same subject from scratch for the second time. After all that, in 1 second you get
either an unsatisfactory result, or the arrows are in the wrong place, or closing in the wrong places. Then you go back to the program text and try again...
Your brain works instead of a debugger, you turn into a monitor for a while... Eventually, on the third day, the test runs
seems fine, but you become convinced that the strategy is "not good". And at this point, that's pretty much it! Because testing the next strategy in this way
there is no desire at all. Why have I written all this? The idea is appealing. And in principle, it works. But, believe me, it's not something
it's not going to work. If we're talking about a template, it has to be a very fundamental template, i.e. a very decent, well thought-out design. In general,
the programme is not the easiest. And if someone after reading this opus will not break a spear in the framework of the described, ie use this my
If someone uses my little, but nonetheless practical experience and moves on without wasting time, something may work out. Then all those who are suffering
(myself included) will chip in and build a monument to the author. :)
 
OK, I'll make one function in the evening (as promised), everything will be clearer. For now, my opinion is that with a properly designed tester it will be possible to
to use native Expert Advisors with some cosmetic modifications. The first "victim" is MACD_sample.mq4 .
 
Rosh,<br / translate="no"> can't the rubbish be erased?
It's impossible to watch.
It must be a glitch of forum, hosting or MT when copying scripts with Russian text.


"Garbage" was removed. Programmers probably know how boring it is to write (comments) :).

Does anyone know - I have correctly defined these constants based on standard?
  int myOP_BUY=0;
   int myOP_SELL=1;
   int myOP_BUYLIMIT=2;
   int myOP_BUYSTOP=3;
   int myOP_SELLLIMIT=4;
   int myOP_SELLSTOP=5;


Meaning specific values.

 
I'm a dummie, why reinvent the wheel. Let's make it simple:

   int myOP_BUY=OP_BUY;
   int myOP_SELL=OP_SELL;
   int myOP_BUYLIMIT=OP_BUYLIMIT;
   int myOP_BUYSTOP=OP_BUYSTOP;
   int myOP_SELLLIMIT=OP_SELLLIMIT;
   int myOP_SELLSTOP=OP_SELLSTOP;


However, I don't know the compiler's reaction beforehand, will it let the trade constants in the indicator body through or not?
Most likely, it will.

Reason: