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

Bars Since Exit - Wizard

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

    Bars Since Exit - Wizard

    I am building a strategy in the strategy wizard and it seem to work great. That is until I use “bars since exit”. I am trying to not enter another trade until at least 10 bars have closed. I am testing for a single day and the strategy recognizes 19 trades. However, two trades are entered immediately upon the close of a previous trade. I am trying to eliminate those two trades. When I use the “bars since exit”, the strategy finds 0 trades.

    Note: I am using a “user defined variable” as “exitbars” so that I can change this in the optimizer. So, my command says left side “bars since exit” middle “>” and right side “exitbars”. Under user defined inputs “exitbars” = 10.

    This is frustrating. I feel that the strategy is working perfectly except this minor (major) issue. Any help would be greatly appreciated. Thanks!

    #2
    Hello tdrogersnt,

    Thank you for your note.

    The first trade for the strategy would need to occur before BarsSinceExit() would properly work in this case. If all entries must have a set number of bars after and exit, then no trades are placed as there is no first trade. So we need to ensure that first trade is placed. You can use a bool for this, such as the following:
    Code:
    private bool firsttrade = true;
    ...
    if(firsttrade)
    {
    // Place first trade
    firsttrade = false;
    }
    Now the first trade will be placed and you can use BarsSinceExit() for the remaining entries. Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by FishTrade, Yesterday, 11:11 PM
    3 responses
    11 views
    0 likes
    Last Post FishTrade  
    Started by Graci117, Today, 09:02 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ETFVoyageur, Today, 07:55 PM
    0 responses
    8 views
    0 likes
    Last Post ETFVoyageur  
    Started by janio973, Today, 07:24 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by aligator, 01-06-2022, 12:14 PM
    4 responses
    250 views
    0 likes
    Last Post john_44573  
    Working...
    X