NinjaTrader Support Forum  

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

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-21-2011, 07:30 AM   #1
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default Namespace problem

I have some private demo scripts, so I thought I would put them in a nested namespace of NinjaTrader.Indicator to keep them out of the the NinjaTrader.Indicator namespace.

That all works fine, except the Magic Code has hard-coded namespace stuff instead of allowing access via "using" statements.

For example, if I place my code in NinjaTrader.Indicator.Demo, it will not work because of Magic Code lines like:

Quote:
public Indicator.DemoStaticFunction DemoStaticFunction()
Note that assumes my function is in Indicator, while it really is in Indicator.Demo.

I know that for now that only answer is "Don't do that", and I won't.

I would like to ask that, for the future, the Magic Code depend on "using" statements being correct so that one can indeed use nested namespaces.

Would that case any problems?

--EV
ETFVoyageur is offline  
Reply With Quote
Old 01-21-2011, 08:12 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

I will forward to development for there consideration. Thanks for the suggestion!
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-21-2011, 08:54 AM   #3
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Further clarification here. Creating a custom namespace is not possible in NinjaScript. It is possible in C# but not NinjaScript therefor as your aware outside of our level of support we provide.
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-21-2011, 09:02 AM   #4
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

No, I was not aware that creating a nested namespace would be unsupported.

I know that everything has to be in the Indicators namespace, but it never occurred to me that did not include nested namespaces.

Thanks for the clarification -- now I know it is unsupported. Since it seems like a very reasonable thing to do, and since it seems easy to allow, I'd like to suggest that it become supported.

I'm hoping that it is as simple as taking the hard coded namespace stuff out of the Magic Code, and expecting compilation to work because of "using" lines.

--RV
ETFVoyageur is offline  
Reply With Quote
Old 01-21-2011, 09:20 AM   #5
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Thanks for suggestion!
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-21-2011, 11:13 AM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Question

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

Further clarification here. Creating a custom namespace is not possible in NinjaScript. It is possible in C# but not NinjaScript therefor as your aware outside of our level of support we provide.
Say what? Many of us have been isolating enums into newly declared namespaces for a while now, because we would rather not pollute the global namespace, and even Intellisense honors the namespaces. Did I misunderstand what you just wrote?

There are few absolutes in programming, but it is generally conceded that polluting the global namespace is bad.
koganam is offline  
Reply With Quote
Old 01-21-2011, 11:19 AM   #7
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

Quote:
Originally Posted by koganam View Post
Say what? Many of us have been isolating enums into newly declared namespaces for a while now, because we would rather not pollute the global namespace, and even Intellisense honors the namespaces. Did I misunderstand what you just wrote?

There are few absolutes in programming, but it is generally conceded that polluting the global namespace is bad.
The issue is not those separate namespaces. They work fine.

The issue is that I tried to put my demo code in a namespace that was nested under Indicator. That canot be done with the current NT, because the Magic Code has some hard-coded namespace stuff. I am requesting that they give up that hard-coded stuff and depend on having the correct "using" directives. Then we could nest namespaces under Indicator.

--EV
ETFVoyageur is offline  
Reply With Quote
Old 01-21-2011, 11:32 AM   #8
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

I was seeking to clarify NT_Brett's assertion: "... Creating a custom namespace is not possible in NinjaScript..."

That seems globally declarative to me; not just related to nested namespaces.
koganam is offline  
Reply With Quote
Old 01-21-2011, 12:05 PM   #9
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

We cannot support any custom namespace. You must use the namespace provided in NinjaScript. even though this is C# programming and you can do it. It is out of what we can support. NinjaScript is used here as a method to submit order and program a strategy in the strategy namespace. Adding custom namespaces is something that we cannot support, even though it should work if an unforeseen issue arises due to it we cannot support it.

Thank you.
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-21-2011, 12:14 PM   #10
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

We cannot support any custom namespace. You must use the namespace provided in NinjaScript. even though this is C# programming and you can do it. It is out of what we can support. NinjaScript is used here as a method to submit order and program a strategy in the strategy namespace. Adding custom namespaces is something that we cannot support, even though it should work if an unforeseen issue arises due to it we cannot support it.

