EA is showing warnings on compilation.

 

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.

 

 

 

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.

 

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 :)

 
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);

 

 

 

You cant declare bool res twice;

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

 
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.