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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    232 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    150 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    161 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    243 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X