Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrossAbove or CrossBelow manual line

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

    CrossAbove or CrossBelow manual line

    Hi all, are there any examples of scripts that shows how to check if a bar has crossed above/below a manually drawn line?

    #2
    Hello shildebrand324,

    Thank you for your post.

    This would be possible with a strategy that loops through drawing objects to get their price levels and uses those levels for cross-over conditions to open your position. This would require unlocking the code from the Strategy Builder in order to accomplish. The strategy can then manage the position with the Managed Approach or the Unmanaged Approach.

    See the attached example script which demonstrates how to get and print the start price and end price of a manually drawn line.

    DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
    Managed Approach: https://ninjatrader.com/support/help...d_approach.htm
    Unmanaged Approach: https://ninjatrader.com/support/help...d_approach.htm

    Note that in NinjaTrader 8, Chart Alerts could be made to easily submit an order when a price crosses over a line drawing object. These orders cannot be tied with ATM strategies, so if you are looking for more robust trading logic, then taking the same approach as described above would be advised.

    Alerts - https://ninjatrader.com/support/help...-us/alerts.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
      Is there a way to read the drawing objects in reverse order?

      Comment


        #4
        Hello shildebrand324,

        Thanks for your note.

        No, there are no documented or supported methods for reading the drawing objects in reverse order. The drawing objects are added in a list in the order that they were drawn on the chart.

        Since the drawing objects are added to a list, you could possibly consider using C# methods like <List>.Sort to sort the drawing objects list.

        Note that we do not provide C# programming education services in our Support department.

        That said, you may find more information in this publicly available documentation: https://docs.microsoft.com/en-us/dot...t?view=net-5.0

        Let us know if we may further assist.
        <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


          #5
          I guess I'm trying to find a way to get the drawing object closest to the bar

          Comment


            #6
            Hello shildebrand324,

            Thanks for your note.

            You could assign a unique tag name to the drawing object and then find the drawing object with that specific tag name.

            See the first example in this help guide page for more information: https://ninjatrader.com/support/help...rawobjects.htm

            Let us know if you have further questions.
            <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
              Figured out a way to do it use bar time and drawn object time.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              590 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              342 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              555 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              552 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X