Oanda is an ECN Broker, you need to set TP and SL at 0.0 when you do an OrderSend and then do an OrderModify to place the correct SL & TP afterwards . . . . please read some other posts first, you would have seen at least 2 posts about this in the last couple of days.
int digits=MarketInfo("EURUSD",MODE_DIGITS);Also this line has to be changed in this EA if your broker use prefix and/or suffix on currencysymbols
This is what i got so far, But still not working,, its shows me : unknown ticket 28281879 for OrderModify function
and its the correct ID for my open position ..
if((halt1!=1)&&(AllowBuy==true)){// halt1 // Buy criteria if ((TradeHour==Hour())&&(TradeMinutes==Minute())&&(TradeSeconds>=Seconds())) //Signal Buy { int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,0,0,0,"time trader buy order ",0,0,Blue); OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,TakeProfit,0,Blue); if(openbuy<1){int buyfail=1;} } }// halt1
I would appricate alittle help ...
Thanks
Read the Documentation . . . . OrderSend() "Returns number of the ticket assigned to the order by the trade server or -1 if it fails. " so check if openbuy is > 0 if it is use it as the ticket number for your OrderModify . . . if not report the error by printing it to the journal/experts log.
Alternatively if openbuy is > 0 use it in an OrderSelect()
This is what i got so far, But still not working,, its shows me : unknown ticket 28281879 for OrderModify function
and its the correct ID for my open position ..
I would appricate alittle help ...
Thanks
// Buy criteria if ((TradeHour==Hour())&&(TradeMinutes==Minute())&&(TradeSeconds>=Seconds())) //Signal Buy {int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"time trader buy order ",0,0,Blue);} //<== Don't remove Slippage //only slb tpb is enough if(openbuy>0) { if(OrderSelect(openbuy,SELECT_BY_TICKET,MODE_TRADES)) { OrderModify(openbuy,OrderOpenPrice(),slb,tpb,0,Blue); } else Print("Error opening new order : ",GetLastError()); if(openbuy<1){int buyfail=1;} }
not checked
You need to change into...
int digits=MarketInfo(Symbol(),MODE_DIGITS);
Than add this line...
if(digits<4)double Pnt=0.01; else Pnt=0.0001;
Than everywhere where there is StopMultd or Point replace with Pnt. Than everywhere where OrderSend(.... there are slb,tpb, or sls,tps, replace with 0,0,.
Than add this after line where is if(openbuy<1){int buyfail=1;}
else { //OrderSelect(... but I am not sure, maybe it is still selected OrderModify(openbuy,OrderOpenPrice(),slb,tpb,0); }
Repeat similar where the if(opensell<1){int sellfail=1;} is...
Thank you very much..
I will try it when i arrive home, i hope it will work..
Hello,
I have downloaded a Timebased EA, its working like a charm with Strategy test, But when i start it with a practice account i get 0 takeprofit and stopless instead of what i have applied,
Im using OandA MT4 ...
Here is the code :
Could some help me please ?
Thanks
I have a thread going on this myself and was just about to update it. It appears that the very first order you enter it wont let you read the values. Oddly enough you can still modify them however. I added an "if Position(STOP_LOSS)==0, to my trailing sl checks and it fixed it as far as that goes. Very strange it wont let you read it however. I spent hours trying to torubleshoot this issue. I am wondering if it is just on the test server or the live/demo environment will do it as well. Better make a mental note just in case it starts acting wonky at least you will know where to tool around. Here is my thread https://www.mql5.com/en/forum/380454
- 2021.10.26
- 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
Hello,
I have downloaded a Timebased EA, its working like a charm with Strategy test, But when i start it with a practice account i get 0 takeprofit and stopless instead of what i have applied,
Im using OandA MT4 ...
Here is the code :
Could some help me please ?
Thanks