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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
72 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
39 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
53 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment