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

share Data between two Chart

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

    share Data between two Chart

    Hello to the forum!

    Unfortunately I can not solve a problem and ask for support.

    In a chart Write, I set calculations that I want to use in another chart Read.
    For the sake of simplicity we assume that in chart Write with 1000 bars I count a counter from 1 to 1000.
    My (public static int) WriteArray [0] correctly displays these numbers for every bar from 1 - 1000.

    I would now like to use the result of this calculation in chart Read (1000 bars).
    I assign ReadArray = Write.WriteArray and get the value 1000.
    (ReadArray [0] = Write.WriteArray [0] returns the value 0.)

    The chart Read should represent all (!) Numbers from 1 - 1000 from bar 1 to bar 1000.
    I tried to read the ReadArray or the Write.WriteArray with the methods
    for (int i = 0; i <(..) Array.Length; i ++) {...}
    foreach {...}
    while {...}

    But I always only get the last value 1000 in chart Read.

    If I print in the chart Read Write.WriteArray [x] at the position x (x = 100, 500, ...), I always get 0;
    Is it possible that the data will be lost? On the other hand the last value 1000 is present.

    The problem should be in the historical assignment. (State == State.Historical) does not solve the problem.
    My WriteArray is one-dimensional and contains no further indexing.
    Because the number of bars in both charts is identical, I tried to synchronize the arrays with a counter in the chart read.
    Unfortunately, without success: chart Read tries to load the data and gets no result ....

    I am thankful for every hint!

    #2
    Hello user10,

    There is information missing from your post.

    By default objects like arrays are not accessible between two instances of scripts.

    This means you would need to find the other instance of the script in question by looping through all charts and looping through all indicators on the chart using unsupported methods.

    Or you would need to use static objects in a custom namespace and class outside of the script.

    Or you would need to read and write to a text file.

    Are you using static methods that are in a custom namespace and class?

    Are you writing and reading from a file?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Write and read on SSD is too slow.

      So I try a static array and contact the forum, because support does not support that.

      Here is a file that represents my problem.

      Thanks for the support!
      Attached Files

      Comment


        #4
        Hello user10,

        The strategies you have provided do not reference each other in any way and do not share data in any way.

        The arrays created are within the scope of the instance of the class and can only be accessible in that class.

        Below is a link to an example of using static classes in custom namespaces.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          The use of the proposed method transmits only real-time data for me ....
          Zip file attached.
          How can I synchronize the Write and Read classes so that I can access the Write class historical data in Class Read?
          Thank you!
          Attached Files

          Comment


            #6
            Hello user10,

            It is not supported by NinjaTrader to have two scripts communicate and share data.

            However, this can be achieved by using static objects in a static class in a custom namespace.

            The MySharedMethodsAddonExample.zip I have posted in my previous post demonstrates this.

            You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rhyminkevin, Today, 04:58 PM
            3 responses
            47 views
            0 likes
            Last Post Anfedport  
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            14 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            50 views
            0 likes
            Last Post futtrader  
            Working...
            X