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

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 algospoke, 04-17-2024, 06:40 PM
    6 responses
    49 views
    0 likes
    Last Post algospoke  
    Started by arvidvanstaey, Today, 02:19 PM
    4 responses
    11 views
    0 likes
    Last Post arvidvanstaey  
    Started by samish18, 04-17-2024, 08:57 AM
    16 responses
    61 views
    0 likes
    Last Post samish18  
    Started by jordanq2, Today, 03:10 PM
    2 responses
    11 views
    0 likes
    Last Post jordanq2  
    Started by traderqz, Today, 12:06 AM
    10 responses
    21 views
    0 likes
    Last Post traderqz  
    Working...
    X