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

Accessing Exposed Variables being calculated on a completely different chart

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

    Accessing Exposed Variables being calculated on a completely different chart

    This is what I'd ike to do:

    Have an indicator on say a TICK index chart expose the end result of that calculation and then have another indicator that grabs the result put that on 5 different charts say 5 min IBM, 2 Min JPM, 5Min ES, 5 Min NQ, and 2 Min DIA. So that the exposed variable of the TICK is grabbed.

    I looked at various threads and I can't seem to find an example on how to do this. What I want to do is have Indicator1 below calculate once and all the other charts grabbing the results. What seems to happen is that every chart will force the indicator1 to calculate so it is being done 5 seperate times, once for each chart that is updating. I want to save on CPU and do not want Indicator1 to cycle for each seperate chart, I just want indicator1 on the TICK chart to calculate once on the ^TICK chart and all other charts to grab the result.

    I'm probably doing it wrong. Can someone advise me as to how to do this properly? Also, this only exposes the last data calculated, how can I pass a Series so that I can grab data from past bars by indexing?

    The best that I've come up with is:

    Indicator1

    In the
    protectedoverridevoid Initialize()
    region:

    Add("^TICK",PeriodType.Second,4);

    then below OnBarUpdate()

    if (BarsInProgress==1)
    exposedStos = Stochastics(BarsArray[
    1],5,3,3)[0];

    Print("exposed stos of ytGVTickStos...."+exposedStos +" name"+name);


    Then in the properties below that:
    [Browsable(false)]
    [XmlIgnore()]
    publicdouble ExposedStos

    {
    get { Update(); return exposedStos; }
    }


    ////////////
    Indicator2 (this is the grab side of the above this goes on seperate charts mentioned abv)

    double testGrab=ytGVTickStos().ExposedStos;
    Print("exposed of grab side..."+testGrab+" name"+name);

    "name is just there to keep track

    #2
    Hi Benske,

    NinjaTrader will create an instance of this indicator and it will be cached internally. The cached version will be reused only if all parameters are exactly identical. If you apply this script to multiple instruments, each instance will be unique and it will never use the cached values.

    If you want only one instance of the indicator, then you could add all the other series into this one script and then they access the needed values within.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hell RyanM,
      The all-cure indicator will be too hard to conquer.
      Benske you can find other way,with C# hopeful power.

      Comment


        #4
        Originally posted by Benske View Post
        This is what I'd ike to do:

        Have an indicator on say a TICK index chart expose the end result of that calculation and then have another indicator that grabs the result put that on 5 different charts say 5 min IBM, 2 Min JPM, 5Min ES, 5 Min NQ, and 2 Min DIA. So that the exposed variable of the TICK is grabbed.

        I looked at various threads and I can't seem to find an example on how to do this. What I want to do is have Indicator1 below calculate once and all the other charts grabbing the results. What seems to happen is that every chart will force the indicator1 to calculate so it is being done 5 seperate times, once for each chart that is updating. I want to save on CPU and do not want Indicator1 to cycle for each seperate chart, I just want indicator1 on the TICK chart to calculate once on the ^TICK chart and all other charts to grab the result.

        I'm probably doing it wrong. Can someone advise me as to how to do this properly? Also, this only exposes the last data calculated, how can I pass a Series so that I can grab data from past bars by indexing?

        The best that I've come up with is:

        Indicator1

        In the
        protectedoverridevoid Initialize()
        region:

        Add("^TICK",PeriodType.Second,4);

        then below OnBarUpdate()

        if (BarsInProgress==1)
        exposedStos = Stochastics(BarsArray[
        1],5,3,3)[0];

        Print("exposed stos of ytGVTickStos...."+exposedStos +" name"+name);


        Then in the properties below that:
        [Browsable(false)]
        [XmlIgnore()]
        publicdouble ExposedStos

        {
        get { Update(); return exposedStos; }
        }


        ////////////
        Indicator2 (this is the grab side of the above this goes on seperate charts mentioned abv)

        double testGrab=ytGVTickStos().ExposedStos;
        Print("exposed of grab side..."+testGrab+" name"+name);

        "name is just there to keep track
        Use a static variable to hold the value that you want to access globally, so to speak. It may be possible to declare and populate a static DataSeries though I have never tried. If not, then you can always use an ArrayList to hold the values, and you can access the values in the same indexed manner that is used for a DataSeries. In fact, I have a sneaky suspicion that DataSeries are being implemented uses some kind of list construct.

        ref: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

        Comment


          #5
          I do some test on Global statics,It is very dangerous:
          1)Shared values over ride.
          2)Shared values access simutaneously.
          At last,I give up.I turned to C# Inheritance,then NINJA Service told me Inheritance Forbiden.
          Now,I just copy same code and shared values for every Inidcator,That is the short cut.

          Comment


            #6
            Originally posted by maorachow View Post
            I do some test on Global statics,It is very dangerous:
            1)Shared values over ride.
            2)Shared values access simutaneously.
            At last,I give up.I turned to C# Inheritance,then NINJA Service told me Inheritance Forbiden.
            Now,I just copy same code and shared values for every Inidcator,That is the short cut.
            Now you know why I am leery of using static variables to pass values.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by AttiM, 02-14-2024, 05:20 PM
            11 responses
            184 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by fernandobr, Today, 09:11 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by timmbbo, Today, 08:59 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by KennyK, 05-29-2017, 02:02 AM
            2 responses
            1,281 views
            0 likes
            Last Post marcus2300  
            Started by itrader46, Today, 09:04 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X