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

Using PNF as secondary series

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

    Using PNF as secondary series

    Hello and good day,

    I'm trying to develop a indicator that can access some indicator values that are based on a PNF dataseries but using it in a minute chart.

    Code:
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Alert"));
                Overlay				= false;
    //			AddPointAndFigure("$EURUSD", pType, baseperiod, box, reversal, PointAndFigurePriceType.Close, MarketDataType.Last); 
    			AddPointAndFigure("$EURUSD", pType, baseperiod, box, reversal, PointAndFigurePriceType.Close, MarketDataType.Last); 
    
            }
    
      protected override void OnBarUpdate()
            {
    			Alert.Set(0);
    			if (CurrentBar < 2)
    				return;
    			if
    			    (
    				d9ParticleOscillator_V2(BarsInProgress [1],d9period,0).RawTrend[0]>0
    				)
    					{
    		    Alert.Set(1);
    			BackColorAll = Color.PaleGreen;
    					}
    			if
    			    (
    				d9ParticleOscillator_V2(BarsInProgress [1],d9period,0).RawTrend[0]<0
    				)
    				{
    		    Alert.Set(-1);
    			BackColorAll = Color.Coral;
    				}		
            }
    Im getting this error:

    24-11-2014 11:00:43 Default Error on calling 'OnBarUpdate' method for indicator 'Signal1' on bar 2: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


    Could you help me?


    Thank You

    #2
    hliboi, first thing I would suggest doing is including a CurrentBars check for all your series (not just primary one).



    Next, to calcuate your indicator using the first added series data, just use BarsArray[1] for the IDataSeries parameter field in your method call (you currently point to BarsInProgress here).
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andrewtrades, Today, 04:57 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    6 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    8 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X