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

Environment type variable for indicator: Market Analyzer or Chart?

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

    Environment type variable for indicator: Market Analyzer or Chart?

    Hello,

    Is there an Environment type variable that tells whether an indicator is attached to a Market Analyzer or a Chart?

    :-)

    #2
    Hello llanqui,

    Thanks for your post.

    Please provide me a brief description of exactly what you are trying to accomplish so I may accurately assist you.

    Are you wanting to access the ChartControl class which provides access to a wide range of properties and methods related to the location of objects on a chart and other chart-related properties.

    ​ChartControl: https://ninjatrader.com/support/help...artcontrol.htm

    Charts: https://ninjatrader.com/support/help.../nt8/chart.htm

    Thanks in advance. I look forward to further assisting.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      When the indicator loads I would like to know if it is attached to a Market Analyzer or to a Chart

      I could do this with a parameter but would rather keep it simple (no parameter) if possible

      Comment


        #4
        Hello llanqui,

        Thanks for your note.

        To check if the indicator is applied to a market analyzer or a chart, please see the forum thread post linked below.



        You could also consider using the unsupported/undocumented code below to check if it is a Market Analyzer Indicator Column. Note that we would not be able to provide assistance with the use of undocumented code.

        Code:
        private string IsRunningIn()
        {
            // Find the top most NinjaScriptBase
            NinjaScriptBase topMost = this;
            for (; topMost.Parent != null; topMost = topMost.Parent) {}
        
            // Check if it is a Market Analyzer Indicator Column
            MarketAnalyzerColumns.IndicatorMarketAnalyzerColumn ma = topMost as MarketAnalyzerColumns.IndicatorMarketAnalyzerColumn;
        
            if (ma != null)
                return "Market Analyzer";
        
        }​
        Let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I like the simple example in the link you mention

          if (Parent is MarketAnalyzerColumnBase)
          Print("Running on a Market Analyzer");
          else
          Print("Running on chart");

          thanks...​

          Comment


            #6
            in what State.? is the best place to put this code?

            Comment


              #7
              Hello llanqui,

              Thanks for your note.

              This could be called in either OnStateChange when the State == State.DataLoaded or in the OnBarUpdate() method.

              Let me know if I may assist further.
              Brandon H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by WHICKED, Today, 12:56 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cre8able, Today, 01:16 PM
              0 responses
              2 views
              0 likes
              Last Post cre8able  
              Started by chbruno, 04-24-2024, 04:10 PM
              2 responses
              47 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by WHICKED, Today, 12:45 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by samish18, Today, 01:01 PM
              0 responses
              6 views
              0 likes
              Last Post samish18  
              Working...
              X