Announcement
Collapse
No announcement yet.
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.
Comment
-
There is no such thing really as a "Global" variable in C#. Something akin to it would be a "static variable". Your Google-Fu should be able to help you find information about it. Heed all the warnings.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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment