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

Custom Series

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

    Custom Series

    Hello,

    I have created a custom series, Series<T>, that stores information related to each bar on the chart. Is there a way of setting values for the series without synchronizing the "barsAgo" pointer via the TriggerCustomEvent() method? Since there is already the method mySeries.GetValueAt(), I am simply wondering if there is an equivalent mySeries.SetValueAt(). I must be missing something here. Any help would be greatly appreciated. Thank you.

    #2
    Hello Zeos6,

    Custom Series objects have to be synchronized to another series.

    If you are wanting a collection that is not related to bars you can use a C# Array or List.
    Create and loop over a string array. Access array Length and get elements at indexes.

    Create a new List, add elements to it, and loop over its elements with for and foreach.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea B,

      Thank you for your reply. The reason this issue came up is that I am working on a custom ChartStyle. I calculate some custom bar specific data and I wanted to save the data in a Series<T>. Whilst I can create the series, I am not able to save the data to it, precisely because of the pointer synchronization issue. That is the reason I was inquiring about the mySeries.SetValueAt() functionality for the Series object since it would bypass the need for pointer synchronization.

      As you are aware, the Bar series is not available in ChartStyle except within OnRender(). However, TriggerCustomEvent() is not available in OnRender() inside ChartStyle to allow for synchronization. Is there any workaround for this?

      In the interim, I have done exactly as you suggested and have defaulted to using a thread safe List<T> to store my data..

      Perhaps having the mySeries.SetValueAt() functionality would be a useful feature to implement.

      Thank you.

      Comment


        #4
        Hello Zeos6,

        The Bars object is not the same as a Series<double> object that is native to indicators and strategies, meaning TriggerCustomEvent() only applies to indicators and strategies.

        It sounds like this should be an indicator and not a chart style.
        The chart style is intended for rendering the chart bars only based on the bar information.

        If you are trying to store information, likely this should be done in an indicator and not a chart style.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          I am aware that an indicator could be used to accomplish what I wish to do but I have reasons for doing it via ChartStyles. I wish to render the bars based on a calculation taken from the underlying bar series and thus the initial idea of using a Series<T> object. It seems to me though that simply adding mySeries.SetValueAt() method would be a simple way to extend the functionality of the Series<T> object outside of of Indicators and Strategies.

          In the absence of this solution, however, List<T> with an indexer works fine and as intended.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by The_Sec, Today, 02:29 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by jeronymite, 04-12-2024, 04:26 PM
          2 responses
          30 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mindset, 05-06-2023, 09:03 PM
          10 responses
          265 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by michi08, 10-05-2018, 09:31 AM
          5 responses
          743 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by tsantospinto, 04-12-2024, 07:04 PM
          4 responses
          63 views
          0 likes
          Last Post aligator  
          Working...
          X