thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
existing indicator?
Collapse
X
-
existing indicator?
Hello. I'm wondering if you guys are aware of any existing indicators I can use for calculating market beta for an instrument? even if there are only subcomponents available, eg. variance or covariance that would be a start. if not I can build them relatively easily but figure i'd just check first.
thanksTags: None
-
Hello stewarco,
Thanks for your post.
There does appear to be an existing NinjaTrader 7 indicator that accomplishes this task. The NinjaTrader 8 Code Breaking Changes page of the help guide could be referenced when converting this indicator to NinjaTrader 8.
NT7 Beta indicator - https://ninjatrader.com/support/foru...tid=-1&lpage=1
Code Breaking Changes - https://ninjatrader.com/support/help...ng_changes.htm
Please let us know if there is anything else we can do to help.
-
a few questions
Hi. So I decided to go ahead and build my own indicator.
1) Does this indicator get updated on every bar update, regardless of whether I call it or not?
2) Are the values then forthwith associated with that same bar? eg. what is now Indicator[0] becomes Indicator[10] 10 bars later?
3) If I have created a series within that indicator, are those values also linked to a specific bar going forward, or do I need to redefine the series every time I call it?
4) In the body of the indicator, where do I actually specifiy the value that is being returned? Eg., my indicator is called Covariance, and I have a variable covariance that is equal to the value I want, but it's unclear to me how I associate that with the actual value that is returned from my indicator when I call it.
5) Is there a place in my strategy code where I need to let the strategy know that a given indicator is going to be used prior to me calling it?
Thanks
Comment
-
Hello stewarco,
Thanks for your additional questions.
If you add an instance of an indicator to a strategy or other hosting NinjaScript (as seen when adding indicators using the Strategy Builder) they will stay updated.1) Does this indicator get updated on every bar update, regardless of whether I call it or not?
Yes. The Series<double> output of the indicator will be synchronized to the Series that is used for the indicator input.2) Are the values then forthwith associated with that same bar? eg. what is now Indicator[0] becomes Indicator[10] 10 bars later?
Series objects should be created in State.DataLoaded and they will be synchronized to the primary data series the NinjaScript is applied to. The Series would not need to be redefined.3) If I have created a series within that indicator, are those values also linked to a specific bar going forward, or do I need to redefine the series every time I call it?
Indicators add plots and then assign the plot values with Value, or Values for multi plot indicators.4) In the body of the indicator, where do I actually specifiy the value that is being returned? Eg., my indicator is called Covariance, and I have a variable covariance that is equal to the value I want, but it's unclear to me how I associate that with the actual value that is returned from my indicator when I call it.
You can add the indicator with AddChartIndicator() in State.DataLoaded so the indicator gets applied to a chart. Otherwise, you may instantiate the indicator in State.DataLoaded and it will not be added to a chart.5) Is there a place in my strategy code where I need to let the strategy know that a given indicator is going to be used prior to me calling it?
I would recommend using the Strategy Builder to get more acquainted with syntax for adding indicators to strategies and using strategies all together. Our open source indicators can also be referenced for how an indicator plots data.
Documentation items that can be referenced for further reading as well as a link to the Strategy Builder 301 tutorial are linked below.
Strategy Builder 301 - https://ninjatrader.com/Webinar/Strategy-Builder-301
Series<t> - https://ninjatrader.com/support/help...us/seriest.htm
AddPlot() - https://ninjatrader.com/support/help...us/addplot.htm
Value - https://ninjatrader.com/support/help...n-us/value.htm
Values - https://ninjatrader.com/support/help...-us/values.htm
We look forward to being of any further assistance.
Comment
-
one more thing
ok. two more questions:
1) so I see that you say Indicator return Values. does that mean if the quantity I ultimately want to return is called x, then at some point in the indicator I would make an assignment statement Value = x?
2) A related question, I guess: since I don't really need to show these on a chart, but instead am just looking for a function I can use to in a variety of strategies to return the value of a relatively complex calculation, is there a better way for me to accomplish this (as opposed to simply copying the block of code and inserting it in each strategy)?
Thanks
Comment
-
Hello stewarco,
Happy to answer.
The assignment would be Value[0] = x; after adding the plot in State.SetDefaults with AddPlot(). The AddPlot() document can also has some examples that can be referenced for Plot creation and assignment.1) so I see that you say Indicator return Values. does that mean if the quantity I ultimately want to return is called x, then at some point in the indicator I would make an assignment statement Value = x?
Adding the plot and creating an indicator will allow the indicator to be used separately throughout the platform which will have its benefits. The indicator will only be added to the chart from a strategy if you add the indicator with AddChartIndicator(). If performance is a major concern of yours, you could consider unrolling any calculations that would be done in the indicator so that you ultimately perform less operations. I generally would not expect most indicators to cause that great of a performance hit, though.2) A related question, I guess: since I don't really need to show these on a chart, but instead am just looking for a function I can use to in a variety of strategies to return the value of a relatively complex calculation, is there a better way for me to accomplish this (as opposed to simply copying the block of code and inserting it in each strategy)?
AddChartIndicator() - https://ninjatrader.com/support/help...tindicator.htm
If there is anything else that you come across that isn't clear, please don't hesitate to ask.
Comment
-
hi
ok thanks. So it sounds like the AddPlot methodology is the way to go regardless of whether I ever plan to look at it on a chart or not.
I haven't done that yet, and currently I have strange problem that while the "main code"might be on bar 100, as soon as i'm within the indicator code it is telling me I'm on bar number (-1) so I keep getting out of range errors. Any idea why this would happen? I'll try doing the AddPlot for now and see what happens.
Comment
-
Hello stewarco,
Debugging steps will need to be taken to better understand the error received and how it should be corrected. I've included some resources on debugging tips and some referencing errors in this post.
It may prove useful to first create the indicator framework for adding a plot and then assigning the plot's Value with Close[0] before proceeding with your port. This way you can approach the conversion of the indicator separately from the creating the underlying framework.
Debugging tips - https://ninjatrader.com/support/help...script_cod.htm
Index out of range errors (specifically for making sure there are enough bars for your calculations.) - https://ninjatrader.com/support/help...nough_bars.htm
As a more direct tip, adding prints throughout the code will point to where you see the error and it should then be possible to understand how to fix it.
Please let us know if you have any questions on these materials.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
331 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
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment