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!
See more
See less

Partner 728x90

Collapse

Cannot convert a double to ISeries Double.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
    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;​

    #2
    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]);
    Check out the Help Guide page for Series<T>:



    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

    Comment


      #3
      Got it working now, thank you so much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      11 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      16 views
      0 likes
      Last Post AaronKoRn  
      Working...
      X