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

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
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X