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

Detect program type - Chart or MarketAnalyzer

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

    Detect program type - Chart or MarketAnalyzer

    Is there any variable, that i can use in my script, i.e.

    Code:
    if(ThisScriptIsBeingExecutedInChart){
      
    }
    
    else if(ThisScriptIsBeingExecutedInMarketAnalyzer){
    
    }

    #2
    Hello selnomeria,

    Thanks for opening the thread.

    NinjaTrader 8 has an IsChartOnly property that you can set in State.SetDefaults, but there is not such equivalent for NinjaTrader 7.

    NT8 IsChartOnly - https://ninjatrader.com/support/help...schartonly.htm

    For NinjaTrader 7, it is typically recommended to make 2 versions of the indicator that can be used for the Market Analyzer and another for a Chart.

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim, thanks but your answer is not quite relevant. The one and most thing I like enormously and without any question, everywhere say, that NT support is one of the best (as opposed to TradeStation support forum), is that you always say what is available and what is not, and send suggestions to developers (unlike TradeStation, who never cares for client requests, hundreds of dissapointed users like me will confirm).

      my question is, that I need a variable (not the one, that i SET manually, but conversely, it should tell me) the environment the script is being executed.
      Most of my scripts in other platforms, are multi-environment functional - they can be used in chart and in scan too- using such pseudo- logic:
      Code:
      if (EnvironmentType.Chart) {
        value = XYZ; ShowArrow();
      }
      else if (EnvironmentType.Scanner ) {
        value = XYZ;   DontShowArrow(); 
      }
      (lets assume, i have set "EnvironmentType" to true or false, with the help of platform wide variable)

      so, your answer is quite different something. i dont want to set variables myself or even , IsChartOnly is different thing at all.
      i am sure you understand what i mean.
      Last edited by ttodua; 08-14-2017, 11:40 AM.

      Comment


        #4
        Hello selnomeria,

        Thanks for your reply and words of encouragement.

        Actually, there is an undocumented ChartOnly property that can be found in the ConstantLines indicator. This is may not achieve what you are looking to do, but the ability to detect what kind of window the indicator is attached to is not something we can provide further direction.

        As NinjaTrader 7 is in a freeze we would not be able to submit a feature request to make such a property available. At this point, my best recommendation for NinjaTrader 7 would still be to create two versions of the indicator that you can separately attach to a Market Analyzer or a Chart.

        If there is anything else I can do to assist, please let me know.
        JimNinjaTrader Customer Service

        Comment


          #5
          1) Can you provide that for NT8? i wanted for both, but even NT8 will be good, if i can determine scanner or chart is being used (at this moment i need it for NT8 to be true). however, you told about "IsChartOnly", which is quite irrelevan thing, because it needs to be set by user. i dont need that at all. i want system told me itself about the environment.

          2) Finally! good that NT7 is frozen. people'd better to switch to NT8. good. concentrate all energy on NT8 development/fixes. Btw, was there any message/statement about NT7 freeze? i couldnt notice that fact untill you said.
          Last edited by ttodua; 08-14-2017, 12:42 PM.

          Comment


            #6
            Hello selnomeria,

            After some testing, this is what I have found for detecting the window type for NinjaTrader 8:

            Code:
            if (Parent is MarketAnalyzerColumnBase)
            	Print("Running on a Market Analyzer");
            else if (Parent is IndicatorSuperDomBase)
            	Print("Running on a SuperDOM");
            else if (Parent is Chart)
            	Print("Running on a Chart");
            NinjaTrader 7 has been frozen since the release of NinjaTrader 8. NinjaTrader 7 is still supported, but we are not accepting any more feature requests, and any reported issues must be deemed critical to consider changing.

            Please let me know if I may be of further assistance.
            JimNinjaTrader Customer Service

            Comment


              #7
              wow, thanks! that's i was searching for. BTW, how you found? THose keyowrds are nowhere documented...
              can you tell Dev team, to disclose all such resources/variables in docs?

              Comment


                #8
                Jim can you confirm that works for you?

                It doesnt work, the "Parent" returns the script type itself, when it's called programatically.

                for example, if you use

                if (Parent != null) Print(Parent.ToString());

                in an indicator, and attach that on chart, you will get no output (beacuse parent is null).

                if you call that indicator from another script, then Parent will return "Indicator".

                So, please, tell me a solution to detect the window type, either to understand if script is in MarketAnalyzer or on Chart. I desperately need that solution.


                (similar threads: https://ninjatrader.com/support/foru...ad.php?t=84931 , https://ninjatrader.com/support/foru...ad.php?t=64014 )
                Last edited by ttodua; 08-28-2018, 11:34 AM.

                Comment


                  #9
                  Hello TazoTodua,

                  Thanks for the reply.

                  The code provided was not documented/supported and the behavior has happened to change somewhere down the line for Charts.

                  The best recommendation would be to take an approach similar to how Harry and NinjaTrader_PatrickH have described: to make specific indicators for use in each specific window you require different behavior.

                  Other than that you may check if ChartControl != null to the other checks to see if you are on a Chart. Checking if(Parent is MarketAnalyzerColumnBase) still appears to work well for the Market Analyzer.

                  Keep in mind, unsupported items are items that are subject to change and are not locked into documentation. Items that are documented can be expected not to change and we can offer support for using.

                  Please let us know if we can be of further assistance.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by kujista, Today, 05:44 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post kujista
                  by kujista
                   
                  Started by ZenCortexCLICK, Today, 04:58 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post ZenCortexCLICK  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  172 responses
                  2,281 views
                  0 likes
                  Last Post sidlercom80  
                  Started by Irukandji, Yesterday, 02:53 AM
                  2 responses
                  18 views
                  0 likes
                  Last Post Irukandji  
                  Started by adeelshahzad, Today, 03:54 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post adeelshahzad  
                  Working...
                  X