Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
strategy start behavior in live Simulation
Collapse
X
-
strategy start behavior in live Simulation
I'm testing a strategy in live feed simulation. My strategy start behavior is set to immediately submit at start. I'm flattening all open orders at 15:45, then restarting the strategy at 17:00. I want the strategy to immediately submit at 17:00 according to it's market position. However, in simulation, the strategy looks back in time and submits this order on the historical data before 15:45 when I flattened all open orders. Is it possible to have this strategy submit this order at the current live market price at 17:00 in simulation, in order to mimic how it would operate if submitting an actual live market order to the exchange at 17:00?Tags: None
-
Hello 2inthebush,
Thanks for your post.
We are using ImmediatlySubmit so the strategy will process historical data to determine what the strategy position what active orders the strategy should have. The behavior is used when we want to resume a position and we know the account position is what the strategy position would be.
There are a few items I will need clarity on:
I'm flattening all open orders at 15:45,
I want the strategy to immediately submit at 17:00 according to it's market position.
Is it possible to have this strategy submit this order at the current live market price at 17:00 in simulation, in order to mimic how it would operate if submitting an actual live market order to the exchange at 17:00?
Can you also confirm if it is used for an entry/exit in this case?JimNinjaTrader Customer Service
-
Hi Jim,
We are using ImmediatlySubmit so the strategy will process historical data to determine what the strategy position what active orders the strategy should have. The behavior is used when we want to resume a position and we know the account position is what the strategy position would be.
I'm flattening all open orders at 15:45,
Are you just canceling orders or also flattening the position? (When we restart the strategy, is it restarted when the account is flat without any orders pending, or when the account is in position without any active orders?)
I want the strategy to immediately submit at 17:00 according to it's market position.
Do you mean that you want the strategy to resume an active position, and submit a historical order, but instead of submitting the historical order, you want to submit an order based on factors that would have been calculated at 17:00?
Is it possible to have this strategy submit this order at the current live market price at 17:00 in simulation, in order to mimic how it would operate if submitting an actual live market order to the exchange at 17:00?
Could you elaborate on the order you want submitted at 17:00? Market/Stop/Limit?
Can you also confirm if it is used for an entry/exit in this case?Last edited by 2inthebush; 03-31-2022, 03:21 PM.
Comment
-
Hello 2inthebush,
I think you will just want to use ImmediatelySubmit, Synchronize Account.
This will have the NinjaTrader submit a live market order to the account when you enable the strategy to sync the account position to the strategy position. This would be your market entry order, and it would be submitted at 17:00 when you re-enable to re-sync the account/strategy
This way, you would disable the strategy and flatten it (Flatten Everything does this)
(Strategy and account are now de-synced)
When you re-enable with Immediately Submit Synchronize Account, the position is immediately re-entered on the account since the strategy calculated it would be in position, and any pending orders will be submitted immediately upon start up.
JimNinjaTrader Customer Service
Comment
-
OK. This strategy is set to ImmediatelySubmit, Synchronize Account. At least I can presume that it will behave as I've intended when placing live orders to the exchange. However, this doesn't solve the issue I've described while trading the simulated account with live data feed.
I've attached a screenshot to demonstrate the behavior. I'm currently connected to my live CQG data feed. First, I flattened all open trades and orders and disabled the strategy. Then I enabled the strategy after 17:00. Instead of entering at the current live price, the strategy has entered at the original historical signal at approx. 14:51.Last edited by 2inthebush; 03-31-2022, 04:46 PM.
Comment
-
Hello 2inthebush,
To be clear, the simulated and Live account will be the same in this case.
You are correct that this will adjust the realtime order (and also the realtime strategy performance report) but the markers on the chart and the historical executions calculated by the strategy, would reflect the historically calculated orders.
Immediately Submit, Sync Account will allow you to re-enter, and re-sync the strategy position, but yes, the active orders would be relative to the historical entry.
To have the target/stop relative to the newly entered position, and not the historical position, you could consider using AdoptAccountPosition and adopt a workflow so you:- Manually re-enter
- Enable the strategy with AdoptAccountPosition
AdoptAccountPosition also exhibits behaviors as ImmediatelySubmit where previously calculated orders would be submitted. You could maybe consider making a copy of your strategy that skips processing historical data, and uses AdoptAccountPosition. I have attached examples.
Alternatively, and maybe what you were trying to do in the first place:
You could consider checking if there is a position on the last historical bar, exit that historical position, and set a bool representing that you need to enter on the first realtime bar. (This could be used with ImmediatelySubmit, without using Sync Account.)
This could look something like:
Code:private bool NeedToReEnter = false; protected override void OnBarUpdate() { if (State == State.Historical && CurrentBar == BarsArray[0].Count-2 && Position.MarketPosition == MarketPosition.Long) { ExitLong(); NeedToReEnter = true; } else if (State == State.Realtime && NeedToReEnter) { EnterLong(); NeedToReEnter = false; } }
JimNinjaTrader Customer Service
Comment
-
Alright cool, I'll look into those options which you've described. I'd tried a similar approach recently with the bool but was having trouble getting it to work right. I'll try it again using your instructions above. Thank you for you help, Jim!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ageeholdings, Today, 07:43 AM
|
0 responses
7 views
0 likes
|
Last Post
by ageeholdings
Today, 07:43 AM
|
||
Started by pibrew, Today, 06:37 AM
|
0 responses
4 views
0 likes
|
Last Post
by pibrew
Today, 06:37 AM
|
||
Started by rbeckmann05, Yesterday, 06:48 PM
|
1 response
14 views
0 likes
|
Last Post
by bltdavid
Today, 05:43 AM
|
||
Started by llanqui, Today, 03:53 AM
|
0 responses
6 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
12 views
0 likes
|
Last Post Today, 12:38 AM |
Comment