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

Drawline(Price/bar, Time)

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

    Drawline(Price/bar, Time)

    Hello,

    In a NinjaTrader 7 script, I want to use DrawLine starting with a condition on a bar, eg Close[0] > priordayClose and ending the line eg at 15:30 time.

    I searched the forum and could not find a solution.

    Thank you

    #2
    Hello,

    Thank you for the post.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello jackomulligan,

      Thank you for your patience and welcome to the forum.

      You will get the prior day close with PriorDayOHLC():

      Code:
      double value = PriorDayOHLC().PriorClose[0];
      More on PriorDayOHLC():


      Then you will use DrawLine() to draw the line based on the data:



      For example:

      Code:
      protected override void OnBarUpdate()
              {
                  if (ToTime(Time[0]) < ToTime(15, 30, 0)
      				&& Close[0] > PriorDayOHLC().PriorClose[0])
      			{
      				DateTime endTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 15, 30, 0);
      				DrawLine(Time[0].Date.ToString(), true, Time[0], Close[0], endTime, Close[0], Color.LimeGreen, DashStyle.Solid, 3);
      			}
              }
      This will draw a line from the current day's bar when it closes above the prior day close and then to the current day's 3:30 pm.

      If there is anything else I may assist with please let me know.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Thanks much Chris!

        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