I recently started using Ninjatrader again and I need help creating a simple indicator that adds the values of two other indicators. That is all I want to create. Basically, value of indicator C = value of indicator A + value of indicator B. How do I go about doing this?
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
Creating an extremely simple arithmetic indicator.
Collapse
X
-
Creating an extremely simple arithmetic indicator.
Hi,
I recently started using Ninjatrader again and I need help creating a simple indicator that adds the values of two other indicators. That is all I want to create. Basically, value of indicator C = value of indicator A + value of indicator B. How do I go about doing this?Tags: None
-
Hi KageRyu,
Thank you for your note.
Here's a sample of how to add two indicator values -
Code:OnBarUpdate() { double myValue = SMA(14)[0] + EMA(14)[0]; }
We are first declaring the variable myValue as a double precision number.
We are then assigning a value to it by adding two indicators here. I used the SMA and EMA as an example.
The SMA(14) is telling the system that I want to use a 14 period SMA, then the [0] is indexing which bar value to grab. Note that this is the bar value of the SMA(14) and not the actual price bar. [0] will be the current bar while if I had a [1] I would be referencing one bar ago.
The allows the system to return a double value of the SMA(14) and add that value to the EMA(14)[0] double value.
Please note that in this setup, the value of the variable will be updated which each bar update.
Let me know if I can be of further assistance.Cal H.NinjaTrader Customer Service
-
Thanks for the quick response.
The issue is that you are already specifying two indicators in the code. What I want to do is create an indicator which adds the output values of ANY two indicators. You know in the box where you can change the indicator settings, there's a part where you can set the data input series?
I want the indicator to have two input series in the data tab. The indicator should be able to add the values of those two indicators, whichever I may choose.
Comment
-
KageRyu,
You will not be able to add another input series as you have described, however, you can create a enum that you can use in the parameters section to select which Indicator to test with.
There is an indicator on the forums that does this, called the Moving Average Cross Builder. I suggest taking a look at the code -
http://www.ninjatrader.com/support/f...atid=4&lpage=7
Let me know if this helps.Cal H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pechtri, 06-22-2023, 02:31 AM
|
10 responses
124 views
0 likes
|
Last Post Today, 12:03 AM | ||
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
59 views
0 likes
|
Last Post
by DynamicTest
Yesterday, 08:25 PM
|
||
Started by ScottWalsh, Yesterday, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Yesterday, 07:40 PM
|
||
Started by olisav57, Yesterday, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Yesterday, 07:39 PM
|
||
Started by trilliantrader, Yesterday, 03:01 PM
|
2 responses
22 views
0 likes
|
Last Post
by helpwanted
Yesterday, 07:25 PM
|
Comment