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
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
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
-
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
-
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 fitspressoburnfat, Today, 04:25 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 04:25 AM | ||
Started by Skifree, Today, 03:41 AM
|
1 response
4 views
0 likes
|
Last Post
by Skifree
Today, 03:42 AM
|
||
Started by usazencort, Today, 01:16 AM
|
0 responses
1 view
0 likes
|
Last Post
by usazencort
Today, 01:16 AM
|
||
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
604 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
23 views
0 likes
|
Last Post Today, 12:31 AM |
Comment