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
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
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 FilesJimNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by arvidvanstaey, Today, 02:19 PM
|
4 responses
10 views
0 likes
|
Last Post Today, 04:08 PM | ||
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
56 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by jordanq2, Today, 03:10 PM
|
2 responses
8 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
47 views
0 likes
|
Last Post Today, 02:36 PM |
Comment