- Only places trades in strategy tester
- Why does EA work on strategy tester but not on live acc.?
- ea have no errors trade on live but can not backtest on strategy tester help
if(Close[0]>movingAverage) if(K0 > 80) if(Close[0]<Open[1] && Close[0]>Close[2]) if(OrdersTotal()==0) OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+(StopLoss*Pips),Bid-(TakeProfit*Pips),NULL,MagicNumber,0,Red); Print("OrderSend failed with error #",GetLastError());
Check the return of OrderSend() and print the error.
Like this?
Read the documentation for OrderSend(). It even gives you an example of dealing with errors.
Read the documentation for OrderSend(). It even gives you an example of dealing with errors.
if(Close[0]>Open[1]) if(OrdersTotal()==0) ticket=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*Pips),Ask+(TakeProfit*Pips),NULL,MagicNumber,0,Green); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully"); if(Close[0]<Open[1]) if(OrdersTotal()==0) ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,Bid+(StopLoss*Pips),Bid-(TakeProfit*Pips),NULL,MagicNumber,0,Red); if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully");
I copy and pasted the highlighted piece of code above from one of your comments on another thread, but when I ran the code it just rapidly fired out lots of "OrderSend placed successfully" messages without actually placing any trades. Do you know why this is?
I copy and pasted the highlighted piece of code above from one of your comments on another thread, but when I ran the code it just rapidly fired out lots of "OrderSend placed successfully" messages without actually placing any trades. Do you know why this is?
Yes.
if(Close[0]>Open[1]) if(OrdersTotal()==0) ticket=OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,Ask-(StopLoss*Pips),Ask+(TakeProfit*Pips),NULL,MagicNumber,0,Green); //The following code is completely independent of the above if so will be executed regardless of whether the conditions are met. if(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else Print("OrderSend placed successfully");
You should get into the habit of using the styler as it will often reveal such errors. Unrelated code will not be indented.
I have deleted your other topic as it seems to be related.
Do not double post!
You've been told already....
Yet you posted in the wrong section again!
I have deleted your other topic as it seems to be related.
Do not double post!
You've been told already....
Yet you posted in the wrong section again!
Yes.
You should get into the habit of using the styler as it will often reveal such errors. Unrelated code will not be indented.
- 2012.05.20
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use