Strategy tester error 130

 

I've been looking at this particular problem for some time and am starting to feel I am missing something very obvious. Running on the Strategy tester I get error 130 consistently for some trades that happen during my testing period . . the vast majority of trades are fine. For example:

18:43:00 2008.03.20 12:35 OBTraderV2T GBPUSD,H1: Going long Bid= 1.9843

18:43:00 2008.03.20 12:35 OBTraderV2T GBPUSD,H1: Start of CheckTradesize Bid= 1.9843

18:43:00 2008.03.20 12:35 OBTraderV2T GBPUSD,H1: TradeSize = 1 TradeSizeBad = false NormTrade = 1 Bid= 1.9843 Ask= 1.9845

18:43:00 2008.03.20 12:35 OBTraderV2T GBPUSD,H1: open #22 buy stop 1.00 GBPUSD at 1.98446 sl: 1.97330 tp: 1.98616 ok

18:43:00 2008.03.20 12:35 OBTraderV2T GBPUSD,H1: RefreshRates: Bid= 1.9843 Ask= 1.9845

18:43:00 2008.03.20 12:38 Tester: order #22, buy 1.00 GBPUSD is opened at 1.98446

18:43:01 2008.03.20 21:10 Tester: take profit #22 at 1.98616 (1.98617 / 1.98633)

I use a BUY_STOP so I can set SL and TP (MBT ECN broker) . . another . . .

18:48:30 2008.03.27 10:17 OBTraderV2T GBPUSD,H1: Going long Bid= 2.0137

18:48:30 2008.03.27 10:17 OBTraderV2T GBPUSD,H1: Start of CheckTradesize Bid= 2.0137

18:48:30 2008.03.27 10:17 OBTraderV2T GBPUSD,H1: TradeSize = 1 TradeSizeBad = false NormTrade = 1 Bid= 2.0137 Ask= 2.0139

18:48:30 2008.03.27 10:17 OBTraderV2T GBPUSD,H1: open #23 buy stop 1.00 GBPUSD at 2.01386 sl: 2.00470 tp: 2.01527 ok

18:48:30 2008.03.27 10:17 OBTraderV2T GBPUSD,H1: RefreshRates: Bid= 2.0137 Ask= 2.0139

18:48:30 2008.03.27 10:18 Tester: order #23, buy 1.00 GBPUSD is opened at 2.01386

18:48:31 2008.03.27 10:24 Tester: take profit #23 at 2.01527 (2.01540 / 2.01556)

Now the error 130 . . .

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: Going long Bid= 2.0173

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: Start of CheckTradesize Bid= 2.0173

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: TradeSize = 1 TradeSizeBad = false NormTrade = 1 Bid= 2.0173 Ask= 2.0175

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: OrderSend error 130

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: Error_Text = PlaceTrade: last error is . . .130

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: OP_BUYSTOP: TradeSize= 1 Trade_Entry= 2.0171 Ask= 2.0175 Trade_SL= 2.0088 Trade_TP= 2.0194

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: RefreshRates: Bid= 2.0173 Ask= 2.0175

Freeze Level and Stop Level are both 0.0, it's an ECN broker, but anyway, the Stops are a long way off on all 3 trades, the TPs are 16 pips, 13 pips
away from Ask and 19 pips for the trade that gave Error 130. As you can see from the RefreshRates entry the price is not changing super quickly . . . what am I missing ? any ideas ?



 
I had problems when I tried using buystops with tp/sl. I thought it was comparing current price vs stops but couldn't ever verify. Could also be ECN, open first THEN set stops.
 
WHRoeder:
Could also be ECN, open first THEN set stops.

My understanding was that with an ECN broker I should be able to set SL and TP with a pending order . . . but I will adjust my code to set order with SL and TP at 0 and then modify order to see if it fixes this issue.

I just get uneasy when things work most of the time and then occasionally don't and I can't explain it . . .

When it's in the Strategy Tester does it matter what the Broker is ? won't the Strategy Tester just go by it's recorded MarketInfo variables ?

 
Bugs in the tester don't obey any thing.
 
WHRoeder:
Bugs in the tester don't obey any thing.

I don't mind if it's a bug in the Tester as long as I can confirm that it is a bug in the Tester. Wonder if there is a list of known bugs . . . .
 

I have build 229 on one of my older PCs and the documentation says:

RaptorUK is suppose to answer question, not ask.

But it also says:

Attention:
  • execution prices for all trade operations are defined by the broker;
  • Stop Loss and Take Profit orders can only be executed for an open position, but not for pending orders;
  • history charts are drawn only for BID prices in the terminal. At that, a part of orders shown in charts is drawn for ASK prices. To enable displaying of the latest bar ASK price, one has to flag the "Show Ask line" in the terminal settings.
 
serpentsnoir:

I have build 229 on one of my older PCs and the documentation says:

RaptorUK is suppose to answer question, not ask.


:-) very funny

Thanks for the quote from the documentation.

 
RaptorUK:

My understanding was that with an ECN broker I should be able to set SL and TP with a pending order . . . but I will adjust my code to set order with SL and TP at 0 and then modify order to see if it fixes this issue.


I modified my code to place the Buy/Sell with TP & SL set to 0, then modify the order afterwards to add the correct SL and TP . . . it seems to have cleared up my error 130s.

I'm a little paranoid about placing orders without a SL. For the EA I'm currently working on I have started with all the generic functions, even if this EA turns out to be a dud I will still have some functions I can reuse for the next EA. I have created a function to check open orders for missing SLs and TPs and also SLs and TPs that have already been passed by without closing the order . . . in the event of a problem the error will be logged to screen and emailed. Not sure what else I can do . . . personally I don't plan to trade with an ECN broker but others that will use this EA will be.

 
Just a thought that you could place Stop orders of the same size instead of Stoploss and Take then delete the remaining pending order when there is no trade open since either the Stop above or below the trade has been hit and closed the trade with the opposite trade.
 

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: OP_BUYSTOP: TradeSize= 1 Trade_Entry= 2.0171 Ask= 2.0175 Trade_SL= 2.0088 Trade_TP= 2.0194

18:49:36 2008.03.27 11:11 OBTraderV2T GBPUSD,H1: RefreshRates: Bid=2.0173 Ask= 2.0175

You try to open a buystop below the ask/bid. You have to use BUYLIMIT for that

 
zzuegg:

You try to open a buystop below the ask/bid. You have to use BUYLIMIT for that


It might look like that but the BUYLIMIT was actually set to be placed at Ask not Trade_Entry ;-)
Reason: