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

Plots vertical line

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

    Plots vertical line

    Hello everybody.
    I need to implement 2 vertical lines to determine the start date and the end of the data sample. In what methods should I revise them, and how can I then contact them to get the data of the time. Which method should work when dragging lines and releasing the mouse button to redraw the indicator. If there are examples or links I will be grateful.
    Thank you.

    #2
    Hello Arkaiy_B,

    To trigger an action at a specific time, you can add your action to OnBarUpdate in the action block of a condition that checks the Time series using the barsAgo index of the bar.


    Use ToTime if you want to ignore the date.


    To draw a vertical line as the action use Draw.VerticalLine().


    For example:
    Code:
    if (ToTime(Time[0]) == 90000))
    {
    Draw.VerticalLine(this, "line1", 0, Brushes.Blue);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_ChelseaB.
      I did not ask about that. The OnBarUpdate method works when the bar is closed or at each tick. I need to catch the event when I drag the vertical line. How to draw a vertical line, I also understand, I need to understand where to insert this function, State == State.DataLoaded it does not appear.

      Comment


        #4
        Originally posted by Arkaiy_B View Post
        I need to catch the event when I drag the vertical line. How to draw a vertical line, I also understand, I need to understand where to insert this function, State == State.DataLoaded it does not appear.
        I've used an OnRender() override to populate a dictionary of DrawingTool anchor SlotIndex values.

        Comment


          #5
          Hi Arkaiy_B,

          When you mention "I need to implement 2 vertical lines to determine the start date and the end of the data sample. In what methods should I revise them, and how can I then contact them to get the data of the time." are you not trying to draw two vertical lines based on a start date and end date from bar data?

          There is not a method that is triggered when the time or price value of a drawing tool anchor is changed.

          However, tradesmart is correct, OnRender() will trigger anytime you touch the chart with the mouse. If you move a drawing object this would trigger OnRender() but would not be specific to that drawing object.


          You could loop through all drawing objects and compare the anchors current values with saved values to see if they have changed.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jclose, Today, 09:37 PM
          0 responses
          6 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,414 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          11 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          11 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X