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 xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          22 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          16 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          229 views
          0 likes
          Last Post TradingLoss  
          Started by agclub, 04-21-2024, 08:57 PM
          3 responses
          17 views
          0 likes
          Last Post TradingLoss  
          Started by TradingLoss, 04-21-2024, 04:32 PM
          4 responses
          45 views
          2 likes
          Last Post TradingLoss  
          Working...
          X