Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem Heiken ashi

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

    Problem Heiken ashi

    Hello,

    I am unable to retrieve the values of the heikenAshi8 indicator.
    I keep getting an array index error. I don't see where I'm going wrong. I'm having trouble understanding bar indexes.


    My code is :


    namespace NinjaTrader.NinjaScript.Indicators.JIT
    {
    public class JITAlertsArrows : Indicator
    {

    private HeikenAshi8 HA;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"";
    Name = "testonha";
    Calculate = Calculate.OnEachTick;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = false;

    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = false;
    BarsRequiredToPlot = 1;



    }

    else if (State == State.DataLoaded)
    {
    HA = HeikenAshi8();
    }
    }


    protected override void OnBarUpdate()
    {


    Print("0 = "+HA.HAClose[0]);
    Print("1 = "+HA.HAClose[1]);
    Print("2 = "+HA.HAClose[2]);

    }

    Thanks for your hel

    #2
    Hello jodu49,

    When you access data with BarsAgo that data needs to be available, please try using a current bar check to see if that helps:

    Code:
    if(CurrentBar < 2) return; 
    Print("0 = "+HA.HAClose[0]);
    Print("1 = "+HA.HAClose[1]);
    Print("2 = "+HA.HAClose[2]);

    Comment


      #3
      okay ! I understood, you have to check the maximum index and put the test. Thank you !

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      573 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      575 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X