Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stop a strategy if profit goal reached?
Collapse
X
-
You might consider managing your own stop/targets if you need that level of control: http://www.ninjatrader-support.com/v...ead.php?t=3917
Comment
-
No, I am already managing my stoploss and profit targets with I just need to know what call or function executes when an order hits a profit target or stoploss -- or otherwise when a working order is closed and the CumProfit property changes. That's when I will open my output file and update my external profit accumulator value.
Comment
-
OK, that's not going to work. Then what I'll do is create a double variable that will hold the last Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit value. Whenever that value changes in OnOrderUpdate, I'll call my code to open and write to the output file.
Thanks,
Bryan
Comment
-
Yes, you are correct.
And what is the order state for when a filled/working order has been closed? I have these to pick from:
OrderState.Accepted Order has been acknowledged by the broker
OrderState.Cancelled Order has been cancelled
OrderState.Filled Order has been filled
OrderState.PartFilled Order has been part filled
OrderState.PendingCancel An order cancellation request has been submitted
OrderState.PendingChange An order change request has been submitted
OrderState.PendingSubmit An order has been submitted
OrderState.Rejected An order has been rejected
OrderState.Working An order is working at the exchange
OrderState.Unknown An unknown order state
Comment
-
Oh OK... I thought "filled" meant when an order is accepted by the broker and becomes 'active' or 'working.' So "filled" is a terminal state of an order that is no longer active any more?
What is the state of a stop or limit order when it's no longer pending but becomes an active order then?
Comment
-
Hey, just wanted to let people know if they are following this thread...
Now I understand where to catch my orders so I can update the daily PnL. In OnOrderUpdate(), there are several 'orders' that are filled with one position. When you enter a new limit or stop position, that order is "filled" when it becomes an active order (I assume new market orders are always "filled" right away).
Then, if you have a SetProfitTarget and/or SetStopLoss defined in your Initialize() tag, one or two new limit/stop orders are entered automatically. It's these orders being 'filled' (not the original position) that I wanted to capture. So in my OnOrderUpdate() tag, I need to look at order.Name for either "Profit target" or "Stop loss" to know when a position is actually being closed. I didn't realize I needed to ignore the order.Name of the original order (which I called "EnterLong" or "EnterShort" in my case).
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
673 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
577 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment