Skip to content
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

Open
rosasurfer opened this issue Dec 8, 2019 · 1 comment
Open

Tester & demo servers may not execute specified stoplosses #10

rosasurfer opened this issue Dec 8, 2019 · 1 comment

Comments

@rosasurfer
Copy link
Owner

rosasurfer commented Dec 8, 2019

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.

@rosasurfer rosasurfer changed the title Tester/demo: In a fast market triggered limit orders with SL will not be reported as closed Tester/demo: In a fast market a triggered limit order with SL may not be reported as closed Dec 8, 2019
@rosasurfer rosasurfer changed the title Tester/demo: In a fast market a triggered limit order with SL may not be reported as closed Tester/demo: In a fast market a triggered limit order with SL may not immediately be reported as closed Dec 8, 2019
@rosasurfer rosasurfer changed the title Tester/demo: In a fast market a triggered limit order with SL may not immediately be reported as closed Tester/demo: In a fast market a triggered limit order with SL is not reported as closed Dec 8, 2019
@rosasurfer rosasurfer changed the title Tester/demo: In a fast market a triggered limit order with SL is not reported as closed Tester+demo: In a fast market a triggered limit order with SL is not reported as closed Dec 8, 2019
@rosasurfer rosasurfer changed the title Tester+demo: In a fast market a triggered limit order with SL is not reported as closed Tester & Demo: In a fast market a triggered limit order with SL is not reported as closed Dec 8, 2019
@rosasurfer rosasurfer changed the title Tester & Demo: In a fast market a triggered limit order with SL is not reported as closed Tester & demo servers check only a single order limit per ticket and tick Jan 29, 2020
@rosasurfer rosasurfer pinned this issue Jan 29, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers check only a single order limit per ticket and tick Tester & demo servers check only a single limit per ticket and tick Jan 29, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers check only a single limit per ticket and tick Tester & demo servers check only one limit per ticket and tick Jan 29, 2020
rosasurfer added a commit that referenced this issue Jan 29, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers check only one limit per ticket and tick Tester & demo servers execute only one limit per ticket and tick Jan 29, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers execute only one limit per ticket and tick Tester & demo servers may not execute specified stoploss Jan 30, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers may not execute specified stoploss Tester & demo servers may not execute specified stoplosses Jan 30, 2020
@rosasurfer
Copy link
Owner Author

Another explanation is here: Ignored Stoploss During Backtest

@rosasurfer rosasurfer changed the title Tester & demo servers may not execute specified stoplosses Tester & demo servers may not execute set stoplosses Apr 18, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers may not execute set stoplosses Tester & demo servers may not execute defined stoplosses Apr 18, 2020
@rosasurfer rosasurfer changed the title Tester & demo servers may not execute defined stoplosses Tester & demo servers may not execute specified stoplosses Jan 2, 2021
Repository owner deleted a comment from gotkungll Jan 28, 2021
@rosasurfer rosasurfer unpinned this issue Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant