Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it possible to make an indicator using max function?

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

    Is it possible to make an indicator using max function?

    I want to calculate VOLMA using various time periods and create a line only with the highest values.
    which means

    max(VOLMA(period1), VOLMA(period2), VOLMA(period3), ... VOLMA(period100))


    For example..

    VOLMA(period1)= 50
    VOLMA(period2)= 60
    VOLMA(period3)= 65
    ....
    VOLMA(period99)= 40
    VOLMA(period100)= 90 (lets say this is the highest value among the 100 VOLMAs)

    Then, in this case

    max(VOLMA(period1), VOLMA(period2), VOLMA(period3), ... VOLMA(period100))

    will be 90.

    Is it possible to make this kind of custom indicator?






    #2
    Hello hybinubt,

    Welcome to the NinjaTrader forums!

    I've moved your thread from Platform Technical Support section of the forums to the Indicator Development of the forums as this pertains to indicator development.

    The MAX() indicator returns the highest bar value for a single series.

    However, you might be able to use a List<double> object and find the largest value with the Linq Enumerable.Max() method.


    List<double> myList = new List<double>() { VOLMA(50)[0], VOLMA(60)[0], VOLMA(100)[0] };
    Print(myList.Max());
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      While I want to use SMA when I calculate that, I found that moving average of Volume(=VOLMA) is calculated using EMA in Ninjatrader.
      Can you please make a code for indicator that displays max value among the various period (for example: period20 period60 period120) Simple Moving Average of Volume? (The values should be displayed in the same panel as the one with the volume)
      I would appreciate if you could give me the complete code like below.

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class Maxvolma : Indicator
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"";
      Name = "Maxvolma";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      }
      else if (State == State.Configure)
      {
      }
      }

      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.
      }
      }
      }​
      Last edited by hybinubt; 06-03-2024, 12:11 AM.

      Comment


        #4
        Hello hybinubt,

        I've copied and pasted the code I've suggested in post # 2 into OnBarUpdate() and exported this to assist in understanding how to get the Max value of multiple indicator instances.
        LinqMaxTest_NT8.zip

        This prints the value to the output window.

        You'll need to adapt this to the needs of your script.

        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          > You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script.

          how can I contact them?

          Comment


            #6
            Hello hybinubt,

            You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!
            Programming Services - https://ninjatraderecosystem.com/sea...mming-services
            Educators - https://ninjatraderecosystem.com/sea...ures=education

            You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

            This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.​
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            600 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            346 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            558 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X