SellAtStop orders are not executing
Author: dclark04
Creation Date: 11/16/2019 12:03 AM
profile picture

dclark04

#1
Edit: The title should be "SellAtStop Orders Are Not Executing"

I'm testing a strategy that uses bracket orders, and I am adjusting the Stop higher throughout the day (on an intra-day chart). This works perfectly when testing the strategy, but when I'm running it live against a PaperTrading account, none of the SellAtStop orders are processing.

Any ideas why these SellAtStop orders are not actually selling the position when the price goes below the stop price?

Here's part of my code:
CODE:
Please log in to see this code.


I am calling PlotStops() to graph the stops on the chart, and logging them Debug Log. Everything looks correct. The orders are getting placed into the Orders window, but the order does not execute and gets canceled.

Is this the correct way to code a bracket order?
Should I be using SellAtTrailingStop if the stop price changes over time?
Is this an issue only with PaperTrading?

Any thoughts would be appreciated.
Thanks.
profile picture

Eugene

#2
Please post the entire code, preserving the structure of the trading loop. You may skip the definitions of stopLoss/profitTarget as well as any variables that lead to entry (but don't omit the entry itself). Need to check the code for potential peeking into the future and other errors.
profile picture

Cone

#3
QUOTE:
Is this the correct way to code a bracket order?
yes, as long as you've previous calculated values for the stopLoss and profitTarget variables.

QUOTE:
Should I be using SellAtTrailingStop if the stop price changes over time?
A trailing stop only allows the stop price to change to a higher price (long position). If the value doesn't change or if you want the freedom to change the trigger price to any value, then just use SellAtStop.

QUOTE:
Is this an issue only with PaperTrading?
Could be. Read the User Guide > Orders > Paper Trading for info about limitations of this feature.
profile picture

dclark04

#4
Cone, you may be on to something. The User Guide specifically states "Bracket OCO Exit Order functionality" is not supported for paper trading.

I'll try again with just a stop loss order and see if the sell orders execute.


profile picture

Cone

#5
I was referring more about how the paper trader polls for quotes every 30 seconds, which is not the way a broker triggers orders. See "How Orders Are Filled"

For example, imagine your stop is at $10.00 and the market is trading $10.05. The market can dip to $10.00 or below, but then rise above it again before the paper trader polls for a quote. (A live order would trigger and sell at the market with the first tick at (or below) the $10.00 stop level.) If the Paper Trader misses this fill, it's a problem for the strategy, because the strategy will hypothetically fill the order since the price actually cross the stop trigger and then will strategy triggering the entry logic again. The result is that the strategy becomes out-of-sync with the Paper account. It's a pretty big deficiency in the Paper trader, but there hasn't been any will to change it.

Keep reading that Orders chapter. This out-of-sync condition can happen with a live account too, but probably only occasionally with limit orders - when the limit is "touched" but not all orders on the book at the price are filled. The salient point here is that Auto-Trading in Wealth-Lab shouldn't be thought of as "turn on and forget". Instead, it's to help traders manage their workload, but they need to be ready to intervene when required.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).