Ok I think I have found what exactly is conflicting, it seems to be stop orders in strategy builder bug out the strategy if you are using limit entries?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Stop order breaks backtester
Collapse
X
-
Stop order breaks backtester
If I add a stop order in the strategy builder it seems to stop the strategy from processing after placing the first order on a day. For example with no stop 10 orders placed in a day, then add a stop of even 99999999 ticks and now only 1 or 2 orders placed in that day. It just seems to be bugging out the backtest logic for some reason. Help please!
Ok I think I have found what exactly is conflicting, it seems to be stop orders in strategy builder bug out the strategy if you are using limit entries?Last edited by obomana; 04-09-2017, 05:12 AM.Tags: None
-
Hi thanks for the fast response.
I have,
Entries per direction: 1
Entry handling: All entries
Not currently using signal names for orders, this is left blank.
If the stop is small enough that it triggers then the strategy will continue as normal.
What it seems to struggle with is exiting then entering in a reverse direction after already in position (but only when a stop is assigned).
I tried increasing the entries per direction and it would enter more trades in the same direction, but still failed to reverse direction most of the time when signalled.
Comment
-
Hello obomana,
The first issue is likely the EntriesPerDirection and Entry handling.
If you add TraceOrders = true; to the State.SetDefaults, are you seeing messages about ignored orders?
Try setting the EntriesPerDirection to the number of entries you would like in a particular direction.
The second issue is likely a violation of the managed approach internal handling rules.
"Methods that generate orders to enter a position will be ignored if:
A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction"
You would need to either allow the stop to exit the trade, or use an entry in the opposite direction to reverse the position. You cannot use both. (And logically you would not want to)Chelsea B.NinjaTrader Customer Service
Comment
-
The problem it would seem is that when there is for example a long stop order active for an open short position then the backtester will ignore any long limit entry orders. It will not close the original short and enter long on triggering as expected.
When I have no stop orders set the strategy works as expected.
I have tried naming the short entry limit and long entry limit seperately with a stop named for each one, and changing entry handling to unique entries. But this has made no difference.
Help much appreciated.
Comment
-
Hello obomana,
To be clear you want to have a stop working and place an order to enter in the opposite direction, is this correct?
You cannot. This violates the internal order handling rules.
From the help guide:
"Methods that generate orders to enter a position will be ignored if:
A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction"
You would need to use the unmanaged approach to do this, or simply call the entry to reverse the position without using an exit order like setstoploss.
Please let me know if I have not understood correctly.Chelsea B.NinjaTrader Customer Service
Comment
-
Yes I think the problem is what you have described because I tried adding a profit target without stop order and I had the same problem.
It is very important for my strategy however to enter and exit/reverse using a limit entry, while also using a stop loss. It seems strange that this is not possible as normal.
Is it possible to use this unmanaged approach through the strategy builder?
Many thanks.
Comment
-
Hello obomana,
It is not suggested to have multiple exit orders working for a single entry order. This can lead to both orders filling and can lead to unwanted positions and overfills.
If you want to reverse the position, it would be suggested to only use the entry in the opposite direction without the stop or target. Or wait until the first position is exited and the position becomes flat before entering into the opposite direction.
You could also unlock the script use an exit order instead of set method for the stop and targets, and then cancel these using CancelOrder() if you have decided to reverse instead, wait for the protective orders to be cancelled (in OnOrderUpdate) and then submit the order to reverse the position.
Below is a link to CancelOrder() in the help guide.
As well as a link to the reference sample on CancelOrder().
When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until
Yes, you could place these orders and any orders at any time using the unmanaged approach as this will not have internal order handling.
No, the Strategy Builder is limited and used for creating simple scripts. Once your strategy needs complexity (such as math), the script needs to be unlocked and coded in the NinjaScript Editor by hand.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello obomana,
You cannot place an entry order while a position is open and an exit order is working in the managed approach because of the internal order handling rules (whether or not you feel in that specific circumstance your orders would not both fill).
You can do this in unmanaged approach.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Yesterday, 06:40 PM
|
2 responses
21 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
21 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment