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 Waxavi, Today, 02:10 AM
          0 responses
          4 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          11 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          5 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X