Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

hitting Targets with CrossAbove

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

    hitting Targets with CrossAbove

    With Calculate.OnEachTick I have 4 long targets and I want to create a text message on the chart (e.g. T1 Hit, T2 Hit etc) as each one is hit as the market moves up.

    can I use something like this?

    Code:
    if (T1 == false && CrossAbove (Close, T1, 1))
      T1 = true;
    if (T1 == true && T2 == false && CrossAbove (Close, T2, 1))
      T2 = true
    if (T1 == true && T2 == true && T3 == false && CrossAbove (Close, T3, 1))
      T3 = true
    if (T1 == true && T2 == true && T3 == true && T4 == false && CrossAbove (Close, T4 1))
      T4 = true
    ​
    or is there a chance, due to gapping etc, that a target could be missed?

    #2
    Hello fingers,

    Thanks for your post.

    To clarify, is T1, T2, etc. in the CrossAbove() conditions referring to the price you are assigning each profit target order?

    If so, then yes you could consider taking this approach to detect if the Close price crosses above the profit target order prices.

    The Draw.Text() method would be used to draw text on the chart when a certain condition becomes true.

    Otherwise, you could consider tracking your orders as Order objects in OnOrderUpdate() and OnExecutionUpdate(), then in OnExecutionUpdate() detect if the OrderState is equal to OrderState.Filled for a specific Order object and call the Draw.Text() method to draw text on the chart.

    See the help guide documentation below and SampleOnOrderUpdate reference sample for more information.

    Draw.Text(): https://ninjatrader.com/support/help.../draw_text.htm
    OnOrderUpdate(): https://ninjatrader.com/support/help...rderupdate.htm
    OnExecutionUpdate(): https://ninjatrader.com/support/help...tionupdate.htm
    SampleOnOrderUpdate reference sample: https://ninjatrader.com/support/help...and_onexec.htm
    <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

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    592 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 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
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X