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 algospoke, Yesterday, 06:40 PM
    2 responses
    20 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    21 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X