Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to query original OHLC price data on Heiken Ashi chart ?

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

    How to query original OHLC price data on Heiken Ashi chart ?

    I have an indicator running on a Heiken Ashi chart (daily time-frame). When I try to use the Open, High, Low or Close arrays from the code, it returns the Heiken Ashi based values and not the original OHLC values based on the price chart.

    How do I fetch the OHLC values from the Daily time-frame, and not the Heikeh Ashi ones ?

    I am aware that adding AddDataSeries() in the OnStateChange(Configure) will work. But the issue is how do I know that the Heiken Ashi chart is Daily or 5-min or 15-min, so I can add the correct BarsPeriodType and BarsPeriod parameters with AddDataSeries ?

    So, if the chart is 5-min Heiken Ashi, I want find its Minute charge, and period = 5, during the OnStateChange() (Configure) state.



    Thanks,

    Last edited by firstlanetech; 11-12-2024, 03:12 AM.

    #2
    I think I may have found the solution.
    In the OnStateChange() State.Configure section, I added

    Code:
    AddDataSeries(Instrument.MasterInstrument.Name, BarsPeriod.BaseBarsPeriodType, BarsPeriod.BaseBarsPeriodValue);
    This seems to work in OnBarUpdate(), when BarsInProgress is 1.

    I use the Opens[BarsInProgress][0] etc to access the underlying OHLC of the price chart.

    Can anyone confirm this is the correct approach ?

    Comment


      #3
      Hello firstlanetech,

      Thank you for your post.

      You can take that approach, although note that it would be unsupported as it is dependent on run-time variables such as Bars and Instrument.

      "Arguments supplied to AddDataSeries() 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.​"



      Unfortunately at this time, there would be no supported solution for what you are looking to do (grab Bars and Instrument info for an AddDataSeries call). Bars and Instrument can only be reliably obtained from State.DataLoaded, so while this may work, we can't guarantee this solution will always function as intended. Support's stance is that all AddDataSeries() calls should be hard-coded.

      Please let us know if you have any further questions.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X