NexusFi: Find Your Edge


Home Menu

 





PnL Question


Discussion in NinjaTrader

Updated
    1. trending_up 1,593 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
SodyTexas's Avatar
 SodyTexas 
Austin TX
 
Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker: RJO
Trading: Futures, Spreads
Posts: 424 since Sep 2013
Thanks Given: 118
Thanks Received: 1,097

I'm Stumped,

What I am trying to do is store PnL in a DataSeries per trade (not per lot). For example, if I buy three contracts and it fills in two lots when closing the position. I want the PnL on the three contracts, not on a lot basis. The reasoning behind this is I want to avoid risk of ruin by controlling position sizing by PnL.

What I have so far:

 
Code
  
#region Variables
private DataSeries PnL;

protected override void Initialize()
{
PnL = new DataSeries(this);
}

protected override void OnBarUpdate()
{
//No PnL information in this 
}

protected override void OnExecution(IExecution execution)
{
if (Performance.RealtimeTrades.Count > 0)
{
	// Get the last completed real-time trade (at index 0)
Trade Trade1 = Performance.RealtimeTrades[Performance.RealtimeTrades.Count - 1];
				
	// Calculate the PnL for the last completed real-time trade
double lastProfit = Trade1.ProfitCurrency * Trade1.Quantity;

if(lastProfit != PnL[1]) {PnL[0] = lastProfit; Print("PnL " +PnL[0]);}
Print("The last trade's profit is " + lastProfit);
The problem is it is returning the PnL for each lot, which will not benefit me in my position sizing calculation. Any thoughts on a work around.

P.S. - new to the Elite crowd, and very happy that I purchased the membership. If you have not done so and are thinking about it... DO IT!!!

Cheers,

SodyTexas


Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
The 50/50 Paradox: Peace and Invasion Each at 20% -- Ira …
Prediction Markets & Event Contracts
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
TradingView Opens Volume Footprint Data to Pine Script - …
TradingView
The Backwardation Signal: How the CL Futures Curve Tells …
Commodities
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks




Last Updated on October 28, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts