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

avoid re-enter after a stop-loss is hit

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

  • NinjaTrader_Jesse
    replied
    Hello DMDINAZ,

    Welcome to the NinjaTrader support forum.

    In the builder, you would essentially just want to prevent further entries after the first as you can only set stop losses which always apply and cannot monitor them in the builder.

    You can do this by using user variables, here is one example of toggling between long and short only allowing one entry per side.
    1. from the inputs and variables section, define a bool variable named CanEnterLong and set its default value to true.
    2. from the inputs and variables section, define a bool variable named CanEnterShort and set its default value to true.
    3. In the long entry condition, in addition to the existing conditions check that the CanEnterLong bool variable is true
    4. In the long entry action, in addition to entering set the value of the CanEnterLong to false.
    5. In the long entry action, in addition to entering set the value of the CanEnterShort to true.

    This creates a one time entry for the long side but also enables the short side. The short side would be set up in the same way except it would check CanEnterShort is true in its condition and set CanEnterShort to false and CanEnterLong to true in its action. This will toggle between long and short trading and only allow one entry in that direction as it sets the bool to false once you enter.

    I look forward to being of further assistance.

    Leave a comment:


  • DMDINAZ
    replied
    Hello all,
    Since I am not a coder, does anyone know how to do this (prevent re-entry after stop loss) in Strategy Builder?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Hi Trendseek, you spotted the correct sample - with the help of the sample code you could check if the last trade was a stop out and then avoid entering the next signal in this direction by working with bool flags in your conditions.

    Leave a comment:


  • Trendseek
    started a topic avoid re-enter after a stop-loss is hit

    avoid re-enter after a stop-loss is hit

    Hi Ninjas.

    Assumed, that I am using a simple Strategie that goes long/short under the following circumstances:


    1) if (SMA(period)[0] > SMA(period)[1])
    --> Enter Long

    2) if (SMA(period)[0] < SMA(period)[1])
    --> Enter Short

    within that Strategie I am also using a simple Stop-Loss. For example something like that:

    // if long
    3) SetStopLoss(CalculationMode.Price, Math.Max(Close[0] - Distance, Close[1] - Distance));


    To prevent, that this simple Strategy will re-enter after a stop-loss, I need to check within condition (1) and (2), whether the stop-loss (3) was hit or not in the last Bar.

    How can I do that?

    I found something about Monitoring - perhaps this is the right thing?


    But I have no Idea how to use this in a simple way within my strategie.

    Hope someone can give me a Hint

    Regards
    Trendseeker

Latest Posts

Collapse

Topics Statistics Last Post
Started by bortz, 11-06-2023, 08:04 AM
47 responses
1,607 views
0 likes
Last Post aligator  
Started by jaybedreamin, Today, 05:56 PM
0 responses
9 views
0 likes
Last Post jaybedreamin  
Started by DJ888, 04-16-2024, 06:09 PM
6 responses
19 views
0 likes
Last Post DJ888
by DJ888
 
Started by Jon17, Today, 04:33 PM
0 responses
6 views
0 likes
Last Post Jon17
by Jon17
 
Started by Javierw.ok, Today, 04:12 PM
0 responses
15 views
0 likes
Last Post Javierw.ok  
Working...
X