if (Ask>OrderOpenPrice()+510*_Point) OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice()+50*_Point),OrderTakeProfit(),0,clrNONE);
Constant
ERR_NO_RESULTYou | Server |
---|---|
Change the SL to X | It is at X! |
Change the SL to X | It is at X! |
Change the SL to X | You are insane |
Unknown
It kept on producing OrderModify Error 1 when running the ea on strategy tester, everything is working just like expected tho but im concern with this error.
This is the code:
void breakEvenStopLoss() { for (int i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) if (OrderSymbol() == Symbol()) if ((OrderType() == OP_BUY)) if (Ask>OrderOpenPrice()+510*_Point && OrderOpenPrice()+50*_Point!=OrderStopLOst()) { OrderModify(OrderTicket(),OrderOpenPrice(),(OrderOpenPrice()+50*_Point),OrderTakeProfit(),0,clrNONE); } } }
After spending the whole day, i've managed to fix the error, it now works without any error. What it now does is stoploss moves to breakeven when price reached 1:1 risk reward ratio
Here is the code:
void breakEvenStopLoss() { for (int i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) { //SYMBOL MUST BE THE SAME if (OrderSymbol() == Symbol()) { //ORDER TYPE MUST BE THE SAME if ((OrderType() == OP_BUY)) { // PRICE REACHED 1:1 MOVE SL TO BREAKEVEN if (Ask>(OrderOpenPrice()-OrderStopLoss()+OrderOpenPrice()) && //SINCE WE MOVE THE SL TO BREAKEVEN + ADD HALF PIP TO ACCOUNT FOR SPREAD, //MEANING THIS COULD ONLY TRIGGER IF PRICE WASN'T MODIFIED YET, //THUS PREVENTING ORDERMODIFY ERROR 1 //ORDERMODIFY ERROR 1: DOING THE SAME THING OVER & OVER AGAIN WITHOUT CHANGING ANYTHING (OrderStopLoss()<OrderOpenPrice())) { OrderModify(OrderTicket() //CHOOSE THE CORRECT TICKET ,OrderOpenPrice() //ORDER ENTRY PRICE NOT CHANGED, ONLY THE STOPLOSS ,(OrderOpenPrice()+5*_Point) // SL HAS BEEN CHANGED ,OrderTakeProfit() // TAKE PROFIT NOT CHANGED, ONLY THE STOPLOSS ,0 //NO EXPIRATION ,clrNONE); // NO COLOR } } } } } for (int i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) { if (OrderSymbol() == Symbol()) { if ((OrderType() == OP_SELL)) { // PRICE REACHED 1:1 MOVE SL TO BREAKEVEN if (Bid < (((OrderStopLoss()-OrderOpenPrice())-OrderOpenPrice())*(-1)) //SINCE WE MOVE THE SL TO BREAKEVEN + ADD HALF PIP TO ACCOUNT FOR SPREAD, //MEANING THIS COULD ONLY TRIGGER IF PRICE WASN'T MODIFIED YET, //THUS PREVENTING ORDERMODIFY ERROR 1 //ORDERMODIFY ERROR 1: DOING THE SAME THING OVER & OVER AGAIN WITHOUT CHANGING ANYTHING && (OrderStopLoss()>OrderOpenPrice())) { OrderModify(OrderTicket() //CHOOSE THE CORRECT TICKET ,OrderOpenPrice() //ORDER ENTRY PRICE NOT CHANGED, ONLY THE STOPLOSS ,(OrderOpenPrice()-5*_Point) // SL HAS BEEN CHANGED ,OrderTakeProfit() // TAKE PROFIT NOT CHANGED, ONLY THE STOPLOSS ,0 //NO EXPIRATION ,clrNONE); // NO COLOR } } } } } }
if ((OrderType() == OP_BUY)) { // PRICE REACHED 1:1 MOVE SL TO BREAKEVEN if (Ask>(OrderOpenPrice()
- "Whole day" - poor baby.
- It moves the stop loss to breakeven before you reach 1:1
-
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
It kept on producing OrderModify Error 1 when running the ea on strategy tester, everything is working just like expected tho but im concern with this error.
This is the code: