PnL Question - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

PnL Question
Started:October 28th, 2013 (11:27 AM) by SodyTexas Views / Replies:424 / 1
Last Reply:October 28th, 2013 (11:27 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

PnL Question

Old October 28th, 2013, 11:27 AM   #1 (permalink)
Spread Trader
Austin TX
Futures Experience: Advanced
Platform: Ninjatrader, Python, & R
Broker/Data: RJO
Favorite Futures: Futures, Spreads
SodyTexas's Avatar
Posts: 311 since Sep 2013
Thanks: 96 given, 813 received

PnL Question

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:

#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!!!



Reply With Quote

Old October 28th, 2013, 11:27 AM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > PnL Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Commissions Not Posting to PnL tderrick NinjaTrader 5 December 9th, 2012 02:17 AM
NINJA TRADER HELP PnL PATaMAT NinjaTrader 0 November 14th, 2012 11:43 AM
Displaying net PNL patbateman NinjaTrader 0 September 30th, 2012 08:02 PM
PnL not updating when flat stephenszpak NinjaTrader 18 January 8th, 2012 11:33 PM
Daily PnL andy335 NinjaTrader Programming 2 November 9th, 2010 08:39 AM

All times are GMT -4. The time now is 09:31 PM.

Copyright © 2016 by 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.
no new posts

Page generated 2016-10-22 in 0.07 seconds with 19 queries on phoenix via your IP