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

DataSeries, IDataSeries or MIN MAX?

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

    DataSeries, IDataSeries or MIN MAX?

    Hi

    I'm trying to 'record' the highest and lowest reading for an indicator (MACD) but only once a set of conditions are met. Once I have the high or low I need to use them in IF statements.

    I've played around with DataSeries, IDataSeries and MIN MAX but wondered if there was an established approach?

    Thanks in advance

    #2
    Hello,

    Thank you for your post.

    Have you tried the HighestBar() and Lowest() Bar methods?

    This will return the highest and lowest value within the period you have specified.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew,

      It's not really how the levels are being recorded (I've opted for SwingLow as per the example below), It's how I can limit the dataseries to storing the data only when a set of conditions are met.

      This approach seems to work but I wondered if there is a recommended approach

      if (MACD(12, 26, 9).Diff[0] > MACD(12, 26, 9).Diff[1]
      && MACD(
      12, 26, 9).Diff[0] > Swing(MACD(12, 26, 9).Diff, 0).SwingLow[0]
      {
      mACDhistlow.Set(Swing(MACD(
      12, 26, 9).Diff, 0).SwingLow[0]);
      Print(mACDhistlow[
      0].ToString("Swing 0.0000000"));
      }

      Comment


        #4
        Hello,

        I see no problem with this. You're storing the value in a DataSeries object which will allow you to access this for later. This is essentially the same approach that is being used in our reference sample on this subject:

        MatthewNinjaTrader Product Management

        Comment


          #5
          Matthew,

          That's reassuring - thanks for the review

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AdamDJ8, Today, 09:18 PM
          0 responses
          2 views
          0 likes
          Last Post AdamDJ8
          by AdamDJ8
           
          Started by knowmad, Today, 03:52 AM
          2 responses
          26 views
          0 likes
          Last Post knowmad
          by knowmad
           
          Started by ETFVoyageur, Today, 07:05 PM
          0 responses
          9 views
          0 likes
          Last Post ETFVoyageur  
          Started by Orion815, 05-02-2024, 08:39 AM
          2 responses
          18 views
          0 likes
          Last Post Orion815  
          Started by suroot, 02-25-2017, 04:43 AM
          11 responses
          2,554 views
          0 likes
          Last Post Zilvercat  
          Working...
          X