![]() |
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: Apr 2010
Posts: 125
Thanks: 18
Thanked 3 times in 3 posts
|
I recently opened my dusty C# for Dummies book and have learned that the programming I’ve done in NT is more “procedural” in nature than “object oriented”.
(Sigh) This bothers me a bit because I thought since I have methods I have objects. That doesn’t seem to be the case… Anyway I’m going to change my code from flow chart to more OOP. I need the flexibility of being able to add new things as they come up. Also, being able to call objects as opposed to having multiple variables that do the same thing will serve me well. Anyway, I was looking for confirmation, in my indicators code I was going to create different classes for the objects I have and go from there. I quickly created a blank class and it compiled without any issues. Are people here with larger programs doing that? The indicator itself obviously will always be the main class (public class MyClass: Indicator) with OnBarUpdate being where the action is. But if we can create methods anywhere we can do the same with classes and then create objects from them? Thx Irvin https://github.com/sempf/CSharpForDummies |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Irvin,
NinjaTrader is based on the .NET framework which uses C#. You can create your own classes for use with indicators, etc. and there are many developers doing so. NinjaScript is setup as sort of a more functional / procedural programming language just for ease of use by inexperienced programmers but OOP should be supported as outlined in the .NET framework. You just need to keep track of the namespaces, etc. engineering part of NinjaTrader when you program your own classes for use in particular indicators or strategies. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service
Last edited by NinjaTrader_AdamP; 06-04-2012 at 11:23 AM.
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2010
Posts: 125
Thanks: 18
Thanked 3 times in 3 posts
|
Hi Ryan
Thanks for your reply. All my methods are in UserDefinedMethods so I will create my objects there. Btw, where is the code for NinjaTrader.Data? That is a namespace? That is where say, the code for DataSeries would be? Thx Irvin |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Irvin,
That would be a global class that would be accessible in both strategy and indicator namespaces. Please let me know if I may assist further.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Apr 2010
Posts: 125
Thanks: 18
Thanked 3 times in 3 posts
|
Quote:
I thought you could only have code in UserDefinedMethods for indicators and then use the UserDefinedMethods for strategies? Currently I copy my code from indicators UserDefined to strategies userdefined... |
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Irvin,
Apologies, I misunderstood. The NinjaTrader.Data is accessible in both namespaces, however isn't exposed for editing/viewing. The My Documents / NinjaTrader 7 / bin / custom / indicator and strategy directories each have their own UserDefinedMethods.cs you can use for each respectively.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Senior Member
|
Quote:
NT seems to be using the now generally accepted standard convention of one class per file, thereby turning each file itself in effect into an object. The code in the object, consisting of methods, variables and other objects will itself be procedural. OOP refers to how the data structures are closely entwined with the code for manipulating said data. OOP is not a reference to a coding style totally devoid of procedural elements. Indeed, it is actually impossible to write such code, because the internal methods of the classes must necessarily be procedural. Just my $0.02.
Last edited by koganam; 06-05-2012 at 10:34 AM.
Reason: Corrected spelling
|
|
|
|
|
|
The following user says thank you to koganam for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Best practice for programming efficient indicators for the NT Strategy Analyzer? | poseidon_sthlm | Indicator Development | 12 | 01-24-2013 03:00 AM |
| Visual Programming Plugin for NT - Seeking beta testers | Jeremytang | NinjaScript File Sharing Discussion | 0 | 02-24-2012 08:38 AM |
| Porting StrategyDesk Programming Code to NT | borland | General Programming | 3 | 09-20-2009 02:49 PM |
| NT object model | astrolobe | General Programming | 1 | 04-01-2009 07:58 AM |
| Need Help Programming Custom Indicator from TS to NT | stevestrading | Indicator Development | 4 | 06-20-2007 04:31 PM |