Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Line above Entry Long

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

    Draw Line above Entry Long

    How can I draw a line say 20 ticks above my entry? Not a Horizontal Line. Just like a line spanning about 3 bars including my entry bar.
    Last edited by r3n3v; 03-17-2021, 08:05 AM.

    #2
    Hello r3n3v,

    Thank you for your post.

    Please see the attached example scripts which demonstrate how to use Draw.Line() to draw a line 20 ticks above an entry order for an indicator or strategy.

    In the indicator example script, we subscribe to Account OnOrderUpdate events and check for the "Entry" named orders in OnOrderUpdate(). We then use TriggerCustomEvent and call Draw.Line to draw a line 20 ticks above the entry order (20*TickSize). We need to use TriggerCustomEvent because we are only able to make BarsAgo references from data processing events like OnBarUpdate. (BarsAgo references are used in Draw.Line)

    In the strategy example script, we use the built-in OnOrderUpdate method. In the OnOrderUpdate method, we check for the order.Name and assign the order to our order object. Then, we check if our order object is not null and call Draw.Line() to draw a line 20 ticks above the entry order.

    See the help guide documentation below for more information.
    Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm
    OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm
    TriggerCustomEvent - https://ninjatrader.com/support/help...ustomevent.htm

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello r3n3v,

      Thank you for your post.

      Please see the attached example scripts which demonstrate how to use Draw.Line() to draw a line 20 ticks above an entry order for an indicator or strategy.

      In the indicator example script, we subscribe to Account OnOrderUpdate events and check for the "Entry" named orders in OnOrderUpdate(). We then use TriggerCustomEvent and call Draw.Line to draw a line 20 ticks above the entry order (20*TickSize). We need to use TriggerCustomEvent because we are only able to make BarsAgo references from data processing events like OnBarUpdate. (BarsAgo references are used in Draw.Line)

      In the strategy example script, we use the built-in OnOrderUpdate method. In the OnOrderUpdate method, we check for the order.Name and assign the order to our order object. Then, we check if our order object is not null and call Draw.Line() to draw a line 20 ticks above the entry order.

      See the help guide documentation below for more information.
      Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm
      OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm
      TriggerCustomEvent - https://ninjatrader.com/support/help...ustomevent.htm

      Let us know if we may assist further.
      Hi Brandon,

      Just testing out the Draw.Line.

      When I loaded the indicator, it gave the following Error message on NinjaScript Output;

      Indicator 'DrawLineAboveEntryIndicatorNT8': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

      Could you please investigate the above error.

      The Strategy seems to work.

      Omololu

      Comment


        #4
        I remember seeing another example that did not use all the order code here on the forum.
        Last edited by r3n3v; 03-17-2021, 06:08 PM.

        Comment


          #5
          Not neccesary everyone use the same way, it depend how the people write

          As long as the result is you want, then i think it is fine

          Comment


            #6
            Hello omololu,

            Thank you for your note.

            After testing the DrawLineAboveEntryIndicator_NT8 script attached in my previous reply I see the error message you are referring to. I have attached a modified version of the script that no longer has the error message occur.

            To test this indicator, enable the indicator on the chart, open Chart Trader in the chart window, select an ATM Strategy template, and place an order. Once the order is placed, a solid green line is drawn 20 ticks above the entry order.

            Let us know if we may assist further.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Appreciate your Help Brandon! I'll try it out!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              332 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X