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 lightsun47, Today, 03:51 PM
    0 responses
    4 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    8 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    44 views
    0 likes
    Last Post futtrader  
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    13 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    8 views
    0 likes
    Last Post port119
    by port119
     
    Working...
    X