Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Target Price
Collapse
X
-
Hello,
The best way to do this will be to assign your profit target order to an IOrder object as it is being submitted. However, you will not be able to accomplish this with SetStopLoss(), which I assume you are using. If you would like to check back on the state of the order, including it's stop/limit price, then you would be better served using one of the Exit methods, which you can assign to an IOrder object, like so:
Code:Edited: #region Variables private IOrder profitTarget; private IOrder entryOrder; #endregion protected override void OnBarUpdate() { if(Close[0] > Close[1]) { entryOrder = EnterLong(); profitTarget = ExitLongLimit(Close[0] + 10 * TickSize); } Print(profitTarget.StopPrice); }Last edited by NinjaTrader_DaveI; 06-24-2015, 02:38 PM.Dave I.NinjaTrader Product Management
-
I am trying to debug a problem where the fill price is different from what I expect. To place an order I use something like:
which is followed by something like:Code:iOrderL2 = EnterLong(iQuantity1, sENTRY2L);
The price I see the order getting filled at (during market replay) is different from the value, targetPx. So, I'd like to check the profit setting of iOrderL2 before the fill.Code:SetProfitTarget(sENTRY1L, CalculationMode.Price, targetPx);
Comment
-
Hello,
Not exactly. What you are doing there is using SetStopLoss(), then checking the stop price of your entry order.
You will need to assign your stop loss to an IOrder interface, just like you are doing with your entry. However, since we cannot assign the return value of SetStopLoss() to an IOrder interface, you would need to use one of the managed Exit methods instead (one quick note -- I used ExitLongStop() in my example below, but that would result in an order rejection due to the order being placed on the wrong side of the market, so you would want to use ExitLongLimit() instead).
You can then check the limit price of that stop loss order. I've attached a working script that will show this in action, as well.Attached FilesDave I.NinjaTrader Product Management
Comment
-
You would be using ExitLongLimit() as your target in this scenario. It would break down like this:
EnterLong() -- enter a position via a market order
ExitLongLimit() -- place a pending limit order that will act as your profit target
Then, you could even do an ExitLongStop() below the market to use as a stop loss. You have to remember that profit targets and stop losses are not order types, they are simply purposes for an order. So by placing a sell limit order via ExitLongLimit(), you are setting yourself up with a profit target.Dave I.NinjaTrader Product Management
Comment
-
That should be fine in this instance. When placing stop losses and profit targets manually, it seems to be standard practice to place the entry order first.
You can find all of the properties associated with IOrder interfaces at the link below:
http://ninjatrader.com/support/helpG...t7/?iorder.htm
You can also see many real-world examples of using IOrders within the code snippets in help guide pages related to Unmanaged order-entry methods.Dave I.NinjaTrader Product Management
Comment
-
In this scenario, that is exactly what t should equal. You are trying to access the limit price of a market order (EnterLong() submits market orders), so the LimitPrice property should either be null, or be holding a 0 as a placeholder. Please see the code examples in posts # 6 and 2 of this thread, as well as the IOrder help guide page in post # 12, for more information.Originally posted by reynoldsn View PostWhen I debug this code, t=0.0 and not tgtPx - what am I doing wrong?
Code:iOrderL1 = EnterLong(iQuantity1, sENTRY1L); ExitLongLimit(tgtPx, sENTRY1L); double t = iOrderL1.LimitPrice;
Dave I.NinjaTrader Product Management
Comment
-
I tried the code found in #2:
but profitOrder is null.Code:iOrderL1 = EnterLong(iQuantity1, sENTRY1L); profitOrder = ExitLongLimit(tgtPx, sENTRY1L); double t = profitOrder.LimitPrice; //profit target?

Again, all I'm trying to do is get the profit target of an order after it's been placed.
I appreciate your patience.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
65 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
23 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
26 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
52 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment