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
No announcement yet.
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 -
Let me explain what is happening here.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 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