Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Global Variable?
Collapse
X
-
Thanks Bertrand
WOW! I'm totally overwhelmed by the complexity of making a value calculated in the code for one indicator available to the code in another indicator. I have a vague understanding, at best, of many of the terms and concepts encountered.
Perhaps I have misstated my problem, which restated is: I calculate a single variable 'redline' in the code for an indicator. I want to make 'redline' available to other indicators and strategies. I was hoping I could do so by somehow making 'redline' global instead of public?
if necessary, maybe I can simply repeat the calculation wherever needed?
Comment
-
Re: 'expose the variable for access'
In summary, my understanding is that:
'expose the variable for access' mean 'pass it on'. But I understand that I can't simply pass it on by means of a simple 'Global variable'' concept. Instead I must pattern my 'pass it on' method after the techniques demonstrated in the download link you provided earlier.
Alternatively I hopefully can explicitly calculate 'redline' everywhere needed. At this time that is obviously the far easier choice for me if it works.
Re: 'if it's not a plot'
I'm not sure I understand the meaning or significance of 'if it's not a plot'. 'redline', the variable I want to share, is a variable, not a plot I'm guessing. What is a 'plot'? Is it an indicator which gets plotted, which is an array of values and not a single value?
If there is not a good reason to not do so, kindly pass on a request to program development to consider adding such a 'Global variable' feature.
thanks a whole lot for your help. much appreciated.
Comment
-
Your understanding is correct, this is not a Global Variable concept, but specifically exposing what you wanted to give access to - that being said a Global Variable framework in on our list of feedback and I will make sure to add your vote in as well.
A plot is a visualized data series from your indicator - the values would for example see in the databox, those are 'auto exposed' if you will.BertrandNinjaTrader Customer Service
Comment
-
Originally posted by joemiller View PostRe: 'expose the variable for access'
In summary, my understanding is that:
'expose the variable for access' mean 'pass it on'. But I understand that I can't simply pass it on by means of a simple 'Global variable'' concept. Instead I must pattern my 'pass it on' method after the techniques demonstrated in the download link you provided earlier.
Alternatively I hopefully can explicitly calculate 'redline' everywhere needed. At this time that is obviously the far easier choice for me if it works.
Re: 'if it's not a plot'
I'm not sure I understand the meaning or significance of 'if it's not a plot'. 'redline', the variable I want to share, is a variable, not a plot I'm guessing. What is a 'plot'? Is it an indicator which gets plotted, which is an array of values and not a single value?
If there is not a good reason to not do so, kindly pass on a request to program development to consider adding such a 'Global variable' feature.
thanks a whole lot for your help. much appreciated.
Using static variables is generally a bad idea: they are just sometimes a necessary evil, so one should be careful about using them all willy-nilly. So far, I have no code that uses static variables, but that is simply because I have never needed them, and my coding style is to generally control everything, including exposing outputs, from within that class. That way, everything is self-contained, and I do not need to worry about breaking dependencies when I export my code. Static classes are a different kettle of fish.
OOP principles generally frown on code that is not controlled directly from its object.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Irukandji, Today, 04:58 AM
|
0 responses
2 views
0 likes
|
Last Post
by Irukandji
Today, 04:58 AM
|
||
Started by fitspressoburnfat, Today, 04:25 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 04:25 AM | ||
Started by Skifree, Today, 03:41 AM
|
1 response
4 views
0 likes
|
Last Post
by Skifree
Today, 03:42 AM
|
||
Started by usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
604 views
0 likes
|
Last Post Today, 12:32 AM |
Comment