Im using PositionAccount.MarketPosition == MarketPosition.Flat on real time trades and is working perfectly. Same is not happening on historical, and I want to simulate my strategy behaviour as if real, but this is not happening. Each time there is a new signal on historical, current position is CLOSED and it goes in the other direction. How I can disable to take a new position if market is not flat but on historical trades?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Only take trades when flat BUT on historical trades
Collapse
X
-
Only take trades when flat BUT on historical trades
Hello guys,
Im using PositionAccount.MarketPosition == MarketPosition.Flat on real time trades and is working perfectly. Same is not happening on historical, and I want to simulate my strategy behaviour as if real, but this is not happening. Each time there is a new signal on historical, current position is CLOSED and it goes in the other direction. How I can disable to take a new position if market is not flat but on historical trades?Tags: None
-
Hello facuevasm,
Thanks for your first post!
PositionsAccount would only be modified for trades submitted to the account live. Submitting an order during historical processing will change the strategy's position and will not change the account position.
You can use the Position object instead of PositionsAccount which will reflect the strategy position and the strategy position will change with each historical or realtime trade that is placed.
If you want the strategy to ignore creating a historical position, you can ignore historical processing with if (State == State.Historical) return;
If you want to have the strategy inherit the account position, you can follow the example attached which uses the Unmanaged Approach.
More information on Strategy vs. Account position and start behaviors are included below.
Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm
Start Behaviors — https://ninjatrader.com/support/help..._positions.htm
If this does not resolve your inquiry, could you elaborate on what you would like the strategy to do with historical and realtime processing?
We look forward to assisting.Attached Files
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
43 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
29 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
46 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
38 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment