help required in preventing errors like error 130

 

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.

 
 

great thanks

 
BigAl:

great thanks



Oh dear did not help!!! I am on IBFX and MarketInfo for STOPLEVEL and FREEZELEVEL both return 0. so i cant use the limitations as

Bid - SL

SL - Ask

ARE BOTH ALWAYS > STOPLEVEL or FREEZELEVEL


so still open to error 130

Help anyone

 
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.
//++++ 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());
     */
 
WHRoeder:
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();
 
BigAl:

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


 
OOPS!!!!! just seen typeo in first attempt should be - not plus in code!! how did it work at all!!
 
OOPS!!!!! just seen typeo in first attempt should be - not plus in code!! how did it work at all!!
 

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 ?

 
BigAl:
OOPS!!!!! just seen typeo in first attempt should be - not plus in code!! how did it work at all!!
It didn't work . . that's why you got an error 130.
Reason: