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

Check for nonvalid indicatr entries

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

    Check for nonvalid indicatr entries

    Hi,

    I have scripted an indicator x that uses values of indicator y.
    To check if indicator y has valid values I use
    indicator_y.IsValidPlot(bars_ago).
    Normally this works fine but not this time. Therefore it must have something to do with
    the validity check of indicator y itself and the structure of that indicator.

    Indicator y works fine if applied to a chart. It calculates 2 plots that are displayed in the chart. Values should be accessable with a command like indicator_y.Plot1 and
    indicator_y.Plot2.
    If I use indicator_y.IsValidPlot(bars_ago) for checking validity it plots false every time.
    It should be true, though.
    If I use indicator_y.Plot1.ContainsValue(bars_ago) it gives an error at bar 0
    because of usingf an invalid index.
    It's the first time I have scripted an indicator that contains 2 dataseries.
    Obviously there is some basic logic I need to change.
    Although the indicator y itself works fine,
    I can't conduct validity checks to use indicator y within other indicators.

    How should this be done? Couldn't find any hints in the help file yet.
    Thanks in advance!
    Stephan
    Last edited by Stephan123; 06-13-2011, 07:51 AM.

    #2
    Hello,


    Thanks for the forum post.

    What value is the indicator plotting on the chart? It isnt the close price is it? As if an indicator does not have a valid plot the last or close price is substituted for charting, However is not programmatically accessible therefor is why the IsValid check is needed for when you reference it from an indicator/strategy.

    If not can you please clarify further on code your using to check this.

    I look forward to assisting you further.

    Comment


      #3
      indicator y is not plotting Close-prices, it's valid values.
      Here are some parts of the script of indicator y:

      Code:
              protected override void Initialize()
              {
                  Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "NAdvance"));
                  Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "NDecline"));
                  Overlay                = false;
              }
      Those are the values beeing calculated by the indicator.

      They are assigned as follows within OnBarUpdate:

      Code:
      NAdvance.Set(n_advance);
      NDecline.Set(n_decline);
      This is how the property-region looks like:

      Code:
              #region Properties
              [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
              [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
              public DataSeries NAdvance
              {
                  get { return Values[0]; }
              }
      
              [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
              [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
              public DataSeries NDecline
              {
                  get { return Values[1]; }
              }
      
              #endregion
      Applying this indicator to a chart works fine, as already said.

      However, the problem comes with using that indicator within another one.

      Within OnBarUpdate of that second indicator I check for valid entries of the first indicator using:

      Code:
      AdvanceDeclineNYSE().Value.IsValidPlot(Periode-1)
      Periode is an integer representing the desired lookbackperiod.
      If that expression is true, calculation of the second indicator is done.
      However, this expression never gives true, don't know why.

      Comment


        #4
        Hello,

        Thanks for that information.

        Instead of using .IsValid, please instead use ContainsValue as shown in the sample below should do the trick for you.



        Let me know if I can be of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Brett View Post
          Hello,

          Thanks for that information.

          Instead of using .IsValid, please instead use ContainsValue as shown in the sample below should do the trick for you.



          Let me know if I can be of further assistance.
          I already had tried that using

          Code:
          AdvanceDeclineNYSE().NAdvance.ContainsValue(Periode-1)
          and got an error message at bar 0 because of an invalid index.
          But, using an additional filter like

          Code:
          CurrentBar>=Periode-1
          arround the above check finally worked out.
          Thanks, Stephan

          Comment


            #6
            Hello,

            Nice work. Good find there.

            Let me know if I can be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mattbsea, Today, 05:44 PM
            0 responses
            5 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            31 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            2 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,282 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            20 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Working...
            X