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

Drawing vertical lines on a timestamp - help?

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

    Drawing vertical lines on a timestamp - help?

    Although this conversation started over in Charting, in

    since it requires custom code, I moved discussion here...

    The goal is to place vertical lines on a (tick) chart at specified time intervals. It helps map the tick movement to the bar development on my neighboring chart.

    So I need a marker to compare to the bar time to know whether or not the draw the vertical line. I do not have a known DateTime variable to use during the Initialize() method.

    I can initialize the marker at the first tick of the session using Time[0]; however, the behavior is odd. It works after everything has started and new bars are being created (tested in replay) but all previous bars get a vertical line on every single bar. Ugh!

    How do I initialize my marker to the session start time or the beginning of the chart? preferably during Initialize() and how to avoid the behavior shown in the NT example below?
    Attached Files

    #2
    I took a quick look at your indicator but could not spot the bug. I suggest debugging as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

    Comment


      #3
      I found time to do a little bit more with this - my thought was that if CurrentBar = the # of bars on the chart (leftmost being 0) and Time[n] uses barsago, then Time[CurrentBar] would give me the time of the leftmost bar on the chart.

      Apparently not. During the Initialize() method, CurrentBar = -1 even though my range chart had two full days of tick bars. (I printed the CurrentBar value to an output window). This is wierd - other indicators backfill the chart properly...

      Trying to find the Time stamp of the leftmost bar in chart history actually made things worse & I gave up -- put the indicator back as it was. There are other pieces of code that have a higher priority right now, sorry.

      At least, once data starts arriving, it operates correctly, and as long as I NEVER apply any indictors again, it is good even after a workspace shutdown & restore (e.g., overnight).

      It would be good if y'all could provide the (correct) function in one of your future drops - this was one of those things I was surprised to not find already there...

      best wishes...

      Comment


        #4
        CurrentBar is not meant to be accessed in Intitialize() as when this method is called, there is not CurrentBar that has been processed yet. Do not confuse CurrentBar with the number of bars on chart. CurrentBar reflects the bar that is currently being processed.
        RayNinjaTrader Customer Service

        Comment


          #5
          OK. I was going by this stmt:
          "if a chart has 100 bars of data, the very first bar of the chart (left most bar) will be number 0 (zero) and each subsequent bar from left to right is incremented by 1." all to way up to 99, I'd would have thought from that stmt.

          Bottom Line: How can I access (address) the first bar on the chart during the Initialize() method?

          Thanks

          BTW, if certain variables are uninitialized until the OnBarUpdate() of this session, y'all should probably say so in the help. There is nothing to indicate that all the bars already on the chart are ignored...

          Comment


            #6
            You can't since in Initialize() bars do not exist yet. I will update the DOC, thanks for raising this point.
            RayNinjaTrader Customer Service

            Comment


              #7
              FWIW, the Timelines originally written half-worked until the latest betas when it broke completely. I spent sometime re-writing it, and I think that I have a decent working version now.

              Unfortunately, the vertical lines are on TOP of price but I cannot control that. I cannot imagine that ANY vertical line should ever be on top of price - it doesn't make sense to hide your data...

              I sure wish y'all would just add this function to NT. Meanwhile, here is the latest version. cheers!
              Attached Files

              Comment


                #8
                Hi Lost Trader,

                Thanks for sharing your Timelines indicator, not too long ago I had requested help to plot vertical Lines at specific time frames so your indicator is just what I was looking for.

                Would it be too hard to modify this indicator so that you can specify the time span where you want to plot the vertical Lines? For example to plot just between 9:00 AM and 4:30 PM (day market), instead of plotting all the way back to the first data point?. I am think about this just to save some CPU resources.

                Thanks again!
                HJS

                Comment


                  #9
                  Hello Lost Trader,
                  Exactly what I have been looking for the the tic charts
                  Thanks
                  Michael B

                  Comment


                    #10
                    I did something along a similar line and posted it a while back.

                    It can be found here... http://www.ninjatrader-support.com/v...ead.php?t=3717

                    If someone has the time, maybe some of these techniques could be merged together.

                    Comment


                      #11
                      Originally posted by Lost Trader View Post
                      FWIW, the Timelines originally written half-worked until the latest betas when it broke completely. I spent sometime re-writing it, and I think that I have a decent working version now.

                      Unfortunately, the vertical lines are on TOP of price but I cannot control that. I cannot imagine that ANY vertical line should ever be on top of price - it doesn't make sense to hide your data...

                      I sure wish y'all would just add this function to NT. Meanwhile, here is the latest version. cheers!
                      Hi could you please tell me how i can apply this indicator into my ninja platform. Maybe it is a simple task but I do not know how to do it and I am lost... thanks

                      Comment


                        #12
                        simple code to draw a vertical line at a time of day

                        Below is some simple code to draw something at a given time of day, everyday.

                        if (Bars.FirstBarOfSession == true)
                        {
                        DateTime myTime = DateTime.Parse((Time[0]).ToString("d") + " 9:30 AM");
                        DrawVerticalLine("myTime" + CurrentBar, myTime, Color.Blue, DashStyle.Dash, 2);
                        Print(myTime);
                        }

                        Just replace " 9:30 AM" with whatever time you want to draw the object, making sure to include a space before the hour numeral.

                        The print output should look like this: 6/28/2011 9:30:00 AM

                        Comment


                          #13
                          Originally posted by Masoud View Post
                          Hi could you please tell me how i can apply this indicator into my ninja platform. Maybe it is a simple task but I do not know how to do it and I am lost... thanks
                          Download and save the zip file, but do not unzip it.
                          Then from NinjaTrader Control Center: go to File> Utilities> Import NinjaScript...
                          Browse to the zip file and go!

                          The imported indicator will now be available to you just as all the built-in indicators.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by AttiM, 02-14-2024, 05:20 PM
                          12 responses
                          213 views
                          0 likes
                          Last Post DrakeiJosh  
                          Started by cre8able, 02-11-2023, 05:43 PM
                          3 responses
                          238 views
                          0 likes
                          Last Post rhubear
                          by rhubear
                           
                          Started by frslvr, 04-11-2024, 07:26 AM
                          8 responses
                          117 views
                          1 like
                          Last Post NinjaTrader_BrandonH  
                          Started by stafe, 04-15-2024, 08:34 PM
                          10 responses
                          47 views
                          0 likes
                          Last Post stafe
                          by stafe
                           
                          Started by rocketman7, Today, 09:41 AM
                          3 responses
                          12 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X