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 CortexZenUSA, Today, 12:53 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          0 views
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          2 views
          0 likes
          Last Post usazencortex  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,262 views
          0 likes
          Last Post sidlercom80  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X