Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop trading for a period of time after x amount of consecutive losses

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

    Stop trading for a period of time after x amount of consecutive losses

    Hi, is there any support for this in NinjaTrader 8? I saw in the forums about this topic in ninjatrader 7 but assumed that it wasnt applicable in 8
    In my strategy I wanted to do the following.
    1. stop trading until next market open after (X) amount of consecutive losses
    2. stop trading until next market open if a trade loses (X)%

    is there a function or example script for this?

    Thank you!

    #2
    Hello tchen7,

    You can use int variables, bool variables, and time conditions to control when orders are submitted with logic.

    Below is a link to a similar script that stops trading after an amount of loss, but is reset when Bars.IsFirstBarOfSession is true.
    https://ninjatrader.com/support/foru...ples#post93881

    As well as a link to a forum post that discusses using an integer as a counter.
    https://ninjatrader.com/support/foru...260#post812260
    https://ninjatrader.com/support/foru...er#post1099186

    Add an int variable to count the number of losses.
    On each trade close, in OnPositionUpdate(), you can check if the last trade ProfitCurrency is below 0. If it is, increment the int counter.
    In the conditions that trigger a new entry, require this int counter to be less than the number of losses you would like.
    When Bars.IsFirstBarOfSession is true, set the int counter to 0.

    Add a bool variable to know if a trade has lost more than x percent.
    On each trade close, in OnPositionUpdate(), you can check if the last trade ProfitPercent is less than the amount you want. If it is, set the bool to true.
    In the conditions that trigger a new entry, require this bool to be false.
    When Bars.IsFirstBarOfSession is true, set the bool to false.

    Below I am providing a link to a forum post with helpful resources on getting started with C# and NinjaScript.


    Be sure to watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' and 'NinjaScript Editor 401' training videos.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    57 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X