NexusFi: Find Your Edge


Home Menu

 





PnL Question


Discussion in NinjaTrader

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




 
Search this Thread

PnL Question

  #1 (permalink)
 
SodyTexas's Avatar
 SodyTexas 
Austin TX
 
Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker: RJO
Trading: Futures, Spreads
Posts: 421 since Sep 2013
Thanks Given: 117
Thanks Received: 1,085

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?
Better Renko Gaps
The Elite Circle
Increase in trading performance by 75%
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Diary of a simple price action trader
26 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
9 thanks




Last Updated on October 28, 2013


© 2024 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 - Privacy Policy - Downloads - Top
no new posts