How can I do this ?
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
Getting active orders from account
Collapse
X
-
Getting active orders from account
I want to check whether there is an active order (long position) for a certain instrument (stock) in my account. Then I want to close this order at some time of day. The order was submitted a few days ago, so I eventually don't have any order object when the strategy restarts overnight. I'm not sure what the "StartBehaviour" options actually mean, so I think setting it to "StartBehavior.WaitUntilFlat" and getting the positions from the account is the most safe/reliable way.
How can I do this ?
Tags: None
-
Hello Derjan,
I wanted to clarify as you mentioned a long position, are you referring to an order which makes a long position or a long order or are you referring to a position which already exists or a long position? If we are referring to an open order and not a position the start behavior would be best to use for resuming the order.
The start behavior can be used to resume a positions/orders but that requires that the strategy re calculates that it made this position/order when you re enable it. If your strategy cannot re create this position/order again when it runs through the historical data it would not be able to easily resume it.
To better understand how the start behavior works I would suggest reading the following resources:
If your logic can re evaluate this position/order in historical you could likely use Immediately submit, synchronize account. Please review the details of this behavior to understand how this manages your position in contrast to the strategy.
If the start behavior is not going to be an option based on the logic used you could look into manually syncing with the account position by waiting until realtime and then observing the account position directly: https://ninjatrader.com/support/help...ionaccount.htm
Orders are not as easily observed when submitted from the strategy. The previous order would no longer be available in the strategies overrides or collections, for this task you would need to use the Addon methods to access an account and its orders collection directly. I do not recommend doing this, I would highly suggest trying to make your logic work with one of the start behaviors to correctly resume the order.
I look forward to being of further assistance.
JesseNinjaTrader Customer Service
-
Hi
On one account I have a Long (or short) position generated with a manual order and I also have two other orders ("Target1" and "Stop1") automatically generated ("Custom - 1"). I would like to see these orders in my strategy that did not generate them.
The strategy is activated after the position and orders have been generated.
PS: I use Unmanaged Approach
Thanka Alberto
Comment
-
Hello Apo84,
If you are trying to manage the orders with a second strategy that wont work. You need to use an indicator for that type of goal and not a strategy. The managed/unmanaged approach for strategies are only intended for a strategy that manages its own orders, not manually placed orders.
From an indicator you could use the addon framework to monitor an account and its orders or do other actions like closing open orders.
The reason an indicator should be used is that manual orders do not affect a strategies performance values, position information or other strategy based properties so those values would be inaccurate in the strategy if you start managing orders that were manually placed. An indicator is a much better location to use the addon framework account code so that there are no misunderstandings. All of the strategy based methods and properties are not avaliable in an indicator which makes it much easier to see what code is actually needed to help manage the manually placed orders.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
53 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
33 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
5 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment