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
referencing a variable from another indicator
Collapse
X
-
referencing a variable from another indicator
Is it possible to reference a variable from another indicator that is also running in a separate market analyzer column? I'm assuming this is possible because otherwise you would have to keep repeating the same code over and over again if you're making an indicator with a lot of inputs. For example, let's say I have indicator 1 and indicator 2 both running in the market analyzer and i want to use data assigned to to a double that is obtained from a method in indicator 1 and use it as a double in an if statement in indicator 2. I could just copy the code for that trigger in the 2nd indicator but some of these methods are really long and to use the inputs from various triggers to make a new trigger it would be easier to just be able to reference them from other indicators that are already running.Tags: None
-
Hello gordongekko,
Thanks for opening the thread.
In a strategy or indicator we can add a new instance of an indicator and reference the public variables and methods of an instance of an indicator to use those exposed variables. The strategy or the indicator that these instances are added to provides the foundation to be able to share data between indicators. (We need to have an instance of a class to reference a member variable.) This is demonstrated in the SampleBoolSeries script in our Reference Samples section of the forums.
Indicators added to the Market Analyzer would not be added in a way you can easily reference the data from one indicator in another indicator. This would be similar to having two separate indicators on a chart and trying to share data between them. There is some information for looping through the indicator's collection in a chart, but we do not have similar information available for looping through indicators in the Market Analyzer.
It is possible to create an AddOn with static variables to hold some data and share it between different indicators, however. I'll link to a thread where this question has come up before and where we have a demonstration script to provide further direction.
MySharedMethodsAddOnExample - https://ninjatrader.com/support/foru...d.php?t=103388
Please let me know if I can be of further assistance.JimNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by llanqui, Today, 11:10 AM
|
1 response
14 views
0 likes
|
Last Post Today, 04:02 PM | ||
Started by reynoldsn, 05-10-2024, 07:04 PM
|
2 responses
21 views
0 likes
|
Last Post
by reynoldsn
Today, 04:02 PM
|
||
Started by llanqui, Today, 10:29 AM
|
1 response
12 views
0 likes
|
Last Post Today, 03:45 PM | ||
Started by Trader146, 05-10-2024, 09:17 PM
|
1 response
22 views
0 likes
|
Last Post Today, 03:35 PM | ||
Started by bourasrafik, Today, 03:26 PM
|
0 responses
5 views
0 likes
|
Last Post
by bourasrafik
Today, 03:26 PM
|
Comment