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

custom heiken ashi calculation for open always equates to zero?

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

    custom heiken ashi calculation for open always equates to zero?

    Hi... I have a data series in my strategy for calculating heiken ashi candles. It is this one:
    In this case TradeTicker is just a user input to indicate what is being traded.
    In this case, the data series is the 2nd data series added to the chart after the primary... so it is data series 2 (the strat has a total of 3 dataseries... 0, 1 and 2)

    AddDataSeries(TradeTicker, Data.BarsPeriodType.Minute, 5);


    here is the dataloaded portion

    haOpen = new double[BarsArray[2].Count];
    haHigh = new double[BarsArray[2].Count];
    haLow = new double[BarsArray[2].Count];
    haClose = new double[BarsArray[2].Count];



    then... I have a snippet for calculating opens and closes... but for some reason my open is equating to 0 for all bars.
    my close comes out OK... but for some reason the open is always 0.

    Can anyone tell me what I'm missing here?

    haClose[0] = (Opens[2][0] + Highs[2][0] + Lows[2][0] + Closes[2][0]) / 4;

    if(CurrentBars[2] == 0)
    {
    haOpen[0] = (Opens[2][0] + Closes[2][0]) / 2;
    }
    else
    {
    haOpen[0] = (haOpen[1] + haClose[1]) / 2;
    }

    haHigh[0] = Math.Max(Highs[2][0], Math.Max(haOpen[0], haClose[0]));
    haLow[0] = Math.Min(Lows[2][0], Math.Min(haOpen[0], haClose[0]));​




    Thank you.

    #2
    I can't figure out how to delete a post... but this can be ignored. I figured it out.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    11 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    1 view
    0 likes
    Last Post port119
    by port119
     
    Started by Philippe56140, Today, 02:35 PM
    0 responses
    3 views
    0 likes
    Last Post Philippe56140  
    Started by 00nevest, Today, 02:27 PM
    0 responses
    2 views
    0 likes
    Last Post 00nevest  
    Started by Jonafare, 12-06-2012, 03:48 PM
    5 responses
    3,986 views
    0 likes
    Last Post rene69851  
    Working...
    X