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

If other than Input[barsAgo] is used then make it impossible to change the price type

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

    If other than Input[barsAgo] is used then make it impossible to change the price type

    When creating a new indicator with Tools-->New NinjaScript-->Indicator,
    one can use the value of Input[barsAgo] since this allows flexibility for what the indicator is calculated based off of, because users have the option to select a price type (High, Open, Close etc...) from the Indicator Dialog window.

    This is nice and working correctly.

    However, if I write e.g. High[barsAgo] in the script, although this also works correctly, my problem is that the user still could select a price type (High, Open, Close etc...) from the Indicator Dialog window and it doesn’t seem that the logic is hard coded in the script for something other than Input[barsAgo] and changing the setting has no effect.


    My suggestion:
    If other than Input[barsAgo] is used then darken (make it impossible to change) the price type in the Indicator Dialog window (Data \ Input series).

    #2
    Arpad,

    If you code to not use Input[] you can use PriceTypeSupported = false in the Initialize() method to remove the options.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I’ve just tried it.

      I used the code from the Help \ NinjaScript \ Tutorials \ Indicators \ Intermediate – Your own SMA
      and inserted the code you suggested,

      There is no difference. The setting still available, can be altered, and the plotting of the graph is changing depending on what I price type I set in the dialog window.

      The code look like this:

      protectedoverridevoid Initialize()
      {
      PriceTypeSupported = false;
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Overlay = true;
      }

      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      if (CurrentBar < Period) return;
      double sum = 0;
      for (int barsAgo = 0; barsAgo < Period; barsAgo++)
      {
      sum = sum + Input[barsAgo];
      }

      Plot0.Set(sum / Period);
      }



      Step by step what I did:
      1) Typing in the above code
      2) Press F5 to compile
      3) Open a new data series
      4) Apply the MySMA indicator
      5) Play with the price type settings – the plotting changes. No good!

      Comment


        #4
        Arpad, are you working with NT 6.5 or 7 beta?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          7.0.0.23 latest

          Comment


            #6
            In that case, this is expected. NT7 selection really lets you choose whatever you want to run the indicator on as the input series. There is no way to limit the selector as it is made for greater flexibility than 6.5 in providing customization for the user.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              You don’t understand me.
              Let’s try again.

              The problem:
              Even if you write other than Input[barsAgo] in the indicator script, you can choose whatever you want (High, Low, Median etc.) in the indicator dialog.
              And even if you change the setting in the indicator dialog, it is not reflected in the plotting – the graph does not change.

              Why is this problem?
              If one writes an indicator script and at a later time use it, maybe he decides to change the price type in the indicator dialog. This is possible (unfortunately) so he changes it.
              And the change is not reflected on the plot. (Since e.g. Low[barsAgo] is written in the script.)

              There is some misleading here.
              If one cannot change the price type from the indicator dialog (this is OK, since the script define an exact type), NinjaTrader should not let the user think that he can change the type from the indicator properties window.

              Comment


                #8
                If you write anything other than Input it will use exactly what you typed in code wise, completely disregarding what you selected in the UI dialogue window. The UI window at that point in time is only relevant for the instrument you choose to run the indicator on. Selecting high, low, etc. from the UI makes no difference to your code if your code uses something other than Input[].

                This is correct behavior. If code explicitly statesLow[], changing UI options will not run off anything but the Low. There is no way the UI option would be reflected anywhere except when the code uses Input[].

                There is no way to limit the selector window as NT7 selector is simply different than 6.5s. Furthermore, it is not misleading to let people choose High or Low series for the input even when it does nothing to the values evaluated out by the indicator.

                For example, even if we somehow could do your suggestion and limit the selector window by graying out all the options, this would mean the option selected is the default Close series. When this series is selected no one is expecting explicit code that says High[] or Low[] to all of a sudden be replaced by Close[]. The same concept carries over to if the series selected was the High series. You would not expect the explicit code of Low[] to all of a sudden be evaluated as if it were High[] because that was the series selected. Choosing a price type is only relevant and only impacts Input[]. Code that does not use Input[] simply is not impacted.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by funk10101, Today, 09:43 PM
                0 responses
                6 views
                0 likes
                Last Post funk10101  
                Started by pkefal, 04-11-2024, 07:39 AM
                11 responses
                37 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Yesterday, 08:51 AM
                8 responses
                44 views
                0 likes
                Last Post bill2023  
                Started by yertle, Today, 08:38 AM
                6 responses
                26 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Started by algospoke, Yesterday, 06:40 PM
                2 responses
                24 views
                0 likes
                Last Post algospoke  
                Working...
                X