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

One Entry per signal bar

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

    One Entry per signal bar

    Hello, I have searched through the forums seeing if I can find a solution without having to make a new thread. Though many of the problems i saw posted were about multiple entries within the same bar. I have created a signal bar and want to enter when the current candle closes below the low of the signal bar. Now no problems there, as it takes the trade and exits. The problem is it keeps using that same signal bar to take multiple trade entries instaed of just stopping until a new signal bar shows up.


    Example: Signal Bar shows up--> Current candle closes below signal bar---->Trade executes and reaches TP/SL.(as expected) --> Trade keeps executing using the same signal bar until a new one shows up.(Don't want)

    I would think the logic would be something like" Only one trade per signal bar"

    I am using strategy builder but not opposed to unlocking the code if need be.


    Thank you for your help and taking the time to read this.




    #2
    Hello jordanq2,

    Thanks for your post.

    Trades would be placed by the strategy if the condition to place the trade in your logic becomes true. If you are using Calculate mode of Calculate.OnPriceChange or Calculate.OnEachTick, it is possible that the condition to place the order could become true multiple times per bar.

    You could consider using Calculate.OnBarClose so that logic in your script processes only at the close of each bar.

    Calculate: https://ninjatrader.com/support/help.../calculate.htm

    Further, a bool variable could be used to control when trades are placed by the script. For example, you could create a bool variable on the Inputs and Variables screen of the Strategy Builder (initially set to true). You could create a condition that checks if the Position.MarketPosition (Strategy folder > Current market position) is equal to MarketPosition.Flat (Strategy folder > Market position > Flat) and set the bool to true. Then, in your condition to place the Entry order, add a condition that checks if the bool (Misc folder > User variables > <variable name>) is equal to true (Misc folder > true). After calling the Entry order method, create an action to set the bool to false.

    By doing so, the Entry order would only be placed when the bool is true and the bool would only be true when you are in a flat market position.

    See the help guide documentation below for more information.

    Builder Screens: https://ninjatrader.com/support/help...er_screens.htm
    Conditions: https://ninjatrader.com/support/help...on_builder.htm
    Actions: https://ninjatrader.com/support/help...t8/actions.htm

    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rhyminkevin, Today, 04:58 PM
    3 responses
    48 views
    0 likes
    Last Post Anfedport  
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    7 views
    0 likes
    Last Post lightsun47  
    Started by 00nevest, Today, 02:27 PM
    1 response
    14 views
    0 likes
    Last Post 00nevest  
    Started by futtrader, 04-21-2024, 01:50 AM
    4 responses
    50 views
    0 likes
    Last Post futtrader  
    Working...
    X