Download MetaTrader 5

EA is showing warnings on compilation.

To add comments, please log in or register
Parag Pisolkar
49
Parag Pisolkar  

Hi,

I have written an EA in mql 4 based on moving average crossover confirmed by ADX. On comilation, meta editor is giving warnings as shown in figure. However,this EA is working fine in strategy tester on EURUSD 1 hr chart. Can anybody help me to rectify the warnings.

 

Thanks in advance.

 

 

Marco vd Heijden
Moderator
5491
Marco vd Heijden  

you need to check what orderselect and ordersend and orderclose return.

they return a value depending on the outcome of the action and it needs to be checked to see if the action was successful or not.

Osama Shaban
1576
Osama Shaban  

You need to write the OrderSelect() in the form ...

if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)==true)

 Then, all the OrderSelect() warnings disappear but expect more warnings will pop-up like those about OrderModify() and OrderDelete() ...

Just change them to something like ...

bool res = OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,OrderTakeProfit(),0,CLR_NONE);

 And everything will be hopefully, fine :)

Parag Pisolkar
49
Parag Pisolkar  
Osama Shaban:

You need to write the OrderSelect() in the form ...

 Then, all the OrderSelect() warnings disappear but expect more warnings will pop-up like those about OrderModify() and OrderDelete() ...

Just change them to something like ...

 And everything will be hopefully, fine :)

Hi,

All OrderSelect  warnings disappear, but one error is showing. Please advice.

 

bool res = OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);

 

 

Marco vd Heijden
Moderator
5491
Marco vd Heijden  

You cant declare bool res twice;

And if you do not check the return value, many things can go wrong.

JD4
1100
JD4  
Warnings are not usually a problem with the EA.  They are there to let you know something is not quite OK, but not bad enough to cause the EA to not work at all.  Errors are problems, those need to be handled by correcting the programming.  In this case, as Marco said, if you try to define something more than once (a variable being assigned a value is not defining it) it can cause issues. 
To add comments, please log in or register