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

VerticalCustomLines

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

    VerticalCustomLines

    This indicator doesn't draw vertical lines as expected and is off timing wise. This is because, it's starting point is messed up. Example use session template as US Index Futures RTH and session starts at 9:30 am eastern. So say an interval of 10 (1 min. chart) would draw vertical lines at 9:40, 9:50........But that is not the case.

    Please check it out and let me know how to correct this problem.

    Thanks,

    Sam777

    #2
    Hi sam777,

    Can you please clarify the exact indicator you're having trouble with? I created this vertical lines custom but it doesn't use sessions at all.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      VerticalLinesCustom



      It is version 7 on page 5 - VerticalLinesCustom indicator.

      Even if it doesn't use sessions template at all (which I though that it would reset at the start/end times defined in the template), it is still unknown as to the start time from where the interval (bars) is input in the parameters and that is the problem. The interval is correct but offset timing wise as can't figure out when it begins counting.

      Thx Sam777
      Last edited by sam777; 02-21-2011, 02:28 PM.

      Comment


        #4
        Yes, this is the script I wrote. It just starts from the very first bar in the series, so will not take session into account. It's very simple and does not relate to session templates at all. I recommend applying it with no other vertical lines applied to chart.
        Right Click > Properties > Set Plot vertical grid lines to false
        Right Click > Data Series > Set plot Session break line to false.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan is there a way to do this so that it prints a line at a set number of minutes? i.e. every 6 minutes or whatever? You don't need to do it for me, obviously, but any tips you have in what I should be looking at to figure this out would be great. Thank you

          Comment


            #6
            Yes, you could use the minute part of time objects to do something similar.

            if (Time[0].Minute % 6 == 0) { }

            If you wanted to use it mainly on real time charts, work off your computer clock DateTime.Now instead.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan, thank you for the help. I can't make it not print for the whole minute, so each incoming tick, it prints a bar during the whole sixth minute

              Comment


                #8
                Set CalculateOnBarClose = true or move logic that you want executed once per bar into this:

                if (FirstTickOfbar)
                {
                //Run logic once per bar when COBC = false.
                }
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  My problem is that I am trying to use this on 1 and 15 tick charts. So there's generally several 'bars' inside each sixth minute. Thanks for your help though

                  Comment


                    #10
                    I see -- you have multiple bars that can end in the same minute. To solve this you could consider using Time[0].Minute as the tag to your drawing objects. If a new line has this same tag, the object is replaced rather than drawn each time.

                    DrawVerticalLine(Time[0].Minute.ToString(), 0, Color.Blue);
                    Last edited by NinjaTrader_RyanM1; 03-06-2012, 02:19 PM.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_RyanM View Post
                      Yes, you could use the minute part of time objects to do something similar.

                      if (Time[0].Minute % 6 == 0) { }

                      If you wanted to use it mainly on real time charts, work off your computer clock DateTime.Now instead.
                      So I'm not really following if you can get it to sync with the first bar of a chart or at a specific time or not. If for example you had it set for 15 min on a 1 min chart can you set it to print at 9:00, 9:15, 9:30, 9:45 etc. rather than the first bar of the chart?

                      Comment


                        #12
                        Tremblinghandtrader,

                        Yes, you could use that line you quoted to check for every xth minute.

                        if (Time[0].Minute % 15 == 0) { }
                        Last edited by NinjaTrader_RyanM1; 07-16-2012, 07:23 AM.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_RyanM View Post
                          I see -- you have multiple bars that can end in the same minute. To solve this you could consider using Time[0].Minute as the tag to your drawing objects. If a new line has this same tag, the object is replaced rather than drawn each time.

                          DrawVerticalLine(Time[0].Minute.ToString(), 0, Color.Blue);
                          How can I change this so that it draws on the first bar that reaches the minute, instead of redrawing until the last?

                          Comment


                            #14
                            Hi wadams,

                            That's a nice twist to this one. One way could be to reset a bool flag when minute changes and use it as a control on your draw objects.

                            Code:
                            #region Variables
                            private bool okToDraw;
                            #endregion
                            
                            if (Time[0].Minute != Time[1].Minute)
                            	okToDraw = true;
                            
                            if (Time[0].Minute % 1 == 0 && okToDraw)
                            {
                            	DrawVerticalLine(Time[0].Minute.ToString(), 0, Color.Blue);
                            	okToDraw = false;
                            }
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks for the quick response, Ryan. I can't get the code to create vertical liens. I've tested on ThreeLineBreak and Range charts. Are there any mistakes in this code? I haven't changed anything outside of this indicator class.
                              Code:
                              public class VerticalLinesCustom : Indicator
                                  {
                                      #region Variables
                              		private int 		lineInterval 		= 15; 
                              		private int 		lineWidth 			= 1;
                              		private Color 		lineColor 			= Color.DimGray;
                              		private DashStyle 	lineStyle 			= DashStyle.Dash;
                              		private bool okToDraw;
                              		#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()
                                      {
                                          Overlay				= true;
                                      }
                              
                                      /// <summary>
                                      /// Called on each bar update event (incoming tick)
                                      /// </summary>
                                      protected override void OnBarUpdate()
                                      {	
                              		
                              			if (Time[0].Minute != Time[1].Minute)
                              				okToDraw = true;
                              
                              			if (Time[0].Minute % lineInterval == 0 && okToDraw){
                              				DrawVerticalLine(Time[0].Minute.ToString(), 0, LineColor, LineStyle, LineWidth);
                              				okToDraw = false;
                              			}	
                              	    }
                              		
                              		public override string ToString() //formats chart label
                              		{
                              			return "VLines" + "(" + LineInterval + ")";
                              		}
                              		
                                      #region Properties
                                      [Description("Sets the bar interval that lines are drawn")]
                                      [GridCategory("Parameters")]
                                      public int LineInterval
                                      {
                                          get { return lineInterval; }
                                          set { lineInterval = Math.Max(1, value); }
                                      }
                              		
                              		[Description("Price Line Style")]
                                      [GridCategory("Parameters")]
                                      public DashStyle LineStyle
                                      {
                                          get { return lineStyle; }
                                          set { lineStyle = value; }
                                      }
                              		 
                                      [Description("Price Line Color")]
                                      [GridCategory("Parameters")]
                                      public Color LineColor
                                      {
                                          get { return lineColor; }
                                          set { lineColor = value; }
                                      }
                              		
                              		[Browsable(false)]
                              		public string LineColorSerialize
                              		{
                              			get { return NinjaTrader.Gui.Design.SerializableColor.ToString(lineColor); }//SerializableColor
                              			set { lineColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                              		}		
                              
                                  	[Description("Price Line Width")]
                                  	[GridCategory("Parameters")]
                                      public int LineWidth
                                      {
                                          get { return lineWidth; }
                                          set { lineWidth = value; }
                                      }
                              
                                      #endregion
                                  }
                              .

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              57 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X