Thank you.

Brett,

I take it this means today, and does not mean you will not consider my suggestion for the future. Right?

-----

As to today, there is an issue that V7 created -- where to place enums for enum parameters. What is your advice on where to place them so that they do not pollute the global namespace?

That's what some of us are using custom namespaces for. If you have a better idea, I'd be happy to take you up on it. But we do need some way to get those enums out of the global namespace. Polluting the global namespace is evil.

Thanks,
EV
ETFVoyageur is offline  
Reply With Quote
Old 01-21-2011, 01:03 PM   #11
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Enums must go in the global namespace. This is demontrated in this supported NinjaScript Sample: We do not support anything else.

http://www.ninjatrader.com/support/f...ead.php?t=3420
NinjaTrader_Brett is offline  
Reply With Quote
Old 01-21-2011, 01:14 PM   #12
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

With all due respect, when your power users point out a potential problem as large as namespace collision, and get a response delivered in the manner of a ukase, it leaves a sour taste in the mouth, and detracts from what is otherwise a very professional appearance.
koganam is offline  
Reply With Quote
Old 01-21-2011, 01:21 PM   #13
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

Ouch!

I saw that example and just assumed it was over simplified as a demo, or else written by someone without commercial programming experience.

Having multiple suppliers contending with names in the global namespace is really evil. Two suppliers can collide, and no one will know until indicators from both suppliers are installed on the same system. There is no way for the supplier to catch this during testing, and there is no guarantee that even extensive beta testing will catch the problem.

I personally create a namespace that is the same name as the indicator. That has the advantage that it is guaranteed to be different than any other indicator -- mine or anyone else's. I could see some suppliers wanting to have all of their indicators share one namespace, though, and I have no problem with that. I just do not want them in my namespace.

The good news is that AFAIK this very simple use of a namespace has no potential for causing a problem. It is zero work for NT -- just agreeing that this is good practice, rather than calling it unsupported. And fix Josh's example to use a namespace for his enum.

Please put in a request that there needs to be some supported way to get those enums out of the global namespace. I do not care what the mechanism is, but I want my symbols to be somewhere that is guaranteed not collide with anyone else. My own namespace is the most obvious answer.

--EV
Last edited by ETFVoyageur; 01-21-2011 at 01:25 PM.
ETFVoyageur is offline  
Reply With Quote
Old 01-21-2011, 01:27 PM   #14
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

The method provided in the reference sample is the only method we can support. If you want to do otherwise you are free to attempt, but we cannot make any guarantees on what will/will not work in those cases.

As much as we would like to support every single caveat of C# we unfortunately are not able to and have drawn the line as to what we can cover and what we cannot. Just because it is not covered by us does not mean you cannot do it. You can always explore in any direction you please, we just unfortunately will not be able to provide you with any guidance down those venues. Thank you for your understanding.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-21-2011, 01:35 PM   #15
ETFVoyageur
Senior Member
 
Join Date: Dec 2010
Posts: 470
Thanks: 0
Thanked 4 times in 4 posts
Default

Josh,

I do not understand "the only method we can support". This is one thing that costs you no work at all. There is nothing to support. There is no cost to you. Zero. Zip. Nada. And it heads off a very real problem before it can get started.

What it does take is you agreeing that it is a good idea, and showing it in use in your demo (and any other place that talks about how to use enum parameters).

I cannot imagine any serious professional programmer who wants his symbols sharing a namespace with those from another supplier.

Is there any good reason for not agreeing to this?

--EV
Last edited by ETFVoyageur; 01-21-2011 at 01:38 PM.
ETFVoyageur 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
Polluting the global namespace ETFVoyageur Indicator Development 4 01-06-2011 04:27 AM
namespace trend Version 7 Beta General Questions & Bug Reports 1 10-21-2010 08:48 AM
namespace System.Messaging not available smasters Indicator Development 1 07-25-2010 10:45 PM
Custom DLL with own Namespace miker General Programming 3 07-22-2010 01:43 PM
Indicator Namespace How Does It Work geoMEAN General Programming 4 07-17-2010 08:10 AM


All times are GMT -6. The time now is 08:16 PM.