Announcement

Collapse
No announcement yet.

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 chartchartchart, Today, 08:08 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Emily  
            Started by andreslazor7, Today, 08:08 AM
            2 responses
            12 views
            0 likes
            Last Post andreslazor7  
            Started by FatCanary, Today, 08:09 AM
            2 responses
            5 views
            0 likes
            Last Post FatCanary  
            Started by vantojo, 01-12-2021, 02:13 PM
            15 responses
            196 views
            0 likes
            Last Post FatCanary  
            Started by nailui, Today, 07:26 AM
            0 responses
            24 views
            0 likes
            Last Post nailui
            by nailui
             
            Working...
            X