Announcement
Collapse
No announcement yet.
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
-
Oh ok.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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 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
553 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