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

Extracing H/L for time period on a volume chart

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

    Extracing H/L for time period on a volume chart

    Hello,

    I know how to determine the H/L value for a given time period if I'm use time-based intervals, but is there a way to do this while using a volume-based interval. I'm trying to get these values for use in a custom indicator.

    Thanks,

    rsi77

    #2
    rsi77, have you tried getting the needed values with GetBar()? - http://www.ninjatrader-support.com/H...V6/GetBar.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I believe "GetBar" is a more elegant way to do what I'm trying to do than the way I'm doing it now since it would enable me (I think) to call for the values I want only one time at the end of the session rather than keeping track of highs and lows throughout the session, but I have two questions:

      1. If I'm using a not time interval which, for example, may span across a specific time frame "edge", e.g. 8:00AM, how can I insure that I get the highest value after or including 8:00AM, but not before. So if my bar starts at 7:58AM and ends at 8:01AM (a volume bar), but I want to start keeping track of the high and lows which occur exactly between 8:00AM and 3:00PM (sharp). How can I get that High and Low value and insure that they didn't occur just before or just after my timeframe?

      2. If I do use "GetBar" in the context of a time interval chart, is there an easy way to point to the 8:00AM bar without having to explicitly state the date? Or if I need to explicitly include the date, what is an easy way to retrieve "today's" date so that it can be included in the GetBar statement?

      Thanks,

      rsi77

      Comment


        #4
        Hi rsi77, unfortunately this is not possible historically what you outline under 1, or you take a really fine granularity and ensure you get the historical timestamps for comparison you need.

        In realtime you can use DateTime.Now to check (your PC clock) and then just run a variable saving the needed values when they update.

        For the second question, you can work with ToDay() - http://www.ninjatrader-support.com/H...eV6/ToDay.html
        BertrandNinjaTrader Customer Service

        Comment


          #5
          why won't my first indicator work

          I thought I was following the format properly, but this indicator returns no values--can you help me???? (I removed the last section of code "#region" because I otherwise couldn't fit this here.

          #region Using declarations
          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Gui.Chart;
          #endregion

          // This namespace holds all indicators and is required. Do not change it.
          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// rsi77 version of pivots which use regular session or globex session HLC for calculation
          /// </summary>
          [Description("rsi77 version of pivots which use regular session or globex session HLC for calculation")]
          public class PivotsRSI : Indicator
          {
          #region Variables
          // Wizard generated variables
          private int useRegSession = 1; // Default setting for UseRegSession
          private int useGlbxSession = 1; // Default setting for UseGlbxSession
          // User defined variables (add any user defined variables below)
          double Range=0; //Variable used in calcualtions of pivot point values
          double HighD=0; //Variable used in calcualtions of pivot point values
          double LowD=0; //Variable used in calcualtions of pivot point values
          double CloseD=0; //Variable used in calcualtions of pivot point values
          double ppToday = 0;
          double s1Today = 0;
          double s2Today = 0;
          double s3Today = 0;
          double r1Today = 0;
          double r2Today = 0;
          double r3Today = 0;
          #endregion

          /// <summary>
          /// This method is used to configure the indicator and is called once before any bar data is loaded.
          /// </summary>
          protected override void Initialize()
          {
          Add(new Plot(Color.FromKnownColor(KnownColor.MenuHighlight ), PlotStyle.Line, "DailyPP"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DailyR1"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DailyR2"));
          Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DailyR3"));
          Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "DailyS1"));
          Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "DailyS2"));
          Add(new Plot(Color.FromKnownColor(KnownColor.LimeGreen), PlotStyle.Line, "DailyS3"));
          CalculateOnBarClose = true;
          Overlay = true;
          PriceTypeSupported = false;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          if (ToTime(Time[0]) >= 83000 && ToTime(Time[0]) <= 151500)
          {
          if (ToTime(Time[0]) > 83000 && ToTime(Time[1]) <= 83000)
          {
          //First we reset variables for a new day
          HighD=High[0];
          LowD=Low[0];
          CloseD=Close[0];
          }
          if (High[0]>HighD) {HighD=High[0];}
          if (Low[0]<LowD) {LowD=Low[0];}
          }

          if (ToTime(Time[0])>150000 && ToTime(Time[1])<=150000)
          {
          CloseD=Close[1];
          Range = HighD-LowD;
          ppToday = (HighD+LowD+CloseD)/3;
          s1Today = 2*ppToday-HighD;
          s2Today = ppToday-Range;
          s3Today = s2Today-Range;
          r1Today = 2*ppToday-LowD;
          r2Today = ppToday + Range;
          r3Today = r2Today + Range;

          }

          DailyPP.Set((HighD+LowD+CloseD)/3);
          DailyR1.Set(r1Today);
          DailyR2.Set(r2Today);
          DailyR3.Set(r3Today);
          DailyS1.Set(s1Today);
          DailyS2.Set(s2Today);
          DailyS3.Set(s3Today);
          }

          #region Properties
          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyPP
          {
          get { return Values[0]; }
          }

          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyR1
          {
          get { return Values[1]; }
          }

          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyR2
          {
          get { return Values[2]; }
          }

          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyR3
          {
          get { return Values[3]; }
          }


          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyS1
          {
          get { return Values[4]; }
          }

          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyS2
          {
          get { return Values[5]; }
          }

          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public DataSeries DailyS3
          {
          get { return Values[6]; }
          }


          [Description("Choose to use regular session H/L/C for calculation")]
          [Category("Parameters")]
          public int UseRegSession
          {
          get { return useRegSession; }
          set { useRegSession = Math.Max(0, value); }
          }

          [Description("choose to use Globex session H/L/C for calculation")]
          [Category("Parameters")]
          public int UseGlbxSession
          {
          get { return useGlbxSession; }
          set { useGlbxSession = Math.Max(0, value); }
          }
          #endregion
          }
          }

          Comment


            #6
            Please check this tip here and the little check mentioned to the start of your OnBarUpdate() - http://www.ninjatrader-support2.com/...ead.php?t=3170
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks again!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, Yesterday, 06:40 PM
              2 responses
              19 views
              0 likes
              Last Post algospoke  
              Started by ghoul, Today, 06:02 PM
              3 responses
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              45 views
              0 likes
              Last Post jeronymite  
              Started by Barry Milan, Yesterday, 10:35 PM
              7 responses
              20 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by AttiM, 02-14-2024, 05:20 PM
              10 responses
              181 views
              0 likes
              Last Post jeronymite  
              Working...
              X