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

Draw Extended Line From Start to End Date.

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

    Draw Extended Line From Start to End Date.

    Hi,

    I'm trying to figure out how to draw an extended line from a starting date to an ending date to be used for an indicator panel - lets say the ADL indicator. I've been working with the code below which works on the price panel based on a comparison of 10 bars back to present bar.. Thanks so much for your help..


    if (CurrentBar < 10)return;

    if (WilliamsR (14)[0] < -50 )
    DrawExtendedLine("tag1", false, 10, High[10], 0, High[0], Color.Blue, DashStyle.Solid, 1);

    #2
    Hi Shawn,

    You can use .nets built in DateTime structure in NinjaScript. For working with extended line DateTime overloads, you place a date time object where expected. Help for working with DateTime objects is here:


    Example:
    Code:
    #region Variables
    private DateTime myDateTime = new DateTime(2011, 8, 11, 12, 0, 0);
    #endregion
    
    protected override void OnBarUpdate()
    {
    DrawExtendedLine("myELine", true, myDateTime, High[0], myDateTime.AddDays(1), High[0], Color.Blue, DashStyle.Solid, 2);
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Feedback

      Hi Ryan,

      THanks for your feedback. I wanted to use this extended line for an indicator panel - not sure how to do that. I tried inserting the sample code you sent - but it didn't work . I'm probably doing something wrong... What would be the procedure for building this indicator?

      Comment


        #4
        That's a simple example, but you can modify the Y values for the indicator you want to draw the values at.

        If you want the indicator's default panel to be something other than price, can add Overlay = false; to the script's Initialize() method.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Shawn View Post
          Hi Ryan,

          THanks for your feedback. I wanted to use this extended line for an indicator panel - not sure how to do that. I tried inserting the sample code you sent - but it didn't work . I'm probably doing something wrong... What would be the procedure for building this indicator?
          It sounds as if your line is not being drawn in the panel as you expect?

          If that is the case, you will need

          Code:
           
          DrawOnPricePanel = false;
          in your Initialize() method.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mathias79, Today, 10:38 AM
          5 responses
          16 views
          0 likes
          Last Post Mathias79  
          Started by Skifree, Yesterday, 11:41 PM
          2 responses
          13 views
          1 like
          Last Post eDanny
          by eDanny
           
          Started by TraderCro, 04-12-2024, 11:36 AM
          8 responses
          105 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by synthhokie, Today, 10:24 AM
          3 responses
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by eladlevi, Today, 11:02 AM
          0 responses
          4 views
          0 likes
          Last Post eladlevi  
          Working...
          X