NexusFi: Find Your Edge


Home Menu

 





PnL Question


Discussion in NinjaTrader

Updated
    1. trending_up 1,720 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,098

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?
Datafeed for Atas
Platforms and Indicators
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
Thanks Mike. Godspeed.
The Elite Circle
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
BERN ALGOS algo trading journal
1 thanks
Afternoon-close session
1 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