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

When profit target hit on the same candle as entry, how to prevent a 2nd entry?

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

    When profit target hit on the same candle as entry, how to prevent a 2nd entry?

    I am using Strategy Builder, and ran into this issue -

    1) Conditions are met for trade entry and an entry by the system with profit target and stop loss orders attached.

    2) In that same candle, the profit target is hit

    3) However, entry conditions still apply, so NT then renters on the same bar.

    I am trying to prevent part three from happening - i.e.; only one entry is allowable per bar.

    Changing to UniqueEntries prevents multiple concurrent positions, not sequential ones, within the same bar.

    I thought about using BarsSinceEntry and setting it to greater than 0, but the issue is this will also prevent the first trade. Same problem if I use BarsSinceExit

    I would appreciate any help on this.​

    #2
    Hello anotherone1,

    Thank you for your post.

    It sounds like you could still use BarsSinceEntry or BarsSinceExit; on top of checking for a value greater than 0, you will also need to check if it is equal to -1. The value of -1 is returned if a previous entry/exit does not exist. For more info, please see the following help guide pages:Using this example from the help guide, here is a screenshot of what that would look like in the Strategy Builder:
    Code:
    // Only enter if at least 10 bars has passed since our last entry
    if ((BarsSinceEntryExecution() > 10 || BarsSinceEntryExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
    EnterLong();

    Screenshot: https://www.screencast.com/t/KGE9Ts7K7T

    Please let me know if I may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Started by ChartTourist, Today, 08:22 AM
    0 responses
    6 views
    0 likes
    Last Post ChartTourist  
    Started by LiamTwine, Today, 08:10 AM
    0 responses
    2 views
    0 likes
    Last Post LiamTwine  
    Started by Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Working...
    X