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

SetStopLoss not working - Multiple Exit Strategy

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

    SetStopLoss not working - Multiple Exit Strategy

    Hi,
    I've been struggling with this one for a few days now and have tried to check out other forum threads to no avail... Any pointers gratefully received!!!! I'm probably overcomplicating it...

    This code detects a two bar pattern (I'm using daily bars from Yahoo) to spot a probable reversal. I've programmed an indicator called TrendingDay to spot the first bar in the pattern, which I call from the Strategy.

    If a pattern is spotted, several variables (e.g. Variable0) are set representing the price targets, initial StopLoss ("1R"), and lock-in profits stoplosses ("2R" and "4R"). The idea is to let profits run by tightening stops as price targets are reached.
    I've programmed indicators ATRStopsOpen and ATRProfitTargetsOpen which assign these Variables to each incoming bar.
    Then the corresponding EnterLong or EnterShort is made.

    Unfortunately, my Stops don't seem to be registering at all!?

    Is there a simpler way to program this strategy?

    Thanks for any help you can give me (I think my head is about to explode...)

    Olly
    Attached Files

    #2
    Someone will follow up on Monday.
    RayNinjaTrader Customer Service

    Comment


      #3
      ollywedgwood,

      In order for you to scale-out with multiple stop-loss levels you would need to scale-in first. You need to tie each stop-loss level to an individual entry signal. Please see this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=3751
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Josh View Post
        ollywedgwood,

        In order for you to scale-out with multiple stop-loss levels you would need to scale-in first. You need to tie each stop-loss level to an individual entry signal. Please see this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=3751
        Hi Josh - thanks for your reply.
        I don't wish to scale out - i.e. take 1/3 of profits at one target, then another 1/3 at the next target etc, but simply to tighten the stoploss for a single entry when it reaches a certain price, i.e. 'lock-in' a proportion of the profit. If the price falls to the new stoploss, then the whole of that trade is exited.

        Can this work using one entry signal and then moving the stoploss when certain conditions are met?

        Thanks!

        Olly

        Comment


          #5
          Olly,

          That would work too. In that case, please see this reference sample instead: http://www.ninjatrader-support2.com/...ead.php?t=3222
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks Josh - Do I need to put the SetStopLoss in the Initialise() and the OnBarUpdate() sections if the stoploss is going to be dynamically moved when certain conditions are met? In my strategy code, I have only put the SetStopLoss in the OnBarUpdate() section.

            For some reason, my stops are just not firing on the backtest. I am, however, getting Output Window printouts of the stoploss price... Perhaps it also may be something to do with the fact that I'm only using daily bars?

            Thanks again for your help!

            Comment


              #7
              Olly,

              It is recommended that you place your initial stop loss from the Initialize(), move it around in OnBarUpate(), and as your position is closed, reset your stop loss to its initial value.

              Please check the Control Center logs for any errors. You may be submitting invalid stop prices. You can also try using TraceOrders = true to better debug your orders. http://www.ninjatrader-support2.com/...ead.php?t=3627
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Fantastic - thank you Josh, much appreciated - I'll try that.

                Olly

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DawnTreader, 05-08-2024, 05:58 PM
                23 responses
                86 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by DustyContrer, Today, 04:02 AM
                0 responses
                3 views
                0 likes
                Last Post DustyContrer  
                Started by ETFVoyageur, Today, 02:15 AM
                0 responses
                11 views
                0 likes
                Last Post ETFVoyageur  
                Started by Board game geek, Today, 01:34 AM
                0 responses
                145 views
                0 likes
                Last Post Board game geek  
                Started by morrnel, 05-12-2024, 06:07 PM
                3 responses
                45 views
                0 likes
                Last Post wzgy0920  
                Working...
                X