Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple "Volume projection at close" indicator

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

    Simple "Volume projection at close" indicator

    (edited this entire post)

    Function:
    A simple indicator that projects the volume at the close of minute-based bars. Jumps in the projection can be inferred as the "pace of tape" increasing.

    Instructions:
    1) Download this file HERE and import it into NT7 via File>Utilities>Import NinjaScript

    2) Add this indicator to the same panel as your preferred volume indicator. This must be a minute-based chart.

    3) Turn the plot color to the exact color as your chart background. The line it plots is meaningless.

    4) Verify your system's time is in sync by looking at bar timer, e.g it resets exactly to 5:00 on 5min bars, as opposed to resetting to 5:05, for example. To synchronize it, click on your clock in the bottom right corner > Change date and time settings > Internet Time tab > Change settings > select time.nist.gov in the pulldown menu > and update now.

    5) Verify AutoScale is False (to prevent any large jumps at the beginning of the bar), CalculateOnClose is False, PriceMarker is True and Displacement is 0.

    Disclaimer:
    This is intended for use in a demo or sim account only. By downloading this indicator you agree to not hold me accountable for any financial loss that may result from this indicator, such as but not limited to any trade signals this indicator may produce or any computer instability it may cause (though I don't foresee any). This indicator is free and not intended for resale.

    Exported using NT Version 7.0.1000.8

    Thanks for downloading.
    Last edited by :::grimReaper:::; 01-15-2012, 06:33 PM.

    #2
    Hi :::grimReaper:::,

    I would do this but I own the direct edition.
    If you want access to create NinjaScript. Please registration for one of our free license key at http://www.ninjatrader.com/download-registration.php

    Once received please copy/paste and enter under the Control Center -> Help--> License Key

    If you manage to create, I'm sure other community members will appreciate and you can post the results to the file sharing section. Thanks for offering.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks! I'll take a look Friday afteroon.

      Comment


        #4
        Done with most of it. Some questions:

        1) I only want a "Price Marker," not plot lines. How do I do that?

        2) I noticed at the beginning of a new bar, e.g a 10 min bar, bar timer says the remaining time is around 10:05. Why is that?

        3) How can I determine what timeframe the user is on?

        4) It updates every tick. For those who trade less active markets, how can I tell it to update every second as an option?

        5) I'm currently plotting this in the same panel as my VolumeUpDown, would it be better/efficient if I built my own volume bars?

        Thanks

        Comment


          #5
          Originally posted by :::grimReaper::: View Post
          Done with most of it. Some questions:

          1) I only want a "Price Marker," not plot lines. How do I do that?

          2) I noticed at the beginning of a new bar, e.g a 10 min bar, bar timer says the remaining time is around 10:05. Why is that?

          3) How can I determine what timeframe the user is on?

          4) It updates every tick. For those who trade less active markets, how can I tell it to update every second as an option?

          5) I'm currently plotting this in the same panel as my VolumeUpDown, would it be better/efficient if I built my own volume bars?


          Thanks
          1) What sort of price marker do you want? Text or some sort of drawn object?

          Most indicators will paint a price marker on the y axis unless PaintPriceMarkers = false.

          2) I am currently unable to replicate this behavior on a 10 minute chart. Are you using the BarTimer indicator code directly from the one that comes with NinjaTrader?

          3) You could use BarsPeriod : http://www.ninjatrader.com/support/h...barsperiod.htm

          4) You could probably make a flag that either activates or deactivates the strategy ignoring any ticks that don't occur on the beginning of each second. The way I would probably do this is check the time stamp of each tick using Time[0], and if the seconds from the previous tick is different from the seconds of the current tick, then you are allowed to run the indicator updates.

          Here is some more information on DateTime objects : http://www.ninjatrader.com/support/h..._reference.htm

          5) This is up to you. I am not sure what exactly you are going for so its difficult to make a recommendation. Perhaps if you could clarify and/or post some screenshots of your indicator we could comment further.
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_AdamP View Post
            1) What sort of price marker do you want? Text or some sort of drawn object?
            Just text on the Volume's y-axis.

            Originally posted by NinjaTrader_AdamP View Post
            2) I am currently unable to replicate this behavior on a 10 minute chart.
            I also see this repeatedly on a 1min and 3min chart. It'll jump from around 0:06-0:08 to 1:07 and 0:06-0:08 to 3:07.


            Originally posted by NinjaTrader_AdamP View Post
            Are you using the BarTimer indicator code directly from the one that comes with NinjaTrader?
            yes

            Comment


              #7
              grimReaper,

              I would suggest debugging your code. If you use volumeupdown and bartimer separately, there are no issues. Please see the attached screenshot.

              Please make sure PaintPriceMarkers = true in Initialize(); It should default to true however.

              If you post your code, perhaps we could help debug anything minor.
              Attached Files
              Adam P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_AdamP View Post
                I would suggest debugging your code. If you use volumeupdown and bartimer separately, there are no issues. Please see the attached screenshot.
                It's not my code, it's the code associated with BarTimer. I paid close attention today to my regular charts/indicator while trading and saw my 3min chart go from 0:06 to 3:07, and a similar story with my 15min chart. And I believe I've seen this before but didn't mind.

                Originally posted by NinjaTrader_AdamP View Post
                Please make sure PaintPriceMarkers = true in Initialize(); It should default to true however.
                It creates a price marker, I just want to get rid of the line it plots.

                Originally posted by NinjaTrader_AdamP View Post
                If you post your code, perhaps we could help debug anything minor.
                Here's my code. It worked yesterday, since then I've made a couple of changes: 1) see below 2) changed "Plot0" to "ProjectionPlot." Compiled fine, but can't test it b/c markets are closed. Btw, doesn't work accurately on historical data, only on live data and historical data that was seen live. And let me know if you want a screenshot of anything.

                Code:
                        protected override void OnBarUpdate(){
                            TimeSpan	barTimeLeft = Bars.GetTime(Bars.Count - 1).Subtract(Now);
                			int secondsleft = barTimeLeft.Seconds + barTimeLeft.Minutes*60 + barTimeLeft.Hours*360;
                			int volume = (int) Volume[0];
                			int timeframe = BarsPeriod.Value*60;  //recent change #1, before it was 600 which is 10 minutes
                			int projection = volume*timeframe/(timeframe-secondsleft);
                			ProjectionPlot.Set(projection);
                        }
                		
                		//Below is BarTime code created by NT
                		private DateTime Now{
                			get 
                			{ 
                				DateTime now = (Bars.MarketData.Connection.Options.Provider == Cbi.Provider.Replay ? Bars.MarketData.Connection.Now : DateTime.Now); 
                
                				if (now.Millisecond > 0)
                					now = Cbi.Globals.MinDate.AddSeconds((long) System.Math.Floor(now.Subtract(Cbi.Globals.MinDate).TotalSeconds));
                
                				return now;
                			}
                		}
                
                //....more code

                Comment


                  #9
                  grimreaper,

                  Does the indicator BarTImer by itself exhibit the same behavior on your system? I watched it yesterday and it wasn't doing so.

                  Additionally, could you please post your Initialize() method as well as variables section from your code?
                  Adam P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_AdamP View Post
                    Does the indicator BarTImer by itself exhibit the same behavior on your system? I watched it yesterday and it wasn't doing so.
                    I'll see and post screenshots by Monday.

                    Originally posted by NinjaTrader_AdamP View Post
                    Additionally, could you please post your Initialize() method as well as variables section from your code?
                    Haven't implemented variables so far

                    Code:
                    public class VolumeProjecter : Indicator
                        {
                            #region Variables
                            // Wizard generated variables
                                private int myInput0 = 1; // Default setting for MyInput0
                            // User defined variables (add any user defined variables below)
                            #endregion
                    
                    
                            protected override void Initialize(){
                                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ProjectionPlot"));
                                Overlay				= false;
                            }
                    
                         
                            protected override void OnBarUpdate(){
                    
                    //..... code from last post
                    Last edited by :::grimReaper:::; 12-03-2011, 04:24 PM.

                    Comment


                      #11
                      I attached the bartimer pic. And I also noticed that it doesn't happen on every bar.

                      So right now my indicator plots a line, how do I make it so it only plots the price marker, and nothing else.
                      Attached Files

                      Comment


                        #12
                        grimReaper,

                        Im going to go ahead and test this on my end for awhile and see if I can identify some issue. Thank you for your patience.

                        As far as your second question. You don't want it to plot anything at all? Just the current value?
                        Adam P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_AdamP View Post
                          As far as your second question. You don't want it to plot anything at all? Just the current value?
                          Correct. Right now it's not plotting unobserved historical data correctly, and even if it did, it would be a line that connects the top of every volume bar, which isn't useful.

                          Comment


                            #14
                            grimReaper,

                            I would suggest using DrawTextFixed(), and then DrawOnPricePanel = true in Initialize();

                            The other alternative is to just set the plot to transparent color.
                            Adam P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_AdamP View Post
                              I would suggest using DrawTextFixed(), and then DrawOnPricePanel = true in Initialize();
                              This works. Though there's one bug: after a few bars, the indicator (number) just stops updating. It happens on a new bar (so the value is stuck at 0 or a negative #, depending which code I have compiled, it'll make sense below). Here's my code if you're interested

                              Code:
                              [B]public class VolumeProjecter : Indicator[/B]
                                  {
                                      #region Variables
                                      // Wizard generated variables
                                          private int myInput0 = 1; // Default setting for MyInput0
                                      // User defined variables (add any user defined variables below)
                                      #endregion
                              
                                      /// <summary>
                                      /// This method is used to configure the indicator and is called once before any bar data is loaded.
                                      /// </summary>
                                     [B] protected override void Initialize(){[/B]
                                          //Add(new Plot(Color.FromKnownColor(KnownColor.Transparent), PlotStyle.Line, "ProjectionPlot"));
                                          Overlay				= false;
                              			DrawOnPricePanel = false; //want it in volume panel
                                     [B] }[/B]
                              
                                      /// <summary>
                                      /// Called on each bar update event (incoming tick)
                                      /// </summary>
                                    [B]  protected override void OnBarUpdate(){[/B]
                                          TimeSpan	barTimeLeft = Bars.GetTime(Bars.Count - 1).Subtract(Now);
                              			int secondsleft = barTimeLeft.Seconds + barTimeLeft.Minutes*60 + barTimeLeft.Hours*360;
                              			int volume = (int) Volume[0];
                              			int timeframe = BarsPeriod.Value*60;
                              			//int projection = volume*timeframe/(timeframe-secondsleft);
                              			int projection = Math.Max(0,volume*timeframe/(timeframe-secondsleft)); //to prevent negative values when BarTimer > timeframe
                              			//ProjectionPlot.Set(projection);
                              			string projectionstr = "" + projection;
                              			DrawTextFixed("","",TextPosition.TopRight);  //clear previous text
                              			DrawTextFixed("",projectionstr,TextPosition.TopRight); //write text
                              			
                                     [B] }[/B]
                              		
                              		//Below is BarTime code created by NT
                              		[B]private DateTime Now{[/B]
                                                  //more code....
                                      [B] }[/B]
                              Originally posted by NinjaTrader_AdamP View Post
                              The other alternative is to just set the plot to transparent color.
                              I'll go with the other method you suggested, so this is just fyi: Transparent doesn't work, it hides everything, but setting it to the same color as the background almost works. By almost, I mean since it doesn't plot unobserved historical data correctly, the indicator sometimes displays large spikes, which scales the volume panel, so the preferable method is to stop it from plotting anything, it's also a bit more efficient.

                              Btw, thanks for all of the help you provided this far. I'm learning a lot and hopefully won't require so many questions if I decide to write another indicator.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              172 responses
                              2,279 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,431 views
                              0 likes
                              Last Post Handclap0241  
                              Working...
                              X