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
Declaring and Setting a Public Variable
Collapse
X
-
Declaring and Setting a Public Variable
I'd like to create a new Public variable, in an Indicator, that my Strategy can call. I need to look back on previous bars for this variable, so I’m trying to use the DataSeries method as described in the NT Users Guide. So far, I’ve not been successful in doing this. Is there detailed discussion or thread that would help me Declare this variable and properly Set it in my Indicator?Tags: None
-
Hello DenMan,
Thanks for the post and welcome to the NinjaTrader forums! Easiest way is to structure the value as a plot, and then you can access it without additional code.
If you want to maintain it as data series only, it should be declared as private and all calculations use the private variable. Then, in properties region, link this private variable to a public one. There is a reference sample available here that can help with this technique:
You would need to setup your data series the same as the BoolSeries in that example.Ryan M.NinjaTrader Customer Service
-
What is the best way to use a variable (that is type double) from an indicator and call it in a strategy?
I want to use the variables from the indicator and delete the duplicate code in the strategy, its too hard to manage.
IntSeries class only takes int.
I have used a DataSeries in the past successfully but will require convert in the strategy.
I thought about using float but then I would have to declare float in the indicator...
Both don't seem that efficient to me.
Any ideas?
Comment
-
Originally posted by NinjaTrader_RyanM View Post
So looks like no need for DataSeries class etc.
It compiled in the strategy after a simple an assignment with
Long = SampleBoolSeries().ExposedVariable;
Hopefully it works with the rest of the code.
Thx
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by yaniv, Today, 12:50 PM
|
1 response
1 view
0 likes
|
Last Post Today, 01:15 PM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
10 responses
31 views
0 likes
|
Last Post Today, 01:04 PM | ||
Started by Padan, Today, 02:02 AM
|
7 responses
19 views
0 likes
|
Last Post Today, 12:59 PM | ||
Started by Adam Klaus, 03-26-2024, 07:43 PM
|
2 responses
22 views
0 likes
|
Last Post
by mcosta72
Today, 12:54 PM
|
||
Started by spottysallrite, Today, 11:31 AM
|
4 responses
12 views
0 likes
|
Last Post Today, 12:53 PM |
Comment