private ISeries<double> haOpenSeries, haCloseSeries, haHighSeries, haLowSeries; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Select a Band Type and a MA to reference it off of all in one indicator. Note: Keltner is based on Close not Typical price so its off slightly from the original Ninjatrader code."; Name = "CX HAMA3"; Calculate = Calculate.OnEachTick; IsOverlay = true; DisplayInDataBox = false; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; MATypesHAMA3 = MATypesHAMA3.SMA; Period = 14; BarsRequiredToPlot = 1; AddPlot(Brushes.Gray, "HAOpen"); AddPlot(Brushes.Gray, "HAHigh"); AddPlot(Brushes.Gray, "HALow"); AddPlot(Brushes.Gray, "HAClose"); } else if (State == State.DataLoaded) { } } protected override void OnBarUpdate() { if (CurrentBar == 0) { haCloseSeries = Close[0]; haOpenSeries = Open[0]; haHighSeries = High[0]; haLowSeries = Low[0]; return; } haCloseSeries = ((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); haOpenSeries = ((haOpenSeries[1] + haCloseSeries[1]) * 0.5); haHighSeries = Math.Max(High[0], haOpenSeries[0]); haLowSeries = Math.Min(Low[0], haOpenSeries[0]); if (CurrentBar < 1) return; double maValue = 0; switch (MATypesHAMA3) { case MATypesHAMA3.ADXVMA: maValue = ADXVMA (haCloseSeries, Period)[0]; break; case MATypesHAMA3.AhrensMA: maValue = CX_AhrensMA (haCloseSeries, Period)[0]; break;
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
Cannot convert a double to ISeries Double.
Collapse
X
-
Cannot convert a double to ISeries Double.
Can someone help me sort this out? I am trying to make the HeikenAshi OHLC's into 4 separate ISeries Doubles so I can use them in Moving Average inputs but I get an error about converting a double to ISeries<double>, not sure what's I'm missing to make the conversion..
Code:Tags: None
-
Hello Conceptzx,
Thank you for your post.
You are trying to assign a value of type double to the entire series.
If you want to save the double values in the series, you need to supply an index to the series. For example,
Code:haCloseSeries[0] = ((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); haOpenSeries[0] = ((haOpenSeries[1] + haCloseSeries[1]) * 0.5); haHighSeries[0] = Math.Max(High[0], haOpenSeries[0]); haLowSeries[0] = Math.Min(Low[0], haOpenSeries[0]);
Additionally, make sure you instantiate the Series<double> objects in State.DataLoaded. For example,
Code:else if (State == State.DataLoaded) { haOpenSeries = new new Series<double>(this);| }
Please let us know if you need any further assistance.
Gaby V.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by futtrader, 04-21-2024, 01:50 AM
|
6 responses
57 views
0 likes
|
Last Post
by futtrader
Today, 11:54 AM
|
||
Started by sgordet, Today, 11:48 AM
|
0 responses
1 view
0 likes
|
Last Post
by sgordet
Today, 11:48 AM
|
||
Started by Trader146, Today, 11:41 AM
|
0 responses
3 views
0 likes
|
Last Post
by Trader146
Today, 11:41 AM
|
||
Started by jpapa, 04-23-2024, 07:22 AM
|
2 responses
18 views
0 likes
|
Last Post
by rene69851
Today, 11:39 AM
|
||
Started by funk10101, Today, 11:35 AM
|
0 responses
1 view
0 likes
|
Last Post
by funk10101
Today, 11:35 AM
|
Comment