Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy problem - wait x bars if winner/loser

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

    strategy problem - wait x bars if winner/loser

    Hi,

    I would really appreciate some help on this attached strategy. I've added notes in the code.

    We have a simple entry: a green bar.

    Then, the idea is that if the last trade is a winner, we wait 5 bars before the next entry is allowed. If the last trade is a loser, we wait 20 bars before the next trade is allowed.

    As it is, the strategy doesn't wait and continues to enter on the next green bar regardless of whether the last trade was a winner or a loser.

    I think I have a lot of things right in the code, but since I'm a novice, I have something fundamental missing, or in the wrong order, or I need to nest some if's...

    Any hints would be greatly appreciated

    thanks,
    David
    Attached Files
    Last edited by trader3000a; 02-25-2023, 11:15 AM.

    #2
    Hello trader3000a,

    From what I can see you are using BarsSinceExitExecution, if you are not seeing this work as expected you need to use prints to find out why.

    You are printing the profit but you are not printing the values you use in all of your conditions.

    You also have a first entry condition that can happen any time the Close is greater than the open. If you are using that as a starting trade I would suggest to remove that and instead use BarsSinceExitExecution value of -1 to know an exit was not found to know to place an initial entry.

    https://ninjatrader.com/support/help...lightsub=BarsS inceExitExecution
    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.​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    46 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    28 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X