Hi,
This function is sporadicaly returning OrderModify Error 1. Any ideas? I'd be most thankful!
You will probably be asking about the OrderIsFresh so here is the function assigning that:
In order of execution (simplified):
int start ()
{
LookForEntry();
ManageOrders();
}
void LookForEntry() { double buyprice = iLow (Symbol(),0,1) - 1 * Point; double sellprice = iHigh(Symbol(),0,1) + 1 * Point; if (Pending_Long == 1 && Bid <= buyprice) { Ticket = OrderSend(Symbol(),OP_BUY ,LotSize,Ask ,30,Ask - (SL_Points * Point),0,NULL,Magic,Red); Pending_Long = 0; } if (Pending_Short == 1 && Bid >= sellprice) { Ticket = OrderSend(Symbol(),OP_SELL,LotSize,Bid ,30,Bid + (SL_Points * Point),0,NULL,Magic,Red); Pending_Short = 0; } OrderIsFresh = 1; }
I am really tearing my hair off over this, I have tried inserting prints everywhere but I have no clue.
Thanks alot in advance!
/ McKeen
just reacting to a gut feel --
OrderModify(tkt,open,stop,0,0,Yellow);
might be best written as:
OrderModify(tkt,OrderOpenPrice(),<newstoploss>,<newtakeprofit>,0,YellowBelly);
You have suggested to the server that your take-profit will be triggered when the price is zero. my retirement plan will be a bust if any currency goes to zero....
please let us know if this triggers "eureka".
sn
just reacting to a gut feel --
OrderModify(tkt,open,stop,0,0,Yellow);
might be best written as:
OrderModify(tkt,OrderOpenPrice(),<newstoploss>,<newtakeprofit>,0,YellowBelly);
You have suggested to the server that your take-profit will be triggered when the price is zero. my retirement plan will be a bust if any currency goes to zero....
please let us know if this triggers "eureka".
sn
Thanks for your reply but that's not it. 0 is okay for tp, a non-zero double is not mandatory. I use it all the time without errors and it may also be used for sl parameter.
/ McKeen
perhaps you should limit ordermodify to once per bar only.
as i understand you loop through ordermodify every tick
Hi,
If you run this code more than once per bar, you will get the OrderModify error 1. Basically you are telling it on each tick to modify the SL to the last bar, which remains unchanged and this produces Error 1.
- Don't call modify if the new values match the current ones.
//For buy if ((new.stop-OrderStopLoss()) > Point) OrderModify(...
for (int x=OrdersTotal()-1; x>=0; x--) { OrderSelect(x,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
You should be checking the return code for orderSelect and why are you selecting twice?for (int x=OrdersTotal()-1; x>=0; x--) if( OrderSelect(x,SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic){
- You should be checking the return code for orderSelect and why are you selecting twice?
I have read in various places that OrderSelect is a common reason for error and can´t be executed one time too many.
I am therefor defaulting to 1 OrderSelect for every 2 order-calls (ie OrderType, OrderSymbol ...).
Perhaps it is unneccesary to run it more than once no matter how many "order-calls" one make?
Thanks for all your replies, it was just like you all suggested. (SL was already at the value being set).
/ McKeen
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
This function is sporadicaly returning OrderModify Error 1. Any ideas? I'd be most thankful!