Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Plotting

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

    #16
    Originally posted by DaFish View Post
    Hi yes there will be savings.

    My indicators I am adding on the chart are:

    DoubleStochastics
    EMA
    CCI
    FisherTransform

    If I add these as indicators - AND - the strategy needs needs them too, so I am RECALCULATING the same indicators each time.

    If I can access the pubilc ISERIES from the strategy, then that is all I need. I don't need to recalculate them so I am saving CPU cycles by only doing it once.
    What difference does it make?

    If you want to read the indicator on the chart by multiple strategies, then all the strategies must be using the exact same parameters for the indicator. In which case, NT already takes care of it by caching the first copy that would be created by AddChartIndicator().

    If the strategies have different parameters for the indicator instances that they are calling, then as the instance on the chart has essentially only one set of parameters, the strategies cannot all read it to sensible ends; or at any rate, only the strategies that have the exact same parameters can get anything useful from the output.

    It seems to me that you are postulating a problem that has already been solved by NT, and then using a more convoluted manner to reach the same effect.

    Comment


      #17
      I should note that during this process we discovered that, in NinjaTrader 8, a cached copy of an indicator will not be used by a different NinjaScript object when using the same parameters. This is only done within the same class.

      So, if you use AddChartIndicator(), then in the same NinjaScript object you use an indicator method to reference the same indicator with the same parameters, that is the scenario in which a cached copy will be used for the second reference. But, this will not occur simply by calling an indicator method and using the same parameters as an indicator already applied to the chart.
      Dave I.NinjaTrader Product Management

      Comment


        #18
        Originally posted by NinjaTrader_Dave View Post
        I should note that during this process we discovered that, in NinjaTrader 8, a cached copy of an indicator will not be used by a different NinjaScript object when using the same parameters. This is only done within the same class.

        So, if you use AddChartIndicator(), then in the same NinjaScript object you use an indicator method to reference the same indicator with the same parameters, that is the scenario in which a cached copy will be used for the second reference. But, this will not occur simply by calling an indicator method and using the same parameters as an indicator already applied to the chart.
        I stand corrected then. I seem to remember that in NT7, that supposedly was what happened with the cached copy. In fact, it was to bypass the search through the cache that I started recommending that my colleagues use named instances of indicators in their strategies, so that the object reference is always definite, with no need to go searching a cache, which was particularly onerous if one used COBC false. I guess that I must have been wrong.

        I will just take your word for it, as unfortunately, all my notes on the matter (NT7, not NT8) went up in smoke with all the other stuff when my apartment was razed by fire 2+ years ago, and I never bothered to recreate a lot of the test scenarios that I had used to poke around NT internals.

        Now, that having been said, it would appear the Richard Todd, then of movethemarkets.com came to the same conclusion, and the same answer! The original site is gone, but here is a link from the Internet Archive: http://web.archive.org/web/201004282...ds/rwt/rwt004/

        Then again, a software engineer's life is more like the attached picture.
        Attached Files

        Comment


          #19
          This is a feature request, which I think is applicable to the discussion here. I would like to see the ability for an indicator or other object to be able to made global - easily - My suggestion to implement this is on the UI for creating an indicator / object, there be 2 additional items, or maybe even only one.
          1 - a check box to say it is global ( if checked makes # 2 appear)
          2 - an input field where you would give it a name to be accessed by.

          You could presume the user intended it to be global by the entering of a name, and eliminate #1.

          To take this to another level. It would be really great if you were able to specify the level of global-ness (my new word). By this I mean you would have either a selection box or set of check boxes, where you can specify the global-ness to be either shared by the tabs in a window, all windows in a workspace, or global across all of NT.

          Just think and wishin'

          John
          Last edited by joromero; 09-05-2015, 08:04 AM.

          Comment


            #20
            Thank you so much Dave. NT Support rocks ! You and all the team there never cease to impress me with your "above and beyond" efforts.

            That said, I do want to ensure that these are just not my requests for things to address my shortcomings in knowledge of how to use the product out of the box.

            I see the response from koganam, and Dave's response to him on this topic, and I must ask if this new feature request is valid. I believe that joromero post #19 sums up my request 110%. That is what I think I have been trying to say, and I do believe this would be efficient and useful.

            For my simple mind the benefits are:
            1) The indicator is allocated on the screen and computed ONCE (regardless of indicator or strategy)
            2) Memory and CPU are efficiently used
            3) Strategy code complexity is reduced (right now I am computing the indicator in the strategy so I can use it to determine trades and see it). That code would be gone.

            This is why I have been exploring AddOns and my own code class. So I could write the code once, and call it from an indicator and/or strategy.

            I would welcome any suggestion and guidance on how to use the product more efficiently.

            Comment


              #21
              This is a terrific idea. To expand on the use of this.

              I trade SPXL and SPXS - S&P 500 3X bull and bear ETFs. I only want to be in one at a time, but must run the same strategy on both at the same time. Due to some programming complexities, I sometimes find the strategy "auto" trading both at the same time. Using the ideas below, I would be able to set/read which one of them has the ball. I could now do inter-strategy "state" programming - as well a reading current values from indicators.

              Originally posted by joromero View Post
              By this I mean you would have either a selection box or set of check boxes, where you can specify the global-ness to be either shared by the tabs in a window, all windows in a workspace, or global across all of NT.

              Just think and wishin'

              John

              Comment


                #22
                Originally posted by DaFish View Post
                This is a terrific idea. To expand on the use of this.

                I trade SPXL and SPXS - S&P 500 3X bull and bear ETFs. I only want to be in one at a time, but must run the same strategy on both at the same time. Due to some programming complexities, I sometimes find the strategy "auto" trading both at the same time. Using the ideas below, I would be able to set/read which one of them has the ball. I could now do inter-strategy "state" programming - as well a reading current values from indicators.
                You could actually do that right now, in your simplified case. Just use a static bool, in a specific namespace or the global namespace. Read that bool to determine if a strategy is allowed to take orders or not. Each strategy can set the bool when in a trade, so that the others automatically cannot trade, as the bool is set. The bool is reset when the strategy that set it goes flat, after which it is a matter of the "firstest with the mostest".
                Last edited by koganam; 09-15-2015, 05:28 PM. Reason: Corrected spelling.

                Comment


                  #23
                  Originally posted by koganam View Post
                  You could actually do that right now, in your simplified case. Just use a static bool, in a specific namespace or the global namespace.
                  Thanks koganam. Would you be able to point me in the direction of where to find, and how to use the global namespace on NT7 and NT8 please? I am still using NT7 as well.

                  Thanks a lot.

                  Comment


                    #24
                    Originally posted by DaFish View Post
                    Thanks koganam. Would you be able to point me in the direction of where to find, and how to use the global namespace on NT7 and NT8 please? I am still using NT7 as well.

                    Thanks a lot.
                    If you declare anything that is not in a namespace, it is automatically in the global namespace. Merely writing a .cs file and declaring any entities in it, provided you do not enclose such declarations, would place such entities in the global namespace.

                    Comment


                      #25
                      Hi Dave. I had another thread on getting CCI in multi time frame working. That was not released in Beta 4, so I hadn't tried this yet (waiting for Beta 4 fix).

                      I really need to get this to work so I can continue on with NT8.

                      ISSUE 1) This example you provided crashed when it went real time. I have tried to fix it, but I can't seem to do that. Can you have a look at what I did please?

                      The code you provided ALMOST does what I wanted - Strategy accesses an indicator value on a the SAME chart.

                      Can the same methodology get this functionality:

                      Chart 1: Contains 15 min chart, with the strategy on it that will access the CCI on CHART 2

                      Chart 2: Contains the same security, but at a 30 min chart with CCI on it.

                      I want the strategy on Chart 1 to access the CCI on Chart 2.

                      Can this be done ?



                      Originally posted by NinjaTrader_Dave View Post
                      I've got an update for you. We are well into undocumented and unsupported code territory on this one, but we were able to figure out a way to obtain the current value of the existing indicator instance already applied to a chart. There are a few key pieces here that must be in place, so I've attached a sample script including all of the necessary pieces.

                      Key #1) You must create a new object of the same type as the indicator you are looking for, then instantiate that object by assigning a reference to the chart-applied indicator's index within the ChartControl.Indicators[] collection. At this point, the object defined in your strategy will contain a reference to the indicator on your chart, NOT a new instance. We were able to verify this by comparing an internal instance ID which you will not be able to access. This ID is unique for each instance, and we verified that both the indicator on the chart and the one held by reference in the object created by the strategy do indeed share the same instance ID.

                      Key # 2) You must call .SetInput(Input) on the object created in your strategy before trying to access its values. Without this, the object's values appear to only be set once, during Bar # 1, and are not updated again.

                      You will be able to see both of these keys in play in the attached sample scripts. Keep in mind that this is not a process designed and intended to be used in NinjaScript, so I cannot guarantee that it will not cause unexpected results down the road. But it should do the trick of limiting the number of redundant instances you are creating via your strategy.

                      Another thing to keep in mind -- a supported method of accomplishing the goal of limiting the number of instances would be to use AddChartIndicator() in your strategy, and just let the strategy handle plotting the indicator on the chart, rather than applying a separate instance to the chart manually.
                      Attached Files

                      Comment


                        #26
                        Originally posted by NinjaTrader_PatrickH View Post
                        Hello DaFish,

                        Thank you for your post.

                        We have updated the reference samples for NinjaTrader 8. Please take a look at the following link for the NinjaTrader 8 version of the Plotting From Within A Strategy sample: http://ninjatrader.com/support/forum...ead.php?t=6651
                        Patrick the link from your last post is for NT7:
                        http://ninjatrader.com/support/forum...ead.php?t=6651
                        Would you point me to the NT8 code?
                        Thanks

                        Comment


                          #27
                          dmitri, in the end we decided not to convert that particular reference sample for NinjaTrader 8, because plotting is built in to the Strategies namespace in NinjaTrader 8. Rather than using the previous method, you can now simply use AddPlot() directly in your strategy, which be a more efficient use, as well.

                          DaFish -- Just to make sure that your last post did not fall through the cracks -- we are continuing to look into that particular issue, and are tracking it with ID # NTEIGHT-8731.
                          Dave I.NinjaTrader Product Management

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by jjanguda, Today, 10:15 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post jjanguda  
                          Started by ScorpioTravis, Today, 09:41 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post ScorpioTravis  
                          Started by DTSSTS, Today, 09:41 PM
                          0 responses
                          7 views
                          0 likes
                          Last Post DTSSTS
                          by DTSSTS
                           
                          Started by Segwin, Today, 06:33 PM
                          1 response
                          24 views
                          0 likes
                          Last Post NinjaTrader_ShawnB  
                          Started by bmaltz, Today, 08:14 PM
                          1 response
                          15 views
                          0 likes
                          Last Post NinjaTrader_ShawnB  
                          Working...
                          X