Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can a strategy read indicator values from a DIFFERENT chart

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

    How can a strategy read indicator values from a DIFFERENT chart

    Hi. There are a few reasons I need to do this.

    1) CCI in multi time frame in beta 3/4 is broken and I can't use it
    2) DoubleStochasticOptimized doesn't work in multiple time frames - so I can't use that.

    I need to explore declaring variables on CHART 1's indicator in the global namespace and pulling data into CHART 2 via a strategy that I can now use to trade.

    What I would like to do is:

    1) Chart 1 - 30 min chart of SPXL - run a CCI and doublestochasticoptimized on that (this works fine on the one time frame)

    2) Chart 2 - 15 min chart of SPXL - running my strategy. I want to READ the value of the CHART 1's CCI and doublestochasticoptimized and use that in the strategy.

    Some questions:
    1) Can I use in my strategy (running on CHART 2): AddChartIndicator(SMA(20)); but add that to a DIFFERENT chart that the strategy is on? (IE: CHART 1 the one running in the 30 min indicators)

    2) How can I accomplish this in other ways using the global namespace ? If I am to use the global name space, How would I exactly reference a chart/indicator/variable by name?

    Originally posted by koganam View Post
    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.

    #2
    Originally posted by DaFish View Post
    Hi. There are a few reasons I need to do this.

    1) CCI in multi time frame in beta 3/4 is broken and I can't use it
    2) DoubleStochasticOptimized doesn't work in multiple time frames - so I can't use that.
    Did you report those issues previously or is this such a report?

    Comment


      #3
      Originally posted by sledge View Post
      Did you report those issues previously or is this such a report?
      Hi, yes I did on the CCI, the DoubleStochasticOptimized is a downloaded program that is not part of the package. That said, do have a support ticket in on it.

      http://ninjatrader.com/support/forum...ad.php?t=77647 (open CCI in multiple time frame issue)

      I'll open another thread in the NT7 area for DoubleStochasticOptimized to see if someone can help me making this work in Multiple Time Frames.

      Comment


        #4
        Originally posted by DaFish View Post
        Hi. There are a few reasons I need to do this.

        1) CCI in multi time frame in beta 3/4 is broken and I can't use it
        2) DoubleStochasticOptimized doesn't work in multiple time frames - so I can't use that.

        I need to explore declaring variables on CHART 1's indicator in the global namespace and pulling data into CHART 2 via a strategy that I can now use to trade.

        What I would like to do is:

        1) Chart 1 - 30 min chart of SPXL - run a CCI and doublestochasticoptimized on that (this works fine on the one time frame)

        2) Chart 2 - 15 min chart of SPXL - running my strategy. I want to READ the value of the CHART 1's CCI and doublestochasticoptimized and use that in the strategy.

        Some questions:
        1) Can I use in my strategy (running on CHART 2): AddChartIndicator(SMA(20)); but add that to a DIFFERENT chart that the strategy is on? (IE: CHART 1 the one running in the 30 min indicators)

        2) How can I accomplish this in other ways using the global namespace ? If I am to use the global name space, How would I exactly reference a chart/indicator/variable by name?
        I may very well be wrong, but it seems there is a fundamental misunderstanding of what a chart is supposed to be. A chart is supposed to present an essentially 2-dimensional visual representation of price movement (or movement of price derivatives), and provide a canvas for other visual data that a user may want to record or access.

        To do so, a trading package reads data from some source, then provides visual information. The visual information on the chart is NOT the data; the underlying data exists independently of the chart. Maybe, you would find an easier time if you analyzed and thought of the underlying data instead of what may be happening on a chart.

        Just my$0.02.

        Comment


          #5
          Although, I agree with Koganam, I even more agree with DaFish. This also ties back to my comments on a thread about the desire to more easily make "things" more global at the UI level, vs only at the coding level. To provide the ability to be able to make "things" plots, etc individually global and give them a name to be accessed by, as well as the scope of "globality" Chart, Workspace, etc, is the level of abstraction I think would be a truly great jump forward. I presume this would take some design thinking on NT8s staff to implement,

          If you think this is valuable, reply to vote / support this. As you can see, this design would provide answers to many of the requests coming in.

          John

          Comment


            #6
            Originally posted by joromero View Post
            Although, I agree with Koganam, I even more agree with DaFish. This also ties back to my comments on a thread about the desire to more easily make "things" more global at the UI level, vs only at the coding level. To provide the ability to be able to make "things" plots, etc individually global and give them a name to be accessed by, as well as the scope of "globality" Chart, Workspace, etc, is the level of abstraction I think would be a truly great jump forward. I presume this would take some design thinking on NT8s staff to implement,

            If you think this is valuable, reply to vote / support this. As you can see, this design would provide answers to many of the requests coming in.

            John
            I think that I already explained how to do that if that is your bent. Make a static object, populate it by a single other object, and other objects can then access the data in the static object.

            That having been said, the problems inherent in accessing data in such a manner, is why OOP was invented in the first place: we wanted to encapsulate data, and the methods to manipulate said data, in such a manner such that we do not have side effects, as the only methods of access have to be defined in the object itself.

            It is the main reason why many books on OOP with C# in particular, warn you to only use static variables if there is absolutely no alternative. Data that is universally modifiable is just asking for unintended side-effects.

            IMHO, and it is only my opinion, this request should be ignored. If punters want to return to methods used in the bad days of procedural (and even structured) programming, that is their prerogative: those who supply OOP frameworks should stick to "best practices" of OOP.
            Last edited by koganam; 09-19-2015, 10:46 AM. Reason: Corrected misspelling.

            Comment


              #7
              Koganam,

              You are absolutely correct relative to OOP in it's intent and structure. Also, I admit, I am a part time programmer only coding for myself. That being said, there are a lot of users of NT that are not high level / competent programmers. Also, there are instances where people have purchased indicators, and other things for NT, that are following good OOP structure, has not exposed plots / etc. This is the area I would think having the capability with NT8 to have a defined, limited data sharing capability would be very beneficial. It would be a structure where you can define the extent of 'global' shared access would be (Window -> multiple tabs, Workspace -> multiple windows, or Global - -> all workspaces and strategies. The ability to provide a name it would be know as, which would allow you to have multiple instances of an indicator in a chart, but would not have to "share" them all and try to figure out some internal naming convention, because a user has 2 or more instances of an indicator running. I for one use the same indicator in multiple windows each with a different time frame in a workspace. I would not want to have to create unique multiple copies of the same indicator, just to share it. To complicate it more, I use the same indicator (different parms) on my ES day trading (multiple timeframes) and my Market Analyzer Workspace to manage my long term (Daily, Weekly) investments / trades (daily / weekly timeframes). So I do feel there is a real value to be able to share plot outputs.

              This could be implemented, via a check box on the indicator UI, that if checked would make a plot global. If checked, then the additional lines would appear where the user would
              a - Global name
              b - Global reach - Window / Workspace / All

              This would all be read only, except for the creator (initial instance).

              If the user is wanting just a variable that they would use to sync, or make updatable via multiple indicators / strategies / drawing objects, etc, then I agree that is programmer controlled. But again, for the less talented, it would be nice for NT8 to create the facility to have a definition of "Global" for a variable type.

              John

              Comment


                #8
                Originally posted by koganam View Post
                I think that I already explained how to do that if that is your bent. Make a static object, populate it by a single other object, and other objects can then access the data in the static object.
                I believe you explained it to me too, but I can't seem to make it work, or find examples that work to make this work. NT Support gave me an example that worked with HISTORICAL data, but doesn't work in real time. Awaiting some guidance from NT on that.

                Originally posted by koganam View Post
                That having been said, the problems inherent in accessing data in such a manner, is why OOP was invented in the first place: we wanted to encapsulate data, and the methods to manipulate said data, in such a manner such that we do not have side effects, as the only methods of access have to be defined in the object itself.

                IMHO, and it is only my opinion, this request should be ignored. If punters want to return to methods used in the bad days of procedural (and even structured) programming, that is their prerogative: those who supply OOP frameworks should stick to "best practices" of OOP.
                With respect, think you are missing the big picture.

                The BIG PICTURE is we need the NT Platform to trade securities - meaning I don't care about why OOP was created. Yes we need to have OOP rules adhered to, but I would hazard a guess that the general population of NT users (like me) are not core C# programmers. I need:

                1) To efficiently use my hardware resources (CPU, Memory) and efficiently apply indicators and strategies to charts.

                This is not currently happening because I am applying the same indicator code to charts with Indicators and Strategies - doubling up my code and using more CPU and memory. I have to have a separate machine with my charts running because it is getting too busy and can't keep up to the market (last Friday was a good example in a very busy market.

                2) To EASILY code strategies to auto trade the market. In my case, I use multiple time frames. This is NOT easy to figure out, where to put code, when bars get executed, BIP0, 1, 2...

                It makes sense to me that an indicator applied to a chart should be accessible to another CHART for efficiency reasons. Apply it once, set a name, have another indicator or strategy go and read the latest calculated data.

                I have 3 charts each on SPXL and SPXS in 3 different time frames, I want to know from a central strategy what is going on in each of them. I can't do that easily. Right now, I have to code 1 chart for SPXL with 3 time frames, and another chart of SPXS with 3 time frames and I can't provide the "state" between these 2. Ideally it would be 1 strategy, maybe that is the answer....

                There is a way to expose the charts/indicators properly in C# - the gurus can figure it out.
                Last edited by DaFish; 09-21-2015, 10:26 AM.

                Comment


                  #9
                  Originally posted by DaFish View Post
                  I believe you explained it to me too, but I can't seem to make it work, or find examples that work to make this work. NT Support gave me an example that worked with HISTORICAL data, but doesn't work in real time. Awaiting some guidance from NT on that.



                  With respect, think you are missing the big picture.

                  The BIG PICTURE is we need the NT Platform to trade securities - meaning I don't care about why OOP was created. Yes we need to have OOP rules adhered to, but I would hazard a guess that the general population of NT users (like me) are not core C# programmers.
                  I am not missing the big picture. In fact, that is what I am looking at. The platform needs to be supported, which means that things need to be done in a standard and supportable manner. One of the biggest problem supporting programmers when we were using procedural, and even structured programming, were the side effects of code modifying values, and then not being able to track down what the heck modified the value. You may not care why NT chose, and why most programmers have moved to using OOP. That is your prerogative. It is also the prerogative of those who supply frameworks whether or not they want to be sloppy. Fortunately, that is not our call. As I said, I am just blowing a hot-air opinion that is only mine. NT will decide what to do, not I.
                  I need:

                  1) To efficiently use my hardware resources (CPU, Memory) and efficiently apply indicators and strategies to charts.

                  This is not currently happening because I am applying the same indicator code to charts with Indicators and Strategies - doubling up my code and using more CPU and memory.
                  That is a problem with your coding, not the platform. OOP efficiently allows you to create data structures and the code to manipulate said structures. If you instead choose to duplicate and encapsulate the code that is in one object, rather than create an instance of the object, and use its access methods, that is a programming choice. Heck, sometimes, on rare occasions, it may even be the best choice. It is still an issue of programming style and choice, not a framework issue.

                  The solution to your problem is to write more efficient code, not to ask for the platform to start violating OOP principles.
                  I have to have a separate machine with my charts running because it is getting too busy and can't keep up to the market (last Friday was a good example in a very busy market.

                  2) To EASILY code strategies to auto trade the market. In my case, I use multiple time frames. This is NOT easy to figure out, where to put code, when bars get executed, BIP0, 1, 2...
                  Again, unfortunately that you cannot figure it out, does not make the solution, an abandonment of good practices. If that is your bent, great, but that is still just your preference. All preferences are valid: which means that my alternative of sticking to OOP practices is also a valid one. We just happen to differ. Again, fortunately, it is not ours to decide. NT will decide if they want to go down that path.
                  It makes sense to me that an indicator applied to a chart should be accessible to another CHART for efficiency reasons. Apply it once, set a name, have another indicator or strategy go and read the latest calculated data.
                  Again, charts are merely a visual representation of the data. The data is accessible, regardless. If you program to the data, the chart is irrelevant. Indeed, the proof of that statement is that you can run a strategy from the NT Control Center, with absolutely no association with a chart whatsoever. What needs changing is not NT; it is your thoughts about the all-encompassing nature of a chart. A chart is important to the eyes of a discretionary trader, especially: a chart is of no relevance to the code that is processing trade entry, exit and management. The data is the driver; the chart is merely ONE reflector of that data.

                  I have 3 charts each on SPXL and SPXS in 3 different time frames, I want to know from a central strategy what is going on in each of them. I can't do that easily. Right now, I have to code 1 chart for SPXL with 3 time frames, and another chart of SPXS with 3 time frames and I can't provide the "state" between these 2. Ideally it would be 1 strategy, maybe that is the answer....

                  There is a way to expose the charts/indicators properly in C# - the gurus can figure it out.
                  Again, no need. The data can be accessed regardless of whether it is on a chart or not. Speak to the data itself.

                  The major reason why nobody seems to have done that "Let the chart read the data and process it, then read the chart to get to the same data", is precisely because the so-called gurus that you talk about understand that the data is the focus of the processing, and a chart merely reflects that data. It is more efficient to handle the data directly instead of first having a chart process the data, then read said data, a process which now includes a high resource intermediary (drawing a chart involves multiple context and thread switches between various operating system and graphics card processes) reading data and processing it, just so that the same data can be read from the intermediary. Then again, as I am not a guru, I may just be bloviating.

                  What you are proposing will have the exact opposite effect at high load, as the required rapid chart updates will mean that the code reading the chart in order to trade, is now gated by the ability of the chart to keep up, quite apart and in addition to, the framework having to cope with the data tsunami in the first place. The most efficient way for the trading code to process data, will always be to process the data directly, instead of waiting for a chart to first process the data, so that the trading code can then read that same data for processing. The extra chart step just means more processing time.

                  Moreover what you are proposing actually says: "There MUST be a chart", in order for the trading code to read the data off the chart, for subsequent processing: a more restrictive condition, than processing the data directly, whether or not there is a chart in the mix.

                  Do you want to see what often happens even when we try to stick to good practices? Take a gander at the picture.
                  Attached Files
                  Last edited by koganam; 09-21-2015, 01:41 PM. Reason: Corrected grammar.

                  Comment


                    #10
                    Hi koganam. Thanks for your post, and I am listening and hearing what you are saying. On the topic of OOP, I agree it has to be done correctly - no questions there. That said, I am not sure why we can't have a method to communicate to the other chart/indicator/strategy (whatever object) and get and set data through a message queue or something (something I used to do way back when...)

                    Lets get into the nitty gritty of what I have to do now to accomplish what I NEED to do to work at the DATA level. I can't ignore the chart, visual level because that is a confirmation for me - so I need both, strategy off the data level, and charts for visual confirmation.

                    NEEDS:
                    1) Trade SPXL - OR - SPXS - one or the other

                    My system uses 3 time frames for each and I will attempt to reference them by BarsInProgress

                    2) BIP0 - this is the display - the visual. I need to display things on this chart for my own visualization of what is going on. I may change this to any of the (3 X 2 = 6 time frames)

                    3) BIP1 - SPXL - RANGE 20 - trade execution level for SPXL
                    4) BIP2 - SPXL - RANGE 40
                    5) BIP3 - SPXL - 30 MINUTE - Trend level for SPXL and SPXS
                    6) BIP4 - SPXS - RANGE 20 - trade execution level for SPXS
                    6) BIP5 - SPXS - RANGE 40

                    What you are saying is that I put all of this in 1 strategy, then plot what I want on BIP0, and that way I don't need to do strategy to strategy or chart to chart communication because they all the data is in the same strategy. That way I can do trade control all in the 1 strategy and I don't need to risk the breaking of rules in OOP.

                    Does this make sense to you?

                    Comment


                      #11
                      Originally posted by DaFish View Post
                      Hi koganam. Thanks for your post, and I am listening and hearing what you are saying. On the topic of OOP, I agree it has to be done correctly - no questions there. That said, I am not sure why we can't have a method to communicate to the other chart/indicator/strategy (whatever object) and get and set data through a message queue or something (something I used to do way back when...)

                      Lets get into the nitty gritty of what I have to do now to accomplish what I NEED to do to work at the DATA level. I can't ignore the chart, visual level because that is a confirmation for me - so I need both, strategy off the data level, and charts for visual confirmation.

                      NEEDS:
                      1) Trade SPXL - OR - SPXS - one or the other

                      My system uses 3 time frames for each and I will attempt to reference them by BarsInProgress

                      2) BIP0 - this is the display - the visual. I need to display things on this chart for my own visualization of what is going on. I may change this to any of the (3 X 2 = 6 time frames)

                      3) BIP1 - SPXL - RANGE 20 - trade execution level for SPXL
                      4) BIP2 - SPXL - RANGE 40
                      5) BIP3 - SPXL - 30 MINUTE - Trend level for SPXL and SPXS
                      6) BIP4 - SPXS - RANGE 20 - trade execution level for SPXS
                      6) BIP5 - SPXS - RANGE 40

                      What you are saying is that I put all of this in 1 strategy, then plot what I want on BIP0, and that way I don't need to do strategy to strategy or chart to chart communication because they all the data is in the same strategy. That way I can do trade control all in the 1 strategy and I don't need to risk the breaking of rules in OOP.

                      Does this make sense to you?
                      Now, you are talking. The chart just monitors and tells you what the code did and does. If the chart tells you something other than what you expect, then it just means that it is time to modify the code.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bmartz, 03-12-2024, 06:12 AM
                      5 responses
                      32 views
                      0 likes
                      Last Post NinjaTrader_Zachary  
                      Started by Aviram Y, Today, 05:29 AM
                      4 responses
                      13 views
                      0 likes
                      Last Post Aviram Y  
                      Started by algospoke, 04-17-2024, 06:40 PM
                      3 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by gentlebenthebear, Today, 01:30 AM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by cls71, Today, 04:45 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X