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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    54 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    29 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    40 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    47 views
    0 likes
    Last Post CarlTrading  
    Working...
    X