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 trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        10 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X