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 llanqui, Today, 03:53 AM
    0 responses
    2 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Working...
    X