• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

avoid re-enter after a stop-loss is hit

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

  • 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?
    http://www.ninjatrader.com/support/f...ead.php?t=5790

    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

  • 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:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Longhornmark, Today, 08:22 AM
0 responses
2 views
0 likes
Last Post Longhornmark  
Started by akuntysh, Today, 12:02 AM
2 responses
10 views
0 likes
Last Post akuntysh  
Started by hir04068, Today, 04:26 AM
1 response
8 views
0 likes
Last Post NinjaTrader_PaulH  
Started by Revan, Yesterday, 11:53 PM
4 responses
26 views
0 likes
Last Post NinjaTrader_Jim  
Started by Vincere, Today, 03:32 AM
1 response
4 views
0 likes
Last Post NinjaTrader_ChrisSch  
Working...
X