- www.mql5.com
I have created a news trading EA but when submitting it to the market approval and moderation, the automatic approval system says it has errors when it does not. It says it places no trades, whereas it does place trades the settings need to be for a specific time and date. Please can someone suggest how to resolve this so that the EA can be submitted for moderation.
Thanks!
Hello,
you can to add a part of code, up in the OnTick() function, to make some trades on tester.
Like that...
//--------------------------------------------------------------------- //Pass tester to approval product int OpenedOrders=0; int iSendOrder1=0; int iSendOrder2=0; bool iCloseOrder1=false; bool iCloseOrder2=false; double Profit1=0; double Profit2=0; double OrdersTakeProfit=10; double OrdersStopLoss=10; double LotsSize=NormalizeDouble(0.01,2); //--------------------------------------------------------------------- if((IsTesting())||(IsVisualMode())||(IsOptimization())) { if(OrdersTotal()>0) { for(i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS)==true) { if(OrderMagicNumber()==123321) { OpenedOrders++; if(OrderType()==OP_BUY) { Profit1=OrderProfit()+OrderCommission()+OrderSwap(); if((Profit1>=(OrderLots()*OrdersTakeProfit)*MarketInfo(Symbol(),MODE_TICKVALUE)*10)||(Profit1<=-((OrderLots()*OrdersStopLoss)*MarketInfo(Symbol(),MODE_TICKVALUE)*10))) { iCloseOrder1=OrderClose(OrderTicket(),OrderLots(),Bid,3,clrNONE); } } if(OrderType()==OP_SELL) { Profit2=OrderProfit()+OrderCommission()+OrderSwap(); if((Profit2>=(OrderLots()*OrdersTakeProfit)*MarketInfo(Symbol(),MODE_TICKVALUE)*10)||(Profit2<=-((OrderLots()*OrdersStopLoss)*MarketInfo(Symbol(),MODE_TICKVALUE)*10))) { iCloseOrder2=OrderClose(OrderTicket(),OrderLots(),Ask,3,clrNONE); } } } } } } else if(Hour()==12) { if((OpenedOrders==0)&&(AccountFreeMarginCheck(Symbol(),OP_BUY,LotsSize)+AccountFreeMarginCheck(Symbol(),OP_SELL,LotsSize)>0)) { iSendOrder1=OrderSend(Symbol(),OP_BUY,LotsSize,Ask,3,0,0,"",123321,0,clrBlue); iSendOrder2=OrderSend(Symbol(),OP_SELL,LotsSize,Bid,3,0,0,"",123321,0,clrRed); } } return; } //+------------------------------------------------------------------+
- www.mql5.com
That code has errors with normalized lot; i can delete it and just put lot, however it also has undefined "i". See screen shot, please resolve "i"
That code has errors with normalized lot; i can delete it and just put lot, however it also has undefined "i". See screen shot, please resolve "i"
Try this.. I make the changes!
void OnTick() { //--------------------------------------------------------------------- //Pass tester to approval product int OpenedOrders=0; int iSendOrder1=0; int iSendOrder2=0; bool iCloseOrder1=false; bool iCloseOrder2=false; double Profit1=0; double Profit2=0; double OrdersTakeProfit=10; double OrdersStopLoss=10; double LotsSize=NormalizeDouble(0.01,2); //--------------------------------------------------------------------- if((IsTesting())||(IsVisualMode())||(IsOptimization())) { if(OrdersTotal()>0) { for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS)==true) { if(OrderMagicNumber()==123321) { OpenedOrders++; if(OrderType()==OP_BUY) { Profit1=OrderProfit()+OrderCommission()+OrderSwap(); if((Profit1>=(OrderLots()*OrdersTakeProfit)*MarketInfo(Symbol(),MODE_TICKVALUE)*10)||(Profit1<=-((OrderLots()*OrdersStopLoss)*MarketInfo(Symbol(),MODE_TICKVALUE)*10))) { iCloseOrder1=OrderClose(OrderTicket(),OrderLots(),Bid,3,clrNONE); } } if(OrderType()==OP_SELL) { Profit2=OrderProfit()+OrderCommission()+OrderSwap(); if((Profit2>=(OrderLots()*OrdersTakeProfit)*MarketInfo(Symbol(),MODE_TICKVALUE)*10)||(Profit2<=-((OrderLots()*OrdersStopLoss)*MarketInfo(Symbol(),MODE_TICKVALUE)*10))) { iCloseOrder2=OrderClose(OrderTicket(),OrderLots(),Ask,3,clrNONE); } } } } } } else if(Hour()==12) { if((OpenedOrders==0)&&(AccountFreeMarginCheck(Symbol(),OP_BUY,LotsSize)+AccountFreeMarginCheck(Symbol(),OP_SELL,LotsSize)>0)) { iSendOrder1=OrderSend(Symbol(),OP_BUY,LotsSize,Ask,3,0,0,"",123321,0,clrBlue); iSendOrder2=OrderSend(Symbol(),OP_SELL,LotsSize,Bid,3,0,0,"",123321,0,clrRed); } } return; } //+------------------------------------------------------------------+ }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have created a news trading EA but when submitting it to the market approval and moderation, the automatic approval system says it has errors when it does not. It says it places no trades, whereas it does place trades the settings need to be for a specific time and date. Please can someone suggest how to resolve this so that the EA can be submitted for moderation.
Thanks!