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
Passing a value to an indicator
Collapse
X
-
Hello,
Yes this is possible to do, an example of this would be the SMA indicator that requires a Period.
For this, an easy example is actually to view the SMA indicators code to see how this is done.
Please go to Tools -> Edit NinjaScript -> Indicator -> SMA
Once the code is open, there are a few parts you need to make a parameter.
The first place to look is the variables section, look for the line:
Code:private int period = 14;
Now look near the bottom in the Properties section for the following:
Code:[Description("Numbers of bars used for calculations")] [GridCategory("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } }
Now in the code for this indicator anywhere you need to use the period input, you would use Period
From a strategy you would call this indicator by name or IndicatorName(13) the 13 would be a period because now this has a Period input.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, Today, 09:30 AM
|
2 responses
11 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
2 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM | ||
Started by lorem, Today, 09:18 AM
|
2 responses
11 views
0 likes
|
Last Post Today, 10:55 AM |
Comment