Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get BarsPeriod.Id for an indicator within a strategy

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

    Get BarsPeriod.Id for an indicator within a strategy

    Assume that a strategy call an indicator X, where X will do the following thing during the initialization:

    Add("MSFT", this.BarsPeriod.Id, this.BarsPeriod.Value, MarketDataType.Bid);
    Add("MSFT", this.BarsPeriod.Id, this.BarsPeriod.Value, MarketDataType.Ask);

    If I use X on a chart as an indicator, then it works fine. However, when I try to add the indicator in the Initialization() of a strategy, then BarsPeriod.Id (in X) is always "Minute", and BarsPeriod.Value is always "-1".

    Is there an easy fix for this without explictly passing the BarsPeriod to the indicator as a parameter?

    David

    #2
    David, thanks for reporting this in - we'll check into. Is this on lastest B21?

    Comment


      #3
      Yes, it is in Beta 21.

      David

      Comment


        #4
        Thanks David, will test it here and get back to you.

        Comment


          #5
          David, when I test it here I'm seeing this error - 'Add' method only accepts positive 'period' values, but was -1 Min - Bid

          You would need to pass in specific values as you can't Add() dynamically unfortunately.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          64 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          35 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          59 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          62 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          51 views
          0 likes
          Last Post CarlTrading  
          Working...
          X