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 > Strategy Development

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

Reply
 
Thread Tools Display Modes
Old 03-24-2009, 09:21 AM   #1
tjendra
Senior Member
 
Join Date: Mar 2009
Posts: 220
Thanks: 0
Thanked 0 times in 0 posts
Default Total Net Profit != Cumulative Profit?

I was trying to keep track of my profits during backtesting, however when I check my the Total Net Profit in the Strategy Analyzer Summary, it is not the same value as the Cumulative Profit which I printed using
Print(
"Cum Profit:" +Performance.AllTrades.TradesPerformance.Currency. CumProfit);
Why is that so?
tjendra is offline  
Reply With Quote
Old 03-24-2009, 09:25 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

Please ensure you are printing it at the correct time and that you have Strategy Analyzer set to currency.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-24-2009, 09:29 AM   #3
tjendra
Senior Member
 
Join Date: Mar 2009
Posts: 220
Thanks: 0
Thanked 0 times in 0 posts
Default

How do I set the Strategy Analyzer to currency? I put the print code on the first line of OnBarUpdate(), would that be a problem? I only check that the final values are different. Therefore shouldn't be a problem of printing at the wrong timing?
tjendra is offline  
Reply With Quote
Old 03-24-2009, 09:32 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

tjendra,

You may be missing the final Exit on Close order as the backtest finishes and closes out any remaining position at that point in time. I suggest you print out Position.MarketPosition to confirm/deny this. If your final CumProfit print is from an active long/short position then you know you are missing that final closing trade in your stats.

You can change the presentation method of the Strategy Analyzer in the top toolbar. There should be a drop down menu where you can select Currency.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-24-2009, 09:45 AM   #5
tjendra
Senior Member
 
Join Date: Mar 2009
Posts: 220
Thanks: 0
Thanked 0 times in 0 posts
Default

My final market position is Long. How do I make it flat so the calculation is correct?
tjendra is offline  
Reply With Quote
Old 03-24-2009, 09:50 AM   #6
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

tjendra,

You would not be able to unless you tell it to place an explicit exit before close. Whatever logic you use to place this exit will not necessarily be an exit you would like in your strategy code though.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-13-2011, 11:51 PM   #7
luxurious_04
Senior Member
 
Join Date: Jul 2010
Location: Philippines
Posts: 248
Thanks: 7
Thanked 6 times in 4 posts
Send a message via Skype™ to luxurious_04
Default

Hello Josh, I used Print("Average cumulative profit of all trades is: " + Performance.AllTrades.TradesPerformance.Currency.C umProfit); but it prints nothing even if there is already a trade in the Account Performance Tab. The value is always zero. I don't understand why. I am using a market replay to test my strategies. I already set the accounts to replay and correct chart, templates and the providers. When I generate it, it does many trades but still the in the output window is zero. Please help me on this.
luxurious_04 is offline  
Reply With Quote
Old 02-14-2011, 03:21 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

luxurious_04, are you using NinjaScript strategies that call ATM's here in your testing?

http://www.ninjatrader.com/support/f...ad.php?t=19148
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-14-2011, 06:20 PM   #9
luxurious_04
Senior Member
 
Join Date: Jul 2010
Location: Philippines
Posts: 248
Thanks: 7
Thanked 6 times in 4 posts
Send a message via Skype™ to luxurious_04
Default

Yes I am using ATM templates but there is a line on the link that you give that says " Accessing all the trade data is still possible, but the set of commands to use differ from the traditional NinjaScript commands.". Now, if it still possible to access all the trade data then what would be other set of commands to use? Because I really want to access all the trade data as a trade filter to my strategy. Please give me tip or a sample code for it. It must be easy if I have a code just like the function of CLOSE button in the DOM. Just the code for disabling automatically the strategies running. If you can give me a tip or a HOT KEY for that one then it would be great. I hope.
Last edited by luxurious_04; 02-14-2011 at 06:37 PM.
luxurious_04 is offline  
Reply With Quote
Old 02-15-2011, 08:10 AM   #10
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

luxurious_04,

When working with ATM strategies in NinjaScript you would want to use this subset of methods: http://www.ninjatrader.com/support/h...gy_methods.htm

To close out of your ATM strategy you could use this method: http://www.ninjatrader.com/support/h...ategyclose.htm

For a hot key to disable strategies, there is none per se, but you can setup in the Hot Key Manager under the Globals section one for "Flatten Everything" which will stop your strategies.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-15-2011, 07:58 PM   #11
luxurious_04
Senior Member
 
Join Date: Jul 2010
Location: Philippines
Posts: 248
Thanks: 7
Thanked 6 times in 4 posts
Send a message via Skype™ to luxurious_04
Default

Flatten Everything can stop my strategies. But in the next signal it will take an order again. Is it? Anyway, please give me a sample Ninja code to automatically trigger my hot key for Flatten Everything. Thanks.
luxurious_04 is offline  
Reply With Quote
Old 02-16-2011, 01:01 AM   #12
luxurious_04
Senior Member
 
Join Date: Jul 2010
Location: Philippines
Posts: 248
Thanks: 7
Thanked 6 times in 4 posts
Send a message via Skype™ to luxurious_04
Default

Hello, anyone could help me on this. Is there a way that strategy can access another strategy? Like for example I have two strategies then the first one have a realized profit of 1130 and the other one have 1140. Now I want the first one to access the realize profit of the second strategy and get the sum of it. Or there a way I can get the sum of this two? I have attached a sample image.
Attached Images
File Type: jpg GC.JPG (61.4 KB, 16 views)
Last edited by luxurious_04; 02-16-2011 at 01:13 AM.
luxurious_04 is offline  
Reply With Quote
Old 02-16-2011, 04:06 AM   #13
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

FlattenEverything will disable your strategy, so to have it trade again, you would need to restart it first.

A hotkey for FlattenEverything can be setup in NT7's hotkey manager - http://www.ninjatrader.com/support/h...ey_manager.htm

Unfortunately NinjaScript strategies would not cross communicate, so you could not access the PnL of strategy A in strategy B - a workaround could be using txt files to 'globally' store the values for reference.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-20-2011, 07:45 PM   #14
luxurious_04
Senior Member
 
Join Date: Jul 2010
Location: Philippines
Posts: 248
Thanks: 7
Thanked 6 times in 4 posts
Send a message via Skype™ to luxurious_04
Default

Hello Bertran, please give me a hint on how to save a value from strategy to a text file or excel and also how does strategy get or query value from a text file. By the way, is there a way to add all the value recorded in a list? How? Thank you.
luxurious_04 is offline  
Reply With Quote
Old 02-21-2011, 12:03 AM   #15
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

You can for example take a look at this reference sample - http://www.ninjatrader.com/support/f...ead.php?t=3477
NinjaTrader_Bertrand 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
summary of "strategy realized" is not equal "account performance, total net profit"" Fragolino Miscellaneous Support 1 02-19-2009 04:12 AM
Cumulated Profit vs Total Net Profit? suedeuno Strategy Development 3 01-04-2009 08:40 AM
What's the easiest way to get the current Net Profit/Gross Profit? tradefaz General Programming 2 08-25-2008 10:31 PM
Cumulative Profit Graph CraigC Automated Trading 3 06-20-2008 11:27 PM
Cumulative Profit Calculation Error whitmark Miscellaneous Support 1 03-07-2007 04:09 AM


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