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

Indicator - Who Called Me?

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

    Indicator - Who Called Me?

    Is there a way to determine, within OnBarUpdate, if the indicator is being placed on a chart as opposed to being called from the Market Analyzer? I want to display a message box if the indicator is being placed on a chart but not if it is being called because it is a column in the market analyzer.

    #2
    Hello dkrumholz,

    Thank you for your post.

    I am not aware of a method to check if the indicator is applied to a chart or Market Analyzer.

    However, you may wish to create a custom Market Analyzer column alone for this indicator. You can view the code used for the Market Analyzer columns by going to the following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Market Analyzer

    Custom Market Analyzer columns are not supported in the confines of NinjaScript support but if you have any questions I may be able to point you in the right direction.

    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_PatrickH; 05-26-2013, 08:17 AM.

    Comment


      #3
      Originally posted by dkrumholz View Post
      Is there a way to determine, within OnBarUpdate, if the indicator is being placed on a chart as opposed to being called from the Market Analyzer? I want to display a message box if the indicator is being placed on a chart but not if it is being called because it is a column in the market analyzer.
      Since you asked ---

      1) If you are using the same period, the indicator might be cached in both places and there is only 1 instance from my understanding.

      2) Override Plot, and set a variable...for your OnBarUpdate to check. I'm going to theorize that Market Analyzer won't call that Plot. I could be mistaken..

      Please report back. Thanks.

      Comment


        #4
        Good Thought - But

        Thanks. Not only did that occur to me - but I tested it. I was pretty surprised, but the plot method still got called!

        Comment


          #5
          Originally posted by dkrumholz View Post
          Thanks. Not only did that occur to me - but I tested it. I was pretty surprised, but the plot method still got called!
          Bummer!

          Let's go 1 step further -

          In the overriden plot, is either ChartControl == null ? Bars == null? That could determine if chart or 'something else' such at Market Analyzer.

          Comment


            #6
            I didn't try that - but I will. Thanks! I'm dealing with how to create a global function to write to a stream writer which is a little more pressing for me at the minute.

            Comment


              #7
              Originally posted by dkrumholz View Post
              Is there a way to determine, within OnBarUpdate, if the indicator is being placed on a chart as opposed to being called from the Market Analyzer? I want to display a message box if the indicator is being placed on a chart but not if it is being called because it is a column in the market analyzer.
              Have you simply tried checking if a ChartControl exists? It should only exist on a chart, but not in the Market Analyzer. At least, I hope NT is not putting the indicator on a hidden chart in the Market Analyzer.
              Last edited by koganam; 05-27-2013, 04:35 PM.

              Comment


                #8
                Originally posted by dkrumholz View Post
                Thanks. Not only did that occur to me - but I tested it. I was pretty surprised, but the plot method still got called!
                I should expect that the Plot will get called. After all, it is one of the things that Market Analyzer can use as a comparator.

                Comment


                  #9
                  I don't find ChartControl documented. Where might I find its definition and use?

                  Comment


                    #10
                    Originally posted by dkrumholz View Post
                    I don't find ChartControl documented. Where might I find its definition and use?
                    Oops. ChartControl is not documented or supported by NT. Maybe I should not have mentioned it. However, you can search the forum for it: there are quite a few threads showing what folks have discovered that you can do with it.

                    Comment


                      #11
                      Originally posted by dkrumholz View Post
                      I don't find ChartControl documented. Where might I find its definition and use?
                      Just type in ChartControl

                      I put the code below.

                      if ( ChartControl == null )

                      if that doesn't work, checks Bars

                      if ( ChartControl == null || Bars == null )
                      {
                      //no chart, set a flag
                      }
                      else
                      {
                      // we have a chart, set flag
                      }

                      Comment


                        #12
                        My Workaround

                        Originally posted by sledge View Post
                        Just type in ChartControl

                        I put the code below.

                        if ( ChartControl == null )

                        if that doesn't work, checks Bars

                        if ( ChartControl == null || Bars == null )
                        {
                        //no chart, set a flag
                        }
                        else
                        {
                        // we have a chart, set flag
                        }
                        The above didn't work for me. But I have rather ugly workaround. Just place an additional parameter in your indicator:
                        Code:
                                [Description("0 from a chart, 1 from strategy , 2 from market analyzer")]
                                [GridCategory("Parameters")]
                                public int CalledFrom
                                {
                                    get { return calledFrom ; }
                                    set { calledFrom = value ; }
                                }
                        and take care to set it accordingly when calling from a chart, indicator or strategy.

                        A suggestion for ninja: implement it internally in NinjaScript. Looking at your caching code, it should be simple.
                        Last edited by xTrader1; 01-01-2014, 08:41 AM.

                        Comment


                          #13
                          Originally posted by xTrader1 View Post
                          The above didn't work for me. But I have rather ugly workaround. Just place an additional parameter in your indicator:
                          Code:
                                  [Description("0 from a chart, 1 from strategy , 2 from market analyzer")]
                                  [GridCategory("Parameters")]
                                  public int CalledFrom
                                  {
                                      get { return calledFrom ; }
                                      set { calledFrom = value ; }
                                  }
                          and take care to set it accordingly when calling from a chart, indicator or strategy.

                          A suggestion for ninja: implement it internally in NinjaScript. Looking at your caching code, it should be simple.
                          It'd be a good idea to make a enum with easier to understand names like calledFromChart, instead of integers such as 0 and 1.

                          Comment


                            #14
                            Originally posted by cdjindia View Post
                            It'd be a good idea to make a enum with easier to understand names like calledFromChart, instead of integers such as 0 and 1.
                            Agree, go on.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by funk10101, Today, 08:14 AM
                            3 responses
                            4 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by frankthearm, Today, 09:08 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post frankthearm  
                            Started by samish18, Yesterday, 08:57 AM
                            11 responses
                            28 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by yertle, Today, 08:38 AM
                            1 response
                            5 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Started by love2code2trade, Yesterday, 01:45 PM
                            3 responses
                            22 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Working...
                            X