![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Location: Castle Pines, Co
Posts: 621
Thanks: 1
Thanked 2 times in 2 posts
|
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.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
|
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.
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
BradB,
If you run your strategy CalculateOnBarClose = false you should get it updated every single tick.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2007
Location: , ,
Posts: 180
Thanks: 0
Thanked 1 time in 1 post
|
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"? |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
}
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |