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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      230 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      149 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      161 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      243 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      198 views
      0 likes
      Last Post CarlTrading  
      Working...
      X