NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 07-03-2012, 10:35 AM   #1
figoliuxi
Junior Member
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default Strategy depends on last few trades PnL

Hi guys,

I am constructing a strategy based on my trading PnL. Do you have any idea on how to code it in NinjaTrader? I would like to know the number of my last recent five trades' win/loss. And to make that number as another indicator to trade in the future. I've tried to use performance class. But it is cumulatively calculated, which means if I did not trade in last few bars, it still gives me a positive/negative profit. Do you have any idea on how to calculating the real profit each trade gives me?

Thanks!
figoliuxi is offline  
Reply With Quote
Old 07-03-2012, 10:41 AM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

figoliuxi,

Welcome to the forum!

You could keep track of this yourself in some sort of data structure or the built in data series.

In other words, when you detect an order has closed calculate PnL and store it somewhere.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-03-2012, 04:28 PM   #3
figoliuxi
Junior Member
 
Join Date: Jul 2012
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks AdamP.
Yeah, I agree with your opinion. But can you show me some sample codes/or method in NinjaTrader on calculate each trade's PnL and store it in a data series. The performance method seems give me cumulative PnL. Is there a way to reset the PnL to 0 each time I store a value?

Thanks
figoliuxi is offline  
Reply With Quote
Old 07-05-2012, 04:41 AM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello figoliuxi,
You can use the trade collection to get the PnL of the trades.

Please refer here to know more
http://www.ninjatrader.com/support/h...collection.htm
http://www.ninjatrader.com/support/h...?gettrades.htm
NinjaTrader_Joydeep 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
Strategy PNL SMuhr Strategy Development 8 02-20-2012 02:08 PM
trades outside time range and outside PNL range SammyC Strategy Analyzer 1 02-02-2011 06:29 AM
Help: Bar height depends on bar width? motownlucas Charting 8 01-11-2011 08:23 AM
Multi-instrument strategy PnL jp_kettunen Miscellaneous Support 5 03-18-2010 09:46 AM
Backtesting w/ PnL Strategy Halt insomniac Strategy Development 3 03-31-2008 12:04 PM


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