Oanda plugin stop loss doesn't work on shorts

Posted By: kap

Oanda plugin stop loss doesn't work on shorts - 12/14/16 02:45

I get errors such as the following when opening short trades on Oanda - these do not occur when opening long trades.

This issue only occurs when connected to Oanda, it does not occur during backtests.

I am setting the stop price by assigning a small value (i.e. 3*PIP) to "Stop" - note there is a limit entry price on all orders too so the trade is not opened at the stazrt of the bar.

Any ideas?

-K

(USD/CAD::S) Entry limit 1.31336 hit at 02:35:58
!Order: {
"code" : 33,
"message" : "Invalid stopLoss error: requested stopLoss is below price 1.3134",
"moreInfo" : "http://developer.oanda.com/docs/v1/troubleshooting/#errors"
}
(USD/CAD::S) Can't open 100000 @ 0.00000 at 02:35
Posted By: MatPed

Re: Oanda plugin stop loss doesn't work on shorts - 12/14/16 07:57

Probably 3 pips are below the spread at that moment. My 2 cents
Posted By: kap

Re: Oanda plugin stop loss doesn't work on shorts - 12/15/16 00:24

The stop price sent to the broker is farther away than the "real" stop (i.e. StopFactor defaults to 50%).

USD/CAD spread is about 2 pips, I only see this error on shorts but I do see it on other currencies.

Also Oanda provides both bid and ask in its feed so plugin has the realtime spread - it should adjust the spread correctly for long/short when calculating the stop price.

I've tried setting the stop price explictly (i.e. the full price, not an offset) and I still see this issue - in the meantime I've disabled btoker stops (i.e. set StopFactor = 0) which at least gets Zorro to place the trade.

Is there any way to get Zorro to dump the broker traffic? Although Oanda uses a straightforward REST/HTTP protocol as it's SSL encrypted I can't use network captures to debug the plugin.

-K
Posted By: Finstratech

Re: Oanda plugin stop loss doesn't work on shorts - 12/15/16 16:11

Are you using the set(TICKS) flag? If not, try it.
Posted By: jcl

Re: Oanda plugin stop loss doesn't work on shorts - 12/16/16 08:06

If your stop distance is too low, increase it. The API can not fix it since the fill price of a trade is unknown beforehand. Quote differences of 3 pips or more are not uncommon.

Many brokers do not accept stop loss orders at a distance less than 10 pips anyway.
Posted By: kap

Re: Oanda plugin stop loss doesn't work on shorts - 12/18/16 14:42

Oanda's normal stops can be placed 0.1 pips below(above) the bid(ask) price for longs(shorts). For Oanda's trailing stops, they have to be placed at least 5.0 pips away.

In this case, given the orders have an entry prices, at the time the order is sent to the broker the market price is different from when the order was submitted to Zorro - it is unclear to me what adjustments Zorro may be making to the prices.

Is it possible to dump the raw broker order message when the plugin sends it?
Or do I need to write a TMF to dump the TRADE struct to a file to trace this?

-K
Posted By: jcl

Re: Oanda plugin stop loss doesn't work on shorts - 12/19/16 15:19

In the case of entry orders the stop loss is relative to the entry price, not to the price at order time. There is no mechanism to dump the raw message AFAIK.
© 2024 lite-C Forums