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

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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,292 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X