Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Getting profit & loss for the day (session)
Collapse
X
-
Not working?
It doesn't seem to work in strategy analyzer. It generates 0 trades:
if (Close[0] > SMA(Open, MALen)[0]
&& Position.MarketPosition == MarketPosition.Flat
&& Performance.AllTrades.TradesPerformance.Currency.C umProfit - priorTradesCumProfit >= -500)
{
EnterLong(2, "long");
}
Any idea?
Comment
-
Hello,
Scaring me there with that screenshot and all them red bars
What code do you have for getting our of a trade if PnL is above a threshold? I see that you have code most likely correct for not taking a new one if it is above the treashold but the current trade would go to completion most likely and that may or may not put you over the threshold.
I look forward to assisting you further.BrettNinjaTrader Product Management
Comment
-
Sorry, I selected only the losers in the picture to make it more obvious to see
My code to exit is just setstoploss:
protectedoverridevoid Initialize()
{
....
SetProfitTarget("long", CalculationMode.Ticks, ProfitTarget1);
SetStopLoss("long", CalculationMode.Ticks, StopLoss, false);
SetProfitTarget("short", CalculationMode.Ticks, ProfitTarget1);
SetStopLoss("short", CalculationMode.Ticks, StopLoss, false);
Comment
-
Hello,
Most likely the code is only preventing new entires once the PnL value is violated. Any entries already put into place would still play out.
You would need code to close any open positions if then PnL value was above a threashold.
Have you added code to do this?
-BrettBrettNinjaTrader Product Management
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, Yesterday, 10:06 AM
|
0 responses
20 views
0 likes
|
Last Post
by argusthome
Yesterday, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
18 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
14 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
9 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
38 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment