I use IsAdoptAccountPositionAware and AdoptAccountPosition. Imagine the strategy position is 8 and account position is 8. Now I place an order manually, so the strategy position is 8 and account position is 9. I can detect that by comparing PositionAccount and Position but I don't know how to force the strategy to adopt this new position without restarting it.
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
How to re-adapot strategy position at run time
Collapse
X
-
How to re-adapot strategy position at run time
I need to re-adopt position my strategy to current AccountPosition without restarting the strategy.
I use IsAdoptAccountPositionAware and AdoptAccountPosition. Imagine the strategy position is 8 and account position is 8. Now I place an order manually, so the strategy position is 8 and account position is 9. I can detect that by comparing PositionAccount and Position but I don't know how to force the strategy to adopt this new position without restarting it.
Tags: None
-
Hello ManTrader,
Thank you for your post.
AdoptAccountPosition will only come into play when a strategy is started.
However, in NinjaTrader 8, you can use the AddOn Framework and create a NinjaScript that:- Loops through the Account.Orders collection for the account to find active orders
- Subscribes to Account OrderUpdate events to look for any newly opened orders.
- Tracks these Orders in the script so they can be changed or cancelled with Account.Change or Account.Cancel
AddOn Development: https://ninjatrader.com/support/help...t_overview.htm
Order object - https://ninjatrader.com/support/help...n-us/order.htm
Account.Orders - https://ninjatrader.com/support/help...rs_account.htm
Account.OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm
Account.Change - https://ninjatrader.com/support/help...-us/change.htm
Account.Cancel - https://ninjatrader.com/support/help...-us/cancel.htm
Please let me know if I can be of further assistance.Kate W.NinjaTrader Customer Service
-
Hello ManTrader,
Thank you for your reply.
NinjaScript Strategies are not able to see trades that are placed manually or from another instance of a strategy - the above will only allow you to monitor and cancel externally placed but unfilled orders placed to the account, but you would not be able to close a filled order using ExitLong().
Strategies have their own internal position and are only able to see orders placed through the strategy.
I recommend you have the strategy add a button and when the button is pressed, submit the "manual" entry order from from the strategy itself.
Below is a publicly available link to an example.
You could also use the Addon approach to detect changes to the account and drop using a NinjaScript strategy at all.
Last, here is a link that details strategy position vs account position.
https://ninjatrader.com/support/foru...199#post517199
And publicly available links to the help guide on the Addon approach.
https://ninjatrader.com/support/help...ount_class.htm
https://ninjatrader.com/support/help...rderupdate.htm
https://ninjatrader.com/support/help...tionupdate.htm
https://ninjatrader.com/support/help...-us/submit.htm
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by samish18, 04-17-2024, 08:57 AM
|
17 responses
64 views
0 likes
|
Last Post Today, 07:51 AM | ||
Started by rocketman7, Today, 02:12 AM
|
2 responses
17 views
0 likes
|
Last Post
by rocketman7
Today, 07:45 AM
|
||
Started by briansaul, Today, 05:31 AM
|
1 response
13 views
0 likes
|
Last Post Today, 07:36 AM | ||
Started by PaulMohn, Today, 03:49 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:36 AM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
6 responses
106 views
1 like
|
Last Post Today, 07:21 AM |
Comment