Where is mistake with My_first_EA ???

 

Dear Mr Codes Guru and senior members,

I began to study Coder's guru lessons and download first EA, but whatever I tried I couldnt see any action (no buy no sell order) ,also when I tried it to run strategy expert only H4 timeframe shows a good result.Other timeframes and others parities (such as EURCAD, AUDUSD ...) never gives any result.I mean this Expert Adviser doesnt run at me.At other times frame strategy tester gives some error message for example "Test Generator:unmatched data error (volume limit 781, at 2012.04.11 17:00, exceeded)

I am really in shock (because I try to solve this problem for 2 days) Please help me where is my problem ????

 

Hi enigmaman,

I do not remember this EA as it was long time ago when I was teaching his lessons as well.

As I know, "unmatched data error" - may be - not enough data for testing?

and "volume limit" seems for me - you used too big lot size? or too small for your broker ...

As I know - this EA was an example only.

or is it MaChannel EA?

I am not a coder sorry.

 

Dear newdigital ,thank you for your quick reply,

My_first_EA is a lessons of Codersguru (MQL4 course),it has given as a lecture (to teach how to write an EA, and how to code sequence).If I solve this problem I will try to write my own expert adviser.BUT !!!.......

 

Can you post it here by text (copy - paste) or as mql4 code?

I do not have time now to go to first lessons sorry ...

 

Hi Enigmaman,

Usually when getting that error you need to redownload the history files again, have found sometimes takes more than 1 download to clear that error, also tried to find the Ea you are talking about could you post it please so can take a look and fond if anything wrong, because could possibly need some updating.

 

here is my biggest problem

//+------------------------------------------------------------------+

//| My_First_EA.mq4 |

//| Coders Guru |

//| Forex TSD - forex forum |

//+------------------------------------------------------------------+

#property copyright "Coders Guru"

#property link "https://www.forex-tsd.com"

//---- input parameters

extern double TakeProfit=250.0;

extern double Lots=0.1;

extern double TrailingStop=30.0;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

int Crossed (double line1 , double line2)

{

int last_direction = 0;

int current_direction = 0;

if(line1>line2) current_direction = 1; //up

if(line1<line2) current_direction = 2; //down

if(current_direction != last_direction) //changed

{

last_direction = current_direction;

return (last_direction);

}

else

{

return (0);

}

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

//----

int cnt, ticket, total;

double shortEma, longEma;

if(Bars<100)

{

Print("bars less than 100");

Print("bars:",Bars);

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

shortEma = iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,0);

longEma = iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,0);

int isCrossed = Crossed (shortEma,longEma);

total = OrdersTotal();

if(total < 1)

{

if(isCrossed == 1)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"My EA",12345,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

if(isCrossed == 2)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"My EA",12345,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if(isCrossed == 2)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>0.0001*TrailingStop)

{

if(OrderStopLoss()<Bid-0.0001*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

if(isCrossed == 1)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(0.0001*TrailingStop))

{

if((OrderStopLoss()>(Ask+0.0001*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

//+------------------------------------------------------------------+

 

Hi Enigmaman,

This version of the Ea should work made it to work for extra digit brokers.And if back testing you will need to down load data from time frame you are testing along with 1 minute data.

Files:
 

Mrtools thank you very for you EA sent me ,I downloaded it tried in strategy tester but I got same error mistake report,Mrtools beside this problem (to see performance of EA) this EA (My_first_EA) doesnt be active even if I tried almost all parities (EURUSD,EURCAD,EURCHF,...) I carefully scanned all sets (EA active,allow live position,...)

Shortly I am in a labirent by the way I also sorrymy poor english but I thin you understand what I mean

Best regards

 

yes mrtool my account is at alpari and alpari use 5 digits.BUT these EAs never run.IM sure there is mistake but where because when compile there is no error

 

...

enigmaman

Here are , as an example, result for 1 day EURCAD (statements with the orders taken by the EA)

As you can see it works. Just make sure that you have EURCAD data downloaded (or data for any other symbol you want to test)

enigmaman:
yes mrtool my account is at alpari and alpari use 5 digits.BUT these EAs never run.IM sure there is mistake but where because when compile there is no error
Files:
title.gif  52 kb
myfirst.zip  11 kb
 

Hi enigmaman,

many members asked same question which you asked, and that is why I created some thread long time ago:

How to prepare metatrader for trading

I mean - if we want to use EA so we should make some preparation for that.

read this small thread

How to prepare metatrader for trading - read this thread.

It will help with any EA.

Reason: