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
No announcement yet.
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,
Check out the Help Guide page for Series<T>: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.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
599 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
344 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
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
557 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment