error 130 puzzled

 

I already have in my code 2 attempts at modifying stop losses (running on EURUSDm chart as using multiple pairs) . Can anybody tell me why/how I got this error and how to avoid it in the future

Code snippet: where JPYBE = 125

if (TradeBusy() < 0)
{
Print(Symbol(), " Trade is still busy");
return(0);
}
RefreshRates();
Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - MarketInfo("GBPJPYm", MODE_POINT) * JPYBE, 0, 0, Blue);
if (Result < 1)
{
Print("Error ", GetLastError(), " On First Attempt to Modify StopLoss On",OrderSymbol());
RefreshRates();
Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - MarketInfo("GBPJPYm", MODE_POINT) * JPYBE, 0, 0, Blue);
if (Result <1)
{
Print("Error ", GetLastError(), " While Modifying StopLoss On GBPJPYm");
Print("SecondJPYTicket ", SecondJPYTicket, " SecondJPYOpen ", SecondJPYOpen);
Print(" Ask = ", MarketInfo("GBPJPYm", MODE_ASK), " SL = ", MarketInfo("GBPJPYm", MODE_ASK) - MarketInfo("GBPJPYm",MODE_POINT)* JPYBE);
}
}
TradeNotBusy();

Error messages:

08:30:23 APairofPairsvY EURUSDm,M15: Error 130 On First Attempt to Modify StopLoss On GBPJPYm

08:30:23 APairofPairsvY EURUSDm,M15: Error 130 While Modifying StopLoss On GBPJPYm

08:30:23 APairofPairsvY EURUSDm,M15: SecondJPYTicket 101106283 SecondJPYOpen 124.926

08:30:23 APairofPairsvY EURUSDm,M15: Ask = 124.858 SL = 124.733

08:30:23 APairofPairsvY EURUSDm,M15: TradeNotBusy

 

Please use this to post code . . . it makes it easier to read.

What is the spread when you try to Modify this order ?

For Buy order the SL is taken at Bid price . . . what is your MarketInfo MODE_STOPLEVEL ? your SL is only 12.5 pips away, looks like it's too close . .

 

Hi RaptorUK thanks for the reply

Not sure what the spread was at the time, the StopLoss was at 0

however I would think the spread was ok as it had just modifed an EURJPY order timed exactly the same

08:30:23 APairofPairsvY EURUSDm,M15: modify #101106284 sell 0.01 EURJPYm at 109.966 sl: 109.655 tp: 0.000 ok

and there is 0.125 gap between the Ask and SL request ....Ask = 124.858 SL = 124.733 the fact that it was a sell order would close that gap a bit ... but more than double the norm 6pips when EURJPY was fine

what do you think?

 
BigAl:


and there is 0.125 gap between the Ask and SL request ....Ask = 124.858 SL = 124.733 the fact that it was a sell order would close that gap a bit ... but more than double the norm 6pips when EURJPY was fine

what do you think?

I think that for a Sell order the SL has to be higher than the entry price . . . from your figures and the fact you are placing the order at Ask . . . I assumed it was a Buy.
 
  1. RaptorUK:
    For Buy order the SL is taken at Bid price . . . what is your MarketInfo MODE_STOPLEVEL ? your SL is only 12.5 pips away, looks like it's too close . .

    Even closer than 12.5 since for a buy, stops are relative to the BID


  2. and there is 0.125 gap between the Ask and SL request ....Ask = 124.858 SL = 124.733 the fact that it was a sell order would close that gap a bit ... but more than double the norm 6pips when EURJPY was fine
    If this is a sell order then the SL must be ABOVE the market ASK
  3. EA/s must adjust for 4/5 digit brokers, your multiply by MODE_POINT doesn't.
 

1. Sorry to have confused you, the EURJPY trade that worked fine was a Sell and the GBPJPY was a Buy trade. So the ASK = 124.858 and SL = 124.733 is a 12.5 pip gap (over double the normal spread).

2. Its a Buy trade and the SL is below the Ask price so that is ok.

3. JPY is neither 4 or 5 digits .... it is 3 Digits and the MODE_POINT works fine for JPY ..... MarketInfo("GBPJPYm",MODE_POINT) * 125 = 12.5 pips

I think it may still be a spread problem but it seems strange that the EURJPY worked fine at the same time. However, the gap on the EURJPY was also 12.5 pips which is approximately 3 x the normal spread.

So maybe if I try setting JPYBE to say 62 and add the spread......Like so

Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - MarketInfo("GBPJPYm", MODE_POINT) * JPYBE + MarketInfo("GBPJPYm",MODE_SPREAD), 0, 0, Blue);

This will work?

What are te thoughts on that please

 
BigAl:

3. JPY is neither 4 or 5 digits .... it is 3 Digits and the MODE_POINT works fine for JPY ..... MarketInfo("GBPJPYm",MODE_POINT) * 125 = 12.5 pips

I think it may still be a spread problem but it seems strange that the EURJPY worked fine at the same time. However, the gap on the EURJPY was also 12.5 pips which is approximately 3 x the normal spread.

So maybe if I try setting JPYBE to say 62 and add the spread......Like so

Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - MarketInfo("GBPJPYm", MODE_POINT) * JPYBE + MarketInfo("GBPJPYm",MODE_SPREAD), 0, 0, Blue);

This will work?

What are te thoughts on that please


Regarding 3., the point is that if you run your EA on a "4 digit Broker" your 125 SL will become 125 pips.

Spread for EJ will be less than the spread for GJ.

 
  1. Result = OrderModify(SecondJPYTicket, SecondJPYOpen, MarketInfo("GBPJPYm",MODE_ASK) - ...
    if (Result < 1)
    OrderModify returns a bool not an int. if(!OrderModify(...){ Alert(...
  2. . Its a Buy trade and the SL is below the Ask price so that is ok.

    No it has to be below the Bid by at least MarketInfo("GBPJPYm", MODE_STOPLEVEL)*Point
 

ok point (no pun intended) taken on digits

Still concerned on error 130 as looked at similar EA with that code and found error 130 with 0.25 pips gap not 12.5. make any difference to what you think?

Reason: