NinjaTrader Support Forum  

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

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 11-30-2011, 01:18 AM   #1
alex.nt
Senior Member
 
Join Date: Nov 2011
Posts: 143
Thanks: 41
Thanked 3 times in 3 posts
Default Can a strategy or indicator have more than a single source file?

Sorry, probably this question is already answered but I could found it through the search.

Is it possible to have multiple sources for a strategy/indicator?

Thank you.
alex.nt is offline  
Reply With Quote
Old 11-30-2011, 02:10 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Hi Alex, what would you mean please by mutiple sources? Do you mean data series / instruments?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-30-2011, 02:19 AM   #3
alex.nt
Senior Member
 
Join Date: Nov 2011
Posts: 143
Thanks: 41
Thanked 3 times in 3 posts
Default

Hi Bertrand,

No, I mean multiple cs files. For instance, to use partial class definition or even different classes, because sometimes strategies get quite big for a single source file.
alex.nt is offline  
Reply With Quote
Old 11-30-2011, 02:26 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

I see, strategies could not call other strategies, but you could call for example methods from UserDefinedMethods.cs or other indicators of course.
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 11-30-2011, 02:55 AM   #5
alex.nt
Senior Member
 
Join Date: Nov 2011
Posts: 143
Thanks: 41
Thanked 3 times in 3 posts
Default

Can I use partial class definition for an indicator/strategy? Can I use a non-indicator class from within a separate cs file?

I mean, there must be ways to split the code of an indicator/strategy into several files.
alex.nt is offline  
Reply With Quote
Old 11-30-2011, 03:45 AM   #6
bukkan
Senior Member
 
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
Default

Quote:
Originally Posted by alex.nt View Post
Can I use partial class definition for an indicator/strategy? Can I use a non-indicator class from within a separate cs file?

I mean, there must be ways to split the code of an indicator/strategy into several files.
ninjascript is all C#. just create your custom namespace and do whatever you like. Strategies/Indicators are partial class by itself (see UerDefinedMethod.cs file).
bukkan is offline  
Reply With Quote
Old 11-30-2011, 03:58 AM   #7
zweistein
Senior Member
 
Join Date: Jan 2009
Posts: 584
Thanks: 2
Thanked 21 times in 12 posts
Default

yes you can use multiple C# files and partial classes.

Only limitation are Indicator derived classes. For these Ninja generates a custom script a the bottom of the file. Having 2 source code files for the same indicator derived class will probably mess that mechanism up. But try it, as you will see errors at compile time.

Andreas

www.zweisteintrading.eu
zweistein is offline  
Reply With Quote
Old 11-30-2011, 04:11 AM   #8
alex.nt
Senior Member
 
Join Date: Nov 2011
Posts: 143
Thanks: 41
Thanked 3 times in 3 posts
Default

I guess a little example would be helpful. I will try to split the code into different cs-files and hopefullt report the results here.
alex.nt 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
How to protect your source file richard Indicator Development 9 07-23-2012 11:33 PM
Two source of input for 1 indicator Oil_Trader Automated Trading 1 08-19-2010 06:13 PM
where is the ninja source file for debugging junkone Miscellaneous Support 5 08-22-2009 11:40 PM
Possible to have one source file include multiple indicators DancesWithBears Indicator Development 1 07-28-2009 04:03 AM
Indicator: Using System.IO File properties to write to and read from a text file NinjaTrader_Josh Reference Samples 0 09-30-2007 10:48 PM


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