Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Streamwrite / Streamread to Bypass Indicator Referencing

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

    Streamwrite / Streamread to Bypass Indicator Referencing

    Hello community!

    I am trying to reference the values I need between two indicators. One indicator calculates via Calculate.OnEachTick and the other Calculate.OnBarClose. I really want to avoid having to reference FROM the OnBarClose indicator, as this would require adding a tick series and running it on OnEachTick, which would be costly because this indicator is performing a lot of calculations.

    To make matters worse, what I need from the OnBarClose indicator is a list of structs, which I don't even know how I would go about referencing.

    A solution I'm considering is to Streamwrite the list of structs from the OnBarClose indicator to a file and then Streamread it from the OnEachTick indicator only when I need the values. At first glance, this sounds like it would be a lot easier on performance and "cleaner", if that makes any sense. But, I'm wondering how I can ensure the correct order of operations. Does the order in which indicators appear in the Indicators window of a chart determine the order in which they're calculated? Or, are they calculated asynchronously? If the latter is the case, how can I guarantee I'm getting the latest values?

    If I attempt the write / read solution for referencing the list values of another indicator, is there anything I should be aware of that I'm not thinking of?

    Thanks in advance for any participation on this!

    #2
    Hello lunardiplomacy,

    Thank you for your post.

    The order in which the indicators appear in the indicators list does not affect the order in which they are calculated. Each indicator is calculated as often as determined by the indicator's calculate setting (OnBarClose, OnEachTick, OnPriceChange).

    The supported/recommended solution to making sure you are getting the updated values is to add the indicator instance / reference the indicator in your indicator script. This way when you access YourIndicator[0] within the script, this will return the most recent indicator value.

    You should be aware that you may be likely to run into file I/O errors if you have two scripts simultaneously trying to access reading and writing the same file.

    Please let us know if you have any further questions.
    Last edited by NinjaTrader_Gaby; 07-29-2024, 09:35 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    593 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 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
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X