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 jaybedreamin, Today, 05:56 PM
          0 responses
          3 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          9 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Working...
          X