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

How to use BarsSinceExit() in Strategy Builder

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

    How to use BarsSinceExit() in Strategy Builder


    Please elaborate on how to use barssinceexit in NT8 Strategy Builder based on the above case. Setting it in SB is very confusing, even after reading many threads it is still vague. Please provide lines that need to be added to the Sets. Thank you.
    Last edited by NinjaTrader_PaulH; 08-06-2021, 06:03 AM. Reason: Removed NT7 quoted text.

    #2
    Hello Radano,

    Thanks for your post and question.

    As you can see I've moved your post to NinjaTrader8 strategy. The NinjaTrader7 strategy Wizard and NinjaTrader8 strategy builder are not the same things (similar but too different) and it would be inappropriate to mix the two by a discussion in the NinjaTrader7 forums when using NinjaTrader8 Strategy Builder. Moving it here helps us to keep the forum topic relevant and less confusing when someone is searching for a solution. I've also changed the title to allow for better searching. Thanks in advance for your understanding and opportunity to better answer your question.

    In NinjaTrader8, the BarsSinceExit() was renamed to BarsSinceExitExecution().

    Even though you are using the Strategy Builder, it is still relevant to look at the help guide for the method and I recommend doing this when possible as this provides additional information. Here is a link to the method in the help guide: https://ninjatrader.com/support/help...texecution.htm

    In reviewing the help guide method you will see a description of: "Returns the number of bars that have elapsed since the last exit. When a signal name is provided, the number of bars that have elapsed since that last specific exit will be returned."

    In addition to the above definition, it also shows the Method Return Value An int value that represents a number of bars. A value of -1 will be returned if a previous exit does not exist.

    The reason for pointing this out is that if you are using this method as an entry condition, you also must account for the condition that a previous exit does not exist. When you apply the strategy to a chart there is no previous exit so the method will return the -1 which would prevent entries if you do not account for that.

    So if the BarsSinceexitExecution() is used as part of an entry condition, you would need to create a "condition group" in the strategy builder where it will return true if either the number of bars have passed (that you specify) since the previous entry OR there is no previous entry and the method is returning a -1 value.

    Here is a screenshot of a group condition, set to "if any" which provides the "or" logic needed. Note that this assumes no entry signal name is used and that you are looking at the latest exit.

    Click image for larger version

Name:	Radano-2.PNG
Views:	195
Size:	35.7 KB
ID:	1166744

    Here is a link to the help guide on creating a group: (Example is of a time filter) https://ninjatrader.com/support/help...ateTimeFilters

    Once you have created the group, in the group window you would click add then select Misc>Bars since exit, the center is equals, the right side is Misc>Numeric Value (in this case 5), and click OK. Next click add once again and repeat the same except provide the numeric value of -1.

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    9 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,615 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Yesterday, 05:56 PM
    0 responses
    10 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    20 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Working...
    X