Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Add / Substartct two EMA's
Collapse
X
-
Hi dkbyond, thanks for your note.
Unfortunately, arithmetic between two indicator values is not supported in the strategy builder. The offset setting for a value is the closest to arithmetic you can get in the builder. Any other computations need to be written by hand in the NinjaScript Editor. I attached a sample indicator for your reference. To compile and run, place the file within Documents\NinjaTrader 8\bin\Custom\Indicators and press F5 in the NInjaScript editor.
Best regards,
-ChrisLAttached Files
-
Understood the script a little bit. Now need help on the below.
FastLine = ExpAverage(close, 20) - ExpAverage(close, 40); --> this is how as per your script Value[0] = EMA1[0] - EMA2[0]; where EMA1 = 20 and EMA2 = 40.
SlowLine = ExpAverage(FastLine, 10); ---> how do I code this SlowLine? Thanks.
Comment
-
Hi dkbyond, thanks for your reply.
What is ExpAverage? I'm not seeing anything in our documentation pages for this. From the looks of it, this takes a Series object and not a double assuming FastLine is a double data type variable. You will need to make a custom series and for each bar, calculate FastLine roughly:
MyCustomSeries[0] = ExpAverage(Close, 20) - ExpAverage(Close, 40);
if(CurrentBar < 10)
return;
SlowLine = ExpAverage(MyCustomSeries, 10);
Comment
-
Sorry my bad, it is exponential average. So I want a indicator plotting first line MyCustomSeries[0] = ExpAverage(Close, 20) - ExpAverage(Close, 40); and second line plotting ExpAverage(MyCustomSeries, 10);
Later I would want to use this indicator in my crossover strategy (first line crosses above second) in strategy builder. I will go through the information you provided, if still stuck, will come back. Thanks.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
79 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
40 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
63 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
63 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
54 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment