And by the way, I think I will be using OnExecution() instead of OnOrderUpdate() -- it seems to be more efficient since it's only called when the orders are filled and that's all I need.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stop a strategy if profit goal reached?
Collapse
X
-
Sorry guys to keep beating on this dead horse, but I have another question about the CumProfit property. What I really need, instead of the cumulated profit amount (now that I'm storing that myself in an external file) is the immediate PnL for just the one order that's being filled in OnOrderUpdate(). Which property holds this information for that order... something like Position.GetProfitLoss?
And by the way, I think I will be using OnExecution() instead of OnOrderUpdate() -- it seems to be more efficient since it's only called when the orders are filled and that's all I need.
-
Yup, that did it. I created a variable prevCumProfit and just subtract that from the CumProfit property and there you have it. Geez... I should frame this strategy, I've spent a lot of time on it! It better make me some money.Originally posted by NinjaTrader_Ray View PostYou would likely need to play around with the "Performance" property, possibly hold the prior profit in a variable, get the new one and check the difference. See Help Guide. You will have to play around to see how it works.
Comment
-
Still working on this strategy. Here's an issue I came up with... maybe you can help me figure it out.
When I capture market data and replay it to forward-test my strategy, it seems the Swing(5) indicator is different between the replay and the live realtime market. So the same strategy executes differently when played with the live market vs. the replay.
How can I get the market replay Swing indicator to match what happened while the market replay was recording?
Comment
-
Well, the data for replay is captured at the same time the live data is happening, right? So the two should be in sync. I usually connect to my provider around 9:15ET or so every day.Originally posted by NinjaTrader_Ray View PostMake sure that you have enough historical data prior to the replay date so that the swing points are correctly calculated.
One thing about Swing though.... when there is a break in connection (like when I shut off the computer for the night), are 'yesterdays' bars combined with today's to create the first Swing pivots of the day? That seems like it would not be accurate to do it that way. It should really start at whatever the first bar of the current day is and work from there.
Comment
-
Is this possible in NinjaTrader 7? The reply two years ago to this post was that it wasn't possible, I'm wondering if it now can be done.Originally posted by cassb View Post(..)
What if I want to know the TOTAL PnL for all instruments and strategies in a given trading period/day? I want to stop trading if ALL of my strategies/instruments running add up to a total profit/loss value. Is that possible?
Comment
-
Hi, kinda new here with an old thread... I have the SamplePnL strategy running and it's not executing at all, I'm at a loss...
I have other strategies running fine - the reason I am at this thread now is that I added the performance object to a strategy that I coded and it stopped working, so I began searching for an answer and found this thread, but as stated before, the SamplePnL is not executing - I just opened CL 09-10 today, so there's only one trade with a small profit that I entered manually via order on the control center as a test... any ideas, suggestions?
Comment
-
Hello pepereal4,
Welcome to the NinjaTrader forums!
The SamplePNL strategy cannot read pnl data from trades placed outside of the strategy instance that it was applied to. Your manual trade cannot be read from this strategy.
Share some of the code you're using, let us know what you expect it to do, and we can take a closer look.Ryan M.NinjaTrader Customer Service
Comment
-
Yes, I understand that, I was checking to see if any order could be placed at all - I was also explaining that the SamplePnL strategy was under the profit/loss/10 trade limits.
I'm trying to run the SamplPnL strategy as posted and it is not executing at all - any ideas?
NOTE: SamplePnL running on CL 09-10 1 min bars, but not executing... plenty of movement to make 10 trades, $400 loss or $1000 profit...Last edited by pepereal4; 07-20-2010, 12:31 PM.
Comment
-
While waiting for a reply I keep thinking, so here's my next question...
The SamplePnL code reads like this:
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// At the start of a new session
if (Bars.FirstBarOfSession)
{
// Store the strategy's prior cumulated realized profit and number of trades
priorTradesCount = Performance.AllTrades.Count;
priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit;
....
But if we are at the beggining of the session, is it not true that Performance.AllTrades.Count = 0 ? And thus "Performance.AllTrades.TradesPerformance.Currency. CumProfit = 0 ?
If so, why do we need to store these values on a "prior" variable ?
If not, what am I missing here ?
Tks
Comment
-
The only entry condition for this strategy is pretty simple and should happen frequently enough on 1 minute bars.
if (Close[0] > Close[1])
{
EnterLong();
}
If you're not seeing entries, you should add TraceOrders = true to your initialize method and view output for this through Tools > Output window.
If you think it's not taking trades as a result of the performance class, use Print() statements to verify the values are what you expect.
Additional NinjaScript debugging help is available here.Ryan M.NinjaTrader Customer Service
Comment
-
Our replies crossed. Regarding your latest post:
The value is captured at the start of the day so that you can later subtract the total from this captured value. This tell you what has been going on for the day-in-progress.
Code:Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit = Your session CumProfit.
Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 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
576 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