Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Matching multiple unmanaged entry orders with their corresponding exit orders
Collapse
X
-
Matching multiple unmanaged entry orders with their corresponding exit orders
I have a strategy that may create more than one entry order at a time. When an entry order fills... how can I create exit orders that are related to that particular entry order. The reason is that I would like the profit and loss lines (and statistics) to reflect each position appropriately.Tags: None
-
Hello BrianARice,
This would need to be done with logic when using the unmanaged approach.
Orders are first in first out.
To provide an idea, your logic could track if an <order>.Name has filled in an entry and set a value to a variable to know this order makes up some of the position. Then you could check that variable to see that value and place an exit order and then remove that value from the variable.Chelsea B.NinjaTrader Customer Service
-
Right... but there is no way to get the profit and loss lines to match up with the proper entry and exit orders on a chart then?
Comment
-
Hi, are there any update in this topic? Is there a way to close the order we need in an unmanaged method? Also, Can you please tell me, I found a method in StrategyBase class
[MethodImpl( MethodImplOptions.NoInlining )
private Order SubmitOrderNow( int selectedBarsInProgress, bool isLiveUntilCancelled, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal, string oco, bool isSimulatedStop )
{
return null;
}
This looks like what I'm looking for, this method has a string argument fromEntrySignal that would help me close the open position I want.Last edited by AdvancedSoftwareFeatures; 04-01-2023, 03:36 AM.
Comment
-
Originally posted by BrianARice View PostI have a strategy that may create more than one entry order at a time. When an entry order fills... how can I create exit orders that are related to that particular entry order. The reason is that I would like the profit and loss lines (and statistics) to reflect each position appropriately.
For entry orders, I use a simple naming scheme. I typically use names that start with a prefix
of 'L' or 'S' (to indicate a Long or Short) followed by a counter, such as CurrentBar.
For example,
L3267 <-- Long entry order at bar 3267
When the entry order fills, I submit matching exit orders (aka, the stop loss and profit target orders)
using the entry order's signalName, but add a suffix, like this,
L3267stp <-- stop loss order
L3267tgt <-- profit target order
If the entry order had Quantity > 1, then the strategy might submit multiple profit target orders, in
which case I numbered them,
L3267stp <-- stop loss order (always the same)
L3267tg1 <-- 1st profit target
L3267tg2 <-- 2nd profit target
...
L3267tg6 <-- 6th profit target (as needed)
The strategy should create the exit orders inside OnOrderUpdate or OnExecutionUpfdate, when
the entry order L3267 state has changed to Filled (or PartFilled).
Is this kind of naming convention what you're talking about?Last edited by bltdavid; 04-01-2023, 07:27 PM.
Comment
-
Originally posted by AdvancedSoftwareFeatures View PostHi, are there any update in this topic? Is there a way to close the order we need in an unmanaged method? Also, Can you please tell me, I found a method in StrategyBase class
[MethodImpl( MethodImplOptions.NoInlining )
private Order SubmitOrderNow( int selectedBarsInProgress, bool isLiveUntilCancelled, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal, string oco, bool isSimulatedStop )
{
return null;
}
This looks like what I'm looking for, this method has a string argument fromEntrySignal that would help me close the open position I want.
Comment
-
Hello bltdavid,
There is no fromEntrySignal when using the unmanaged approach. In the managed approach, using the fromEntrySignal in an exit will attach the exit order to the signalName of a specific entry order. This will be use used for the pairing of the orders in the performance window. The unmanaged approach does not have this ability to attach exits to specific entries. The matching in the performance window will be purely first in first out. This means the developer would have to make their own report that matches these differently based on signal names and not based on first in first out.
AdvancedSoftwareFeatures,
You can assign orders to variables in OnOrderUpdate() and know which orders are still working and which orders have filled and add up the quantities. When an entry order fills, you can submit a specific exit order with the quantity of that entry.
You also have access the Position.MarketPosition and Position.Quantity, which update when the position changes in OnPositionUpdate().Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello bltdavid,
There is no fromEntrySignal when using the unmanaged approach. In the managed approach, using the fromEntrySignal in an exit will attach the exit order to the signalName of a specific entry order. This will be use used for the pairing of the orders in the performance window. The unmanaged approach does not have this ability to attach exits to specific entries. The matching in the performance window will be purely first in first out. This means the developer would have to make their own report that matches these differently based on signal names and not based on first in first out.
AdvancedSoftwareFeatures,
You can assign orders to variables in OnOrderUpdate() and know which orders are still working and which orders have filled and add up the quantities. When an entry order fills, you can submit a specific exit order with the quantity of that entry.
You also have access the Position.MarketPosition and Position.Quantity, which update when the position changes in OnPositionUpdate().
Comment
-
AdvancedSoftwareFeatures The SubmitOrderUnmanaged() method allows specification of a signalName ("A string representing the name of the order. Max 50 characters.").
By tracking individual Orders as recommended by NinjaTrader_ChelseaB with signal names, and using a naming convention for your Orders that allows you to distinguish each one and know it as an entry or exit Order, you should be able to manage this quite well.
Thanks.
Comment
-
Originally posted by jeronymite View PostAdvancedSoftwareFeatures The SubmitOrderUnmanaged() method allows specification of a signalName ("A string representing the name of the order. Max 50 characters.").
By tracking individual Orders as recommended by NinjaTrader_ChelseaB with signal names, and using a naming convention for your Orders that allows you to distinguish each one and know it as an entry or exit Order, you should be able to manage this quite well.
Thanks.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DeskTroll, Today, 12:09 PM
|
3 responses
22 views
0 likes
|
Last Post Today, 03:52 PM | ||
Started by Pabulon, 12-02-2024, 03:42 PM
|
14 responses
90 views
0 likes
|
Last Post
by Pabulon
Today, 03:36 PM
|
||
Started by tfa2806trader, Today, 12:04 PM
|
10 responses
25 views
0 likes
|
Last Post Today, 03:32 PM | ||
Started by trdninstyle, 11-26-2024, 12:23 PM
|
62 responses
186 views
0 likes
|
Last Post
by trdninstyle
Today, 03:24 PM
|
||
Started by lorien, 08-08-2021, 07:33 AM
|
12 responses
721 views
0 likes
|
Last Post
by AndyM871
Today, 02:45 PM
|
Comment