Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit Immediately

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

    Exit Immediately

    I am losing my mind.

    Simple strategy I cannot for the life of me get to work with the wizard. If I enter a long position, I want to exit immediately the next bar if the price falls below the previous bars low.

    So go long on a 15 minute chart at 9:05am and the 9-9:15 bar ranges from from 12-13$, and in the 9:15-30 bar if at any point the price is < 12$ (previous bars low) then exit long position.

    I am using the wizard and i cannot get it to work.

    I have the following:
    position.marketposition == marketposition.long
    low(0)<low(1)

    do the following:
    ExitLong

    I have calculate on bar close = false

    Many Thanks

    D.

    #2
    Hi deurich,

    Thank you for your post.

    Keep in mind that if you reference Low[0], this will still look at the previous bar. That's because it doesn't actually know where the low is yet. Try Close[0] instead. With CalculateOnBarClose = false, it will assume you mean the current price of the current bar.
    TimNinjaTrader Customer Service

    Comment


      #3
      Well I tried the following;

      BarSinceEntry()==1
      PositionMarketPosition == MarketPosition.Short
      Close(0)>High(1)

      ExitShort

      As you can see from the picture, the exit did not trigger until my stop loss at 50 ticks? Not sure what I did wrong here?
      Attached Files

      Comment


        #4
        Hi deurich,

        You have BarSinceEntry()==1, and on the following bar the price was never greater than the high of the previous. You may want to change this to not include the BarsSinceEntry line.
        TimNinjaTrader Customer Service

        Comment


          #5
          Hi Tim, I have tried that as well. Same result, exit never triggers despite the fact that each of the green bars for sure are higher than the previous bar.

          D.

          Comment


            #6
            Please post exact, complete code along with exact TraceOrders = true output. Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Ok, I understand why it is exiting when it does .. because my code is wrong!

              What I basically want is a trailing stop with the stop set to the previous bars low (if I was long for example) or previous bars High (if I was short).

              If the trade movies in my favour, I want to stay in the trade until the price breaks below the previous bars low or high.

              The way I had written the code it went off of the previous bar prior to my trade entry. I would like to try and make it a trailing stop type of entry.

              I assume I have to use the time command but not sure how? May have to ask your programming group??

              Thanks

              D.

              Comment


                #8
                Hi deurich,

                Here are a few resources on setting and changing the stop loss (trailing stop).



                TimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by charlesugo_1, 05-26-2026, 05:03 PM
                0 responses
                55 views
                0 likes
                Last Post charlesugo_1  
                Started by DannyP96, 05-18-2026, 02:38 PM
                1 response
                142 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 05-11-2026, 05:56 AM
                0 responses
                160 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 05-10-2026, 08:12 PM
                0 responses
                96 views
                0 likes
                Last Post CarlTrading  
                Started by Hwop38, 05-04-2026, 07:02 PM
                0 responses
                276 views
                0 likes
                Last Post Hwop38
                by Hwop38
                 
                Working...
                X