-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tester & demo servers may not execute specified stoplosses #10
Labels
Comments
Another explanation is here: Ignored Stoploss During Backtest |
Repository owner
deleted a comment from
gotkungll
Jan 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checking and execution of stoplosses in Strategy Tester and on demo servers is broken. In a fast market both limits of a pending entry order with attached stoploss may be triggered by the same tick. Tester and demo servers only check a single order limit per ticket and tick. As a result such an entry order is reported as open (filled) while in a real market it would be closed. The stoploss limit will be checked at the next tick but if the next tick doesn't trigger that limit the order will stay open and the position becomes invalid. In a real market such an order would be closed. In tester and on demo servers it may stay open for an infinite time.
Imagine a market at 1.2000, a Buy Limit order at 1.1998 with a SL at 1.1995. Further assume an open long position with SL at 1.1990. If the market spikes down to 1.1990 with a single tick (e.g. news) all existing limits are triggered (the buy limit and the two stoplosses). Despite the market now being at 1.1990 tester and demo servers will report the Buy Limit order at 1.1998 as open and the SL at 1.1995 as not executed.
If the next tick is above 1.1995 (the SL of the wrongly reported open order) the SL is not triggered and the order is not reported as closed again. If the market continues to go up the SL may never be triggered and the order stays open, while in a real market the order would be immediately closed. Tester and demo server will be in an illegal state.
The workaround is to manually check the exit limit of orders with entry and exit limits on the tick the entry limit is reported as executed, and to manually execute such ignored exit limit.
The text was updated successfully, but these errors were encountered: