I want to know how to get the value of 10-period SMA, where the lengh of a period is configurable (e.g. 1 period can be 30 minutes (30-minute bar) or 1 hour (1-hour bar) and so on) or 1 hour using Ninjascript. How can I do that? Please advise.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Getting SMA values of a specific-period bar chart
Collapse
X
-
Getting SMA values of a specific-period bar chart
Hi all,
I want to know how to get the value of 10-period SMA, where the lengh of a period is configurable (e.g. 1 period can be 30 minutes (30-minute bar) or 1 hour (1-hour bar) and so on) or 1 hour using Ninjascript. How can I do that? Please advise.Tags: None
-
Thanks for you advice and information given.Originally posted by NinjaTrader_Bertrand View PostYou will need to Add your needed time frame in the Initialize of your strategy and then calculate the SMA value for your desired period on this frame using this BarsArray then as input for the IDataSeries input -
http://www.ninjatrader-support.com/H...BarSeries.html
Actually I am not going to write a strategy, but instead write an indicator showing the absolute difference between two SMAs of different time frames. When I tried to compile the program, the following compile-time error is shown:
No overload for Method "Add" takes "2" arguments.
What happened? Below is a part of my code:
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 20, "Convergence"));
Add(PeriodType.Minute, timeFrame1);
Add(PeriodType.Minute, timeFrame2);
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
Comment
-
I am currently using NT6.5, and I am not going to upgrade it to NT 7 unless it is a non-beta release.Originally posted by NinjaTrader_Austin View PostDGMan, if you're using NT6.5, multi-instrument indicators are not possible. If you're using NT7, please try hardcoding the values for timeFrame1 and timeFrame2.
Speaking back to my issue, I am not intending to develop a custom mult-INSTRUMENT indicator, but an indicator with the same underlying instrument (e.g. ES) but with different timeframes. Is it possible in NT6.5?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
596 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
554 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment