NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-21-2009, 11:52 AM   #1
gg80108
Senior Member
 
Join Date: Dec 2008
Location: Castle Pines, Co
Posts: 621
Thanks: 1
Thanked 2 times in 2 posts
Default Performance.AllTrades. class

Is there any reference as to the options available for the Performance.AllTrades. class?? I'm interested in how to calculate the "Realized" and "Unrealized" that shows on the strategy tab..
I do have the samplePNL script which has good stuff, but cant seem to calculate the above mentioned.
i also checked lot http://www.ninjatrader-support.com/H...ollectionClass but kinda slim on whats available
Last edited by gg80108; 04-21-2009 at 11:55 AM.
gg80108 is offline  
Reply With Quote
Old 04-21-2009, 11:59 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Trades class shows you end of trade results where you can aggregate to get Realized PnL. http://www.ninjatrader-support.com/H...nceValuesClass

For Unrealized PnL you need to use this: http://www.ninjatrader-support.com/H...?GetProfitLoss
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-23-2009, 09:24 PM   #3
BradB
Senior Member
 
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
Default

Is there anyway to get Unrealized PnL intrabar? I'm running it " Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) " in "OnMarketData" with a Print and it doesn appear to be updating until endofbar. Thx.
BradB is offline  
Reply With Quote
Old 04-24-2009, 07:30 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

BradB,

If you run your strategy CalculateOnBarClose = false you should get it updated every single tick.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-24-2009, 07:54 AM   #5
BradB
Senior Member
 
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
Default

Yeah Josh, that's what I'm doing now. I didn't want my order routing firing off orders every new tick update, but I got around that. Sorry for not explaining myself very well.

Thx.
BradB is offline  
Reply With Quote
Old 04-24-2009, 01:14 PM   #6
BradB
Senior Member
 
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
Default

Ok, I guess I'm back to the original question. If I use CalculateOnBarClose = false it throws of my evaluation criteria, such as a CCI zero corss that may happen numerous times intrabar. It appears I need to run this Strategy with CalculateOnBarClose = true.

That being the case, is there a way I can the Unrealized PnL intrabar? Shouldn't it work by putting it in "OnMarketData"?
BradB is offline  
Reply With Quote
Old 04-24-2009, 01:58 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

No, GetProfitLoss() is calculated based off of Close[0]. If you are only updating at the end of each bar, well, Close[0] is only updated once and as such GetProfitLoss() updates once.

Run with CalculateOnBarClose = false and then just filter parts of your code to calculate once at the end of the bar.

Code:
if (FirstTickOfBar)
{
     // Do something at the end of the bar. All bar referencing needs to be indexed back one so [0] would now be [1]. FirstTickOfBar is the same event as the closing of the prior bar.
}
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AllTrades set in OnPositionUpdate? heech Strategy Development 11 03-17-2009 12:48 PM
Performance.AllTrades.Performance Folls Strategy Development 2 07-01-2008 07:43 AM
Performance.AllTrades index ? michaelbb Strategy Development 1 06-17-2008 01:58 AM
Bug in Performance.AllTrades? trader_rick Automated Trading 4 05-16-2008 07:09 PM
Indicator Class Januson General Programming 5 06-18-2007 02:27 PM


All times are GMT -6. The time now is 01:01 PM.