• 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

    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

    #2
    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.
    BertrandNinjaTrader Customer Service

    Comment


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

      Comment


        #4
        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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by FMtrader, 03-15-2019, 02:30 AM
        6 responses
        32 views
        0 likes
        Last Post James108  
        Started by timko, Today, 08:18 AM
        0 responses
        2 views
        0 likes
        Last Post timko
        by timko
         
        Started by victorsmith, Today, 06:00 AM
        0 responses
        4 views
        0 likes
        Last Post victorsmith  
        Started by sohailashraf, Yesterday, 10:18 PM
        0 responses
        6 views
        0 likes
        Last Post sohailashraf  
        Started by jjnc2006, Yesterday, 07:36 PM
        0 responses
        16 views
        0 likes
        Last Post jjnc2006  
        Working...
        X