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 bortz, 11-06-2023, 08:04 AM
|
47 responses
1,603 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
8 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
4 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
12 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment