Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syncing Data Series From different scripts & Best Practices

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

    Syncing Data Series From different scripts & Best Practices

    • Hello, I have a few questions and would like some help.
    • I’m building a strategy, and in a stage where i want to separate a lot of logic onto different scripts so i can reuse a lot of it in other strategies in the future, since i came from Godot (Game development engine using GDscript, a built in scripting language), and learnt in this enclosed environment, I might be missing some basic knowledge about classes and extensions beyond some basic things.
    • Referrals to the right documentation would very much help, but detailed answers (if needed) would be even more appreciated.
    • 1. When creating a custom class that returns different data types that are dependent on bar series from the strategy, how can i make sure that the strategy calling the class methods, and the class are using the same data series, and that those series are synced?
    • 2. When creating a custom class, depending on the classes use, whether its an indicator, or a class that returns custom mathematical calculations, what would be considered best practice to create that new class depending on its use, i know that a custom indicator for example is created via the indicators Folder in the editor, but something less obvious to me is the latter.

      Thanks in advance! Aviram Y.
    Aviram Y
    NinjaTrader Ecosystem Vendor - Aviram Y

    #2
    Hello, thanks for writing in.

    You can set up a partial class or a regular class and pass in the IndicatorBase or StrategyBase object like shown here:
    I have class called Logger... I want to use this class inside indicator or strategy (ninjatrader objects). This Logger class should write text using Time[0],


    The best place to put lose .cs files in the Addon folder, there you can define your own custom namespaces, classes and custom reusable code.

    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you for the response, i will try this out!
      And what about question No.1? i have read about TriggetCustomEvent method in the documentation, is it the right way to approach synchronization between a custom indicator and a strategy that doesn't rely on OnBarUpdate for example?
      Aviram Y
      NinjaTrader Ecosystem Vendor - Aviram Y

      Comment


        #4
        Originally posted by Aviram Y View Post
        Thank you for the response, i will try this out!
        And what about question No.1? i have read about TriggetCustomEvent method in the documentation, is it the right way to approach synchronization between a custom indicator and a strategy that doesn't rely on OnBarUpdate for example?
        use a internal double property instead of a series[0] and populate the doulbe with the most recent data let the strategy call that at any time

        eg:

        var value = myindcator1.MyValueB;

        typically onBarUpdate is used for reading/.setting and doing actions
        onMarketUpdate can be used but will end up with errors due to series/barsarray alignment so you can use TriggetCustomEvent and
        myindcator1.Update()
        the read from a series
        myindcator1.Values[0][0];

        or easier more robust myindcator1.MyValueB;


        You can use this to speed up development of a strategy and have very useful features off the shelf. all open source.




        MicroTrends
        NinjaTrader Ecosystem Vendor - micro-trends.co.uk

        Comment


          #5
          Hi, the TriggerCustomEvent method is used to synchronize the data series when you need to access data from the data series in a non-data-driven event, it has nothing to do with inter-communication between NinjaScript objects. Doing something like this goes beyond the scope of support I am able to provide on the subject, but I have made an example here demonstrating how to set up a property changed event to keep subscribed objects aware of value changes of a global variable:



          Kind regards,
          -ChrisL​

          Comment

          Latest Posts

          Collapse

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