Can someone test my code and provide me his feedback (EURUSD)

 

Hello

I'm new on MQL4 programming langage and i need your help to do backtesting on my new code and give me advise on how to do it better or if the simulation is very relevant of the reality :

The parameters i use for my backtest :

Lots=10 EntryLimit=45 EntryStop=9 Stop=45 Limit=40 MACDOpenLevel=3 MACDCloseLevel=2 MATrendPeriod=26

Period : 1H

Currency : EURUSD

here is the code :

//+------------------------------------------------------------------+
//|                                                    Test n°26.mq4 |
//|                                                            Dentz |
//|                                        https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Dentz"
#property link      "https://www.metaquotes.net"

//--- input parameters

extern double    Lots = 10;
extern double    EntryLimit = 45;
extern double    EntryStop = 9;
extern double    Stop = 45;
extern double    Limit = 40;
extern double MACDOpenLevel=3;
extern double MACDCloseLevel=2;
extern double MATrendPeriod=26;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   //----
double MacdCurrent, MacdPrevious, SignalCurrent;

double SignalPrevious, MaCurrent, MaPrevious;

MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);

MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);

SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);

SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);

MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);

MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);


int cnt, ticket, total;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}

total=OrdersTotal();

if(total<1) {
   if(AccountFreeMargin()<(10*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}
   
   }
   
if(iClose("EURUSD",PERIOD_H1,1)>iClose("EURUSD",PERIOD_H1,2) && iClose("EURUSD",PERIOD_H1,2)>iClose("EURUSD",PERIOD_H1,3) && MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MathAbs(MacdCurrent)<(MACDOpenLevel*Point) && MaCurrent<MaPrevious && OrdersTotal()<5)
{
Print("Coucou");
//Lots=MathRound(AccountBalance()/2500); 
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Limit*Point,Bid-Stop*Point,"My order #2",16384,0,Green); 
//ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stop*Point,Ask+Limit*Point,"My order #2",16384,0,Green); 
}
//----
   return(0);
  }
//+------------------------------------------------------------------+

The backtesting work but the modeling quality is N/A, if you can help me about this i will enjoy it a lot,

Thank you.

Files:
testfn26.mq4  3 kb
 

We'll help you code, and maybe even advise you on how to backtest.

As to how to do better .... I'm too busy trying to make my own strategies profitable!

You can get the strategy tester to change some of the settings & work out the best setting, but this should be 'used with care'. Best idea (well, one I would recommend) is to work out 'best settings' with one set of data (say one lot of 6 months) & then try those settings on ANOTHER set of data (say, ANOTHER set of 6 months). Of course, the market may have changed, but be careful of over-optimising your strategy - otherwise you can get a "$1000 to $1M in 6 months" results that just will not work in real life. I can give you the best lottery numbers to use for any set of lotteries ... in the past.

Reason: