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

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.



    JesseNinjaTrader Customer Service

    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 llanqui, Today, 03:53 AM
      0 responses
      5 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X