great thanks
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_POS)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket()...) Alert("OrderModify failed: ", GetLastError()); */
Are you adjusting pips to double for 4/5 digit brokers. Are you opening the order and THEN setting stops. No mind-readers here, SRC your code.
ok lets try again
running on EURUSDm chart
using several pairs interactively so no discussions on seperate EAs please. use marketinfo mode points so no adjusting required on 3||5 digits.
Orders are opened first and stoploss applied later
First attempt here has failed and second attempt works - values have not changed!! sometimes (every 3-5weeks) second attempt fails as well and screws my scenario completely.
the trade is long and the value of JPYBE is 125
I suppose it could be spread this time - but last time it failed both attempts spread was 0.00028 and I think it would be unlikely to change between the 2 attempts.
Maybe I should recode to Bid - JYPBE
What do you guys think please
Results are
00:55:00 APairofPairsvX EURUSDm,M15: Order Modify Details - First Attempt:
00:55:00 APairofPairsvX EURUSDm,M15: GBPJPYm Ticket# 101396224 OrderOpenPrice 122.567 Ask 122.322 Stoploss 122.322 - JPYBE 0.125 which give stoploss = 122.197 Stoplevel 0 Freezelevel 0
00:55:00 APairofPairsvX EURUSDm,M15: Error 130 Result of first attempt to modify StopLoss on ticket 101396224 GBPJPYm existing StopLoss 0
00:55:00 APairofPairsvX EURUSDm,M15: GBPJPYm Ticket# 101396224 OrderOpenPrice 122.567 Ask 122.322 Stoploss 122.322 - JPYBE 0.125 which give stoploss = 122.197 Stoplevel 0 Freezelevel 0
00:55:00 APairofPairsvX EURUSDm,M15: modify #101396224 buy 0.01 GBPJPYm at 122.567 sl: 122.197 tp: 0.000 ok
00:55:00 APairofPairsvX EURUSDm,M15: TradeNotBusy
if (TradeBusy() < 0) { Print(Symbol(), " Trade is still busy"); return(0); } Print("Order Modify Details - First Attempt:"); while (RefreshRates() == 1) i = i; Print("GBPJPYm Ticket# ", SecondJPYTicket, " OrderOpenPrice ", SecondJPYOpen," Ask ", MarketInfo("GBPJPYm", MODE_ASK), " Stoploss ", MarketInfo("GBPJPYm",MODE_ASK), " - JPYBE ", JPYBE * MarketInfo("GBPJPYm",MODE_POINT), " which give stoploss = ", MarketInfo("GBPJPYm", MODE_ASK) - JPYBE * MarketInfo("GBPJPYm",MODE_POINT), " Stoplevel ",MarketInfo("GBPJPYm",MODE_STOPLEVEL)," Freezelevel ",MarketInfo("GBPJPYm",MODE_FREEZELEVEL)); Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) + MarketInfo("GBPJPYm", MODE_POINT) * JPYBE, 0, 0, Red); if (Result < 1) { Print("Error ", GetLastError(), " Result of first attempt to modify StopLoss on ticket ", OrderTicket(), " ", OrderSymbol(), " existing StopLoss ", OrderStopLoss()); while (RefreshRates() == 1) i = i; Print("GBPJPYm Ticket# ", SecondJPYTicket, " OrderOpenPrice ", SecondJPYOpen," Ask ", MarketInfo("GBPJPYm", MODE_ASK), " Stoploss ", MarketInfo("GBPJPYm",MODE_ASK), " - JPYBE ", JPYBE * MarketInfo("GBPJPYm",MODE_POINT), " which give stoploss = ", MarketInfo("GBPJPYm", MODE_ASK) - JPYBE * MarketInfo("GBPJPYm",MODE_POINT), " Stoplevel ",MarketInfo("GBPJPYm",MODE_STOPLEVEL)," Freezelevel ",MarketInfo("GBPJPYm",MODE_FREEZELEVEL)); Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - MarketInfo("GBPJPYm", MODE_POINT) * JPYBE, 0, 0, Red); if (Result <1) { Print("Error ", GetLastError(), " Results after Second Modify Attempt Modifying StopLoss On Ticket ", OrderTicket(), " ", OrderSymbol()); Print("Spread = ", MarketInfo("GBPJPYm",MODE_SPREAD), " Ask = ", MarketInfo("GBPJPYm",MODE_ASK), " Bid = ", MarketInfo("GBPJPYm",MODE_BID)); Print( "STOPLEVEL = " , MarketInfo("GBPJPYm",MODE_STOPLEVEL), " FREEZELEVEL = ", MarketInfo("GBPJPYm",MODE_FREEZELEVEL)); Print("GBPJPYm Ticket# ", SecondJPYTicket, " OrderOpenPrice ", SecondJPYOpen," Bid ", MarketInfo("GBPJPYm", MODE_BID), " Stoploss ", MarketInfo("GBPJPYm",MODE_ASK), " - JPYBE ", JPYBE * MarketInfo("GBPJPYm",MODE_POINT), " which give stoploss = ", MarketInfo("GBPJPYm", MODE_ASK) - JPYBE * MarketInfo("GBPJPYm",MODE_POINT)); } } TradeNotBusy();
ok lets try again
running on EURUSDm chart
using several pairs interactively so no discussions on seperate EAs please. use marketinfo mode points so no adjusting required on 3||5 digits.
Orders are opened first and stoploss applied later
First attempt here has failed and second attempt works - values have not changed!! sometimes (every 3-5weeks) second attempt fails as well and screws my scenario completely.
the trade is long and the value of JPYBE is 125
I suppose it could be spread this time - but last time it failed both attempts spread was 0.00028 and I think it would be unlikely to change between the 2 attempts.
Maybe I should recode to Bid - JYPBE
What do you guys think please
Results are
00:55:00 APairofPairsvX EURUSDm,M15: Order Modify Details - First Attempt:
00:55:00 APairofPairsvX EURUSDm,M15: GBPJPYm Ticket# 101396224 OrderOpenPrice 122.567 Ask 122.322 Stoploss 122.322 - JPYBE 0.125 which give stoploss = 122.197 Stoplevel 0 Freezelevel 0
00:55:00 APairofPairsvX EURUSDm,M15: Error 130 Result of first attempt to modify StopLoss on ticket 101396224 GBPJPYm existing StopLoss 0
00:55:00 APairofPairsvX EURUSDm,M15: GBPJPYm Ticket# 101396224 OrderOpenPrice 122.567 Ask 122.322 Stoploss 122.322 - JPYBE 0.125 which give stoploss = 122.197 Stoplevel 0 Freezelevel 0
00:55:00 APairofPairsvX EURUSDm,M15: modify #101396224 buy 0.01 GBPJPYm at 122.567 sl: 122.197 tp: 0.000 ok
00:55:00 APairofPairsvX EURUSDm,M15: TradeNotBusy
After an Error 130 you are supposed to wait 5 seconds before retrying . . .
Can you explain how this works ? and what is the point of it ?
while (RefreshRates() == 1) i = i;
How does this work out ? ask ( 122.322 ) + JPYBE ( 0.125 ) = 122.447 not 122.197
Your second modify does ask ( 122.322 ) - JPYBE ( 0.125 ) = 122.197 and works . . weird eh ?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
If I want to modify a trade stoploss on a buy trade with a simple Ask - 0.0012 for example I am obviously leaving myself exposed for the trade to fail.
Ok, if I want to ensure I do not get an error then I must consider the Spread, the Stoplevel and the freezelevel. (is there anything else I need to look for?)
Please can someone explain the relationship between Spread, stoplevel and freezelevel as I understand they can all change under certain market conditions
and may well stop the modification of a trade.