Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why does my indicator always show 0 for some indicators ?

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

    Why does my indicator always show 0 for some indicators ?

    Hello
    Looking at the ChartToCsv code (https://ninjatraderecosystem.com/use...oad/charttocsv/) I wanted to simply display the value of an indicator which cannot be accessed by code but which is displayed both in the data box and in the save file.
    This is the Vpoc line of this indicator https://ninjatraderecosystem.com/use...estionboxlite/
    But the result is always print 0, whereas if I save with ChartToCsv, the values are correct.
    So I'd like to understand, not especially the action with the CongestionBoxLite,(for example) but why some indicators display always 0 while others display their correct value( SMA for example), even though when exported to a save file, the results are correct.
    Thanks for your help.

    My code :

    Code:
    foreach (IndicatorBase indicator in ChartControl.Indicators)    // loop through indicators on chart        
                      {
                        for (int seriesCount = 0; seriesCount <  indicator.Values.Length ; seriesCount++)  // process each plot of the indicator
                        {
                            Plot    plot                = indicator.Plots[seriesCount];                        // get a plot from the indictor
                            double val                    = indicator.Values[seriesCount].GetValueAt(0);        // now get a specific bar value                            
                            Print(plot.Name+"\t\t"+val.ToString());
    
                        }
                    }​

    #2
    Hello stephletrader,

    Are you seeing a value with the print that you added? In the code you provided you are using the method GetValueAt and supplying the bar index of 0. Bar 0 would be the very first bar on the chart, the left most bar. If your indicator has a 0 value at that point in time that would explain why the value is always 0 because you are always supplying 0 as the bar index.



    Comment


      #3
      Thank you for your reply.
      I hadn't really thought about it!
      I'm always so pleasantly surprised by the quality of the support.

      I have therefore modified
      Code:
      double val                    = indicator.Values[seriesCount].GetValueAt(CurrentBars[0]);

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      636 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      568 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X