Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to send an update message from one indicator/panel to another indicator/panel?

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

    How to send an update message from one indicator/panel to another indicator/panel?

    I would like to be able to draw one one panel and have it show up in another panel.

    For example, I want to draw a rectangle on one chart and have it appear on all other charts that are linked to the same instrument.

    Question #1. Is there a mechanism to broadcast messages to different panels? Or to listen to messages in an indicator?

    Option # A. Since the data in my case actually gets loaded and saved to the cloud, I build a mechanism to serialize and deserialize all the relevant drawing tools to an xml file that I temporarily save and load from the local file system.

    If there were a good place to hook it, I could check to see if the file has been modified since one panel last loaded or saved it.

    pseudo code:

    Code:
    DateTime lastLoaded;
    
    OnBarUpdate()
        if (lastLoaded < File.GetModifiedDate("myData_GC-12-20.xml")
              update my drawing tools with an invoker
              lastLoaded = DateTime.Now
    Obviously, checking a file in OnBarUpdate() isn't a good idea but.... is there some other way? Checking once per minute isn't horrible.

    Question #2. Is there some function besides OnBarUpdate() or OnRender() that would be a good place to check if my data needs to be reloaded?

    related...

    Question #3. Is there now a way to force a reload of a chart? Basically, a way to run the 'F5' functionality without sending keystrokes.

    Question #4. Has anyone actually made an 'F5' function work using the sending of keys?

    I have heard it speculated about but I haven't seen any code.

    Any other ideas for how I can make edits in one window appear in another window?

    -- -- -- -- -- -- -- -- -- -- -- --

    More info:

    I didn't want to confuse the question with too many details but what I actually built is a system so that storage for these "edits" are stored in the cloud so the edits don't always even come from the machine, location, etc. That all works although you need to press a button to "load/save to the cloud." I'd just like a way for different panels to stay in sync on the same machine.

    #2
    Hello ntdev,

    Thanks for your questions.

    Question #1. Is there a mechanism to broadcast messages to different panels? Or to listen to messages in an indicator?

    Indicators are designed to operate independently on the panel they own. You could have an indicator added to each panel that reads/writes to static variables in an AddOn or searches for specific indicators in each chart to interact with public methods of the indicator, and that may accomplish your goal. Both approaches would be unsupported. I can provide rough examples, but making the approach work for you would be something you would need to do on your own and we could not provide further assistance other than making you aware of the idea.

    Using static variables in an AddOn - https://ninjatrader.com/support/foru...est#post733956

    Also see "FindMeChangeMeChangeSharpDXColor" attached to this thread.

    To reiterate for other readers: These approaches are 100% unsupported by NinjaTrader support staff.

    Question #2. Is there some function besides OnBarUpdate() or OnRender() that would be a good place to check if my data needs to be reloaded?

    Some ideas would be to check for user interaction on the chart through mouse clicks to see if you need to refresh anything from your external source, or to use a timer to have updates received on a timed interval. You could also consider using a combination of the two.

    From a supported perspective once the script is loaded, it would already have processed historical data and realtime data would be streaming and creating new bars. Reloading data should not be necessary under regular uses.

    Question #3. Is there now a way to force a reload of a chart? Basically, a way to run the 'F5' functionality without sending keystrokes.

    Question #4. Has anyone actually made an 'F5' function work using the sending of keys?

    There is ReloadAllHistoricalData() but this method is intended to be used with connection loss handling only. I am not aware of any other way to programmatically reload NinjaScripts than using SendKeys to invoke the F5 key.

    https://ninjatrader.com/support/help...oricaldata.htm

    I cannot provide any further insight for the unsupported topics brought up here, but we will happily leave the thread open for other community member feedback.

    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Wow, Jim. GREAT ANSWERS!!!

      That's exactly what I needed to know and I can take it from here with one more question.

      Question #5. Let's say that I'm a DrawingTool derived object. Is there a way for me to know when I've been deleted by the user?

      I would need a way to tell the indicator that drew me that I'm gone and that things need to be taken care of, recalculated, etc.

      OnStateChange(State.Terminated) also happens in when the whole panel goes away, script is reloaded, etc.

      I'd like to know specifically if I've been removed by the user.

      Comment


        #4
        Hello ntdev,

        I'm glad the detail is helpful.

        I don't have a supported solution other than looping through the chart's DrawObjects collection and then checking if an object is removed from the collection and to set variables that would signal if your scripts have attempted to remove the object that was just removed.

        Using unsupported approaches, you could consider subscribing to a ChartScale's ChartObjects collection's CollectionChanged event and then identifying if an item removed is what your script is removing.

        However, We would not be able to identify if the drawing object is removed from a script you have not created or if the object was removed from the user.

        DrawObjects collection - https://ninjatrader.com/support/help...rawobjects.htm

        Unsupported example using ChartObjects.CollectionChanged event - https://ninjatrader.com/support/foru...423#post677423

        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by soon123, Today, 02:14 AM
        0 responses
        6 views
        0 likes
        Last Post soon123
        by soon123
         
        Started by guilhem, Today, 01:53 AM
        1 response
        6 views
        0 likes
        Last Post sgkcfc
        by sgkcfc
         
        Started by elkingonzalez, 11-24-2020, 09:59 AM
        4 responses
        41 views
        0 likes
        Last Post MrSmart
        by MrSmart
         
        Started by Photon66, Today, 12:03 AM
        0 responses
        9 views
        0 likes
        Last Post Photon66  
        Started by morrnel, Yesterday, 09:38 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Marco  
        Working...
        X