Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddHeikenAshi() to change with timeframe switch

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

    AddHeikenAshi() to change with timeframe switch

    Hi,

    I would like to add Heiken Ashi into my indicator as secondary data series.

    The function and the syntax is clear, however my question would be : what syntax should I use so that whenever I change the instrument or the timeframe, the Heiken Ashi data series would follow my primary settings? In the code below, I add a 1 minute Heiken Ashi, but if I would like to switch to 15 seconds bars, I would like Heiken Ashi to switch as well. Or if I change the instrument to NQ, Heiken Ashi should also follow that.

    Thank you

    Code:
    protected override void OnStateChange()
    {
      if (State == State.SetDefaults)
      {
          Name = "Examples Indicator";            
      }
      else if (State == State.Configure)
      {
            AddHeikenAshi("ES 12-24", BarsPeriodType.Minute, 1, MarketDataType.Last);
      }
    }​

    #2
    Hello gyilaoliver,

    Thank you for your inquiry.

    AddHeikenAshi is not supported to be used dynamically in this way.

    "Arguments supplied to AddHeikenAshi() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.​"



    Any HeikenAshi series you want to use in your script must be hard-coded.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    590 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    342 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    555 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X