Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pivots indicator has zero values in a Strategy

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

    Pivots indicator has zero values in a Strategy

    I've created a Strategy that uses the daily pivots as one of the types of exits. However I've found that the standard Pivots indicator only returns zero when used in a strategy. Does anyone know why this is, and how I can avoid it?

    Note this is for a FOREX instrument (hence the Ask & Bid series being added)

    Example snippet...

    Code:
    protected override void Initialize() {
    			CalculateOnBarClose = false;
    			ExitOnClose = false;
    			TraceOrders = true; 
    			
    			BarsRequired = 10;
    						
    			Add(Instrument.FullName.ToString(), PeriodType.Minute, 60, MarketDataType.Ask);  // BarsInProgress index = 1 DAILY	
    			Add(Instrument.FullName.ToString(), PeriodType.Minute, 1, MarketDataType.Ask);  // BarsInProgress index = 2 Long	
    			Add(Instrument.FullName.ToString(), PeriodType.Minute, 1, MarketDataType.Bid);  // BarsInProgress index = 3 Sell
    
    			RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction; 
    }
    
    
    protected override void OnBarUpdate()  {
    
                            if (BarsInProgress==2 && CurrentBars[2]>60) {
                                               Log("R1: "+Pivots(PivotRange.Daily,HLCCalculationMode.DailyBars,0,0,0,20).R1[0].ToString(), NinjaTrader.Cbi.LogLevel.Information);
    
                            }
    }

    #2
    Hello,
    You are receiving a 0 value for the R1 due to using the DailyBars HLCCalculationMode. When using this calculation mode it can be expected for values to return 0 due to daily bars not being loaded yet. To workaround this you will want to use a contains value check for example:

    Code:
    if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0 , 0 , 0 ,20).PP.ContainsValue(0))
    {
    	Print("R1:" + Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R1[0].ToString());
    }
    For more information on this I would recommend reviewing the Tip on this in the Help Guide section of the Pivots Indicator Method: http://ninjatrader.com/support/helpG...nt7/pivots.htm
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    574 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X