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

How to find the max value

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

    #16
    Sorry...I had another indicator edit window opened and it was that one that had the errors. My updated SampleCustomDataSeries now works.

    If I wanted to increase the look back period from 256 to 500 would I simply change the value of ForceMaximumBarsLookBack256 to 500.

    Thanks, Steven

    Comment


      #17
      ForceMaximumBarsLookBack256 will ignore UI selection when user selects infinite. You probably don't need this setting right now.

      If any of your calculations require more than 256 bars, you can change to infinite with this setting, available by code or GUI:
      Ryan M.NinjaTrader Customer Service

      Comment


        #18
        Originally posted by StevenV View Post
        How do I have a SMA of the above formula.
        Here's a simple way:

        1) Create an indicator (say called BarWickAvg) that plots this formula
        Code:
        protected override void Initialize()
                {
                    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Value"));
        			BarsRequired=0;
                    Overlay				= false;
                }
        
                protected override void OnBarUpdate()
                {
                   Value.Set( ((High[0]-Math.Max(Open[0],Close[0]))+(Math.Min(Open[0],Close[0])-Low[0]))/2);
                }
        2) Getting an SMA of BarWickAvg:
        If you just want an SMA of this on an ad-hoc basis you can simply put an SMA on your chart (new panel) and change its "Input Series" to Indicators/BarWickAvg.

        Or if you want to make this more convenient you can make a new indicator say called SMABarWickAvg with a parameter Period,


        Code:
                protected override void Initialize()
                {
                    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Value"));
        			BarsRequired=0;
                    Overlay				= false;
                }
        
                protected override void OnBarUpdate()
                {
                    Value.Set(SMA(BarWickAvg(),period)[0]);
                }

        Comment


          #19
          Thanks DaveE!

          I did not know I could apply one indicator to another...good to know.

          Your code works great and is simpler.

          Thanks, Steven

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kevinenergy, 02-17-2023, 12:42 PM
          116 responses
          2,757 views
          1 like
          Last Post kevinenergy  
          Started by franatas, 12-04-2023, 03:43 AM
          7 responses
          106 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by jpapa, Today, 07:22 AM
          0 responses
          1 view
          0 likes
          Last Post jpapa
          by jpapa
           
          Started by Jltarrau, Today, 05:57 AM
          3 responses
          7 views
          0 likes
          Last Post Jltarrau  
          Started by f.saeidi, Today, 05:56 AM
          2 responses
          8 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X