Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Define Exit Conditions for a strategy,

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

    Define Exit Conditions for a strategy,

    Hello All,

    Trying to use strategy wizard to define an exit strategy to an entry. From my initial entry if market goes against me 3 bars. Then Exit. Any Ideas on how to do that.

    #2
    Also, If price goes in my favor then reverse 3 bars then that meets my condition to exit.

    Comment


      #3
      Hello traderfolife777,

      Thank you for your inquiry.

      Here is an example below that will exit if three bars go against you in a long position:
      Code:
      When the following conditions are true:
      (add these conditions)
      (symbols in brackets denote what to select in the middle column)
      Strategy -> Current market position [==] Strategy -> Long
      Misc -> Bars since entry [==] Misc -> Numeric value -> Parameters/Value = 3
      Price data -> Close -> Parameters/Bars ago = 0 [<] Price data -> Close -> Parameters/Bars ago = 1
      Price data -> Close -> Parameters/Bars ago = 1 [<] Price data -> Close -> Parameters/Bars ago = 2
      Price data -> Close -> Parameters/Bars ago = 2 [<] Price data -> Close -> Parameters/Bars ago = 3
      
      Do the following:
      (add this condition)
      Order management -> Exit long position
      Can you please provide clarification on your second post? Are you wanting to exit if three bars go in your favor as well?
      Zachary G.NinjaTrader Customer Service

      Comment


        #4
        IF I am short market goes in my favor 6 candles for example then goes back up 3 candles then I want to be out at the close of the third..Is the logic for that similar to what you wrote above.

        Comment


          #5
          Hello traderforlife777,

          The logic would be similar.

          I would suggest using a User Defined Variable that will keep track if a condition you have created is true or not, and using that variable, determine if another set of code will execute.

          Example:
          Code:
          Set 1
          When the following conditions are true:
          (add these conditions)
          (symbols in brackets denote what to select in the middle column)
          Strategy -> Current market position [==] Strategy -> Short
          Price data -> Close -> Parameters/Bars ago = 0 [<] Price data -> Close -> Parameters/Bars ago = 1
          Price data -> Close -> Parameters/Bars ago = 1 [<] Price data -> Close -> Parameters/Bars ago = 2
          Price data -> Close -> Parameters/Bars ago = 2 [<] Price data -> Close -> Parameters/Bars ago = 3
          Price data -> Close -> Parameters/Bars ago = 3 [<] Price data -> Close -> Parameters/Bars ago = 4
          Price data -> Close -> Parameters/Bars ago = 4 [<] Price data -> Close -> Parameters/Bars ago = 5
          Price data -> Close -> Parameters/Bars ago = 5 [<] Price data -> Close -> Parameters/Bars ago = 6
          
          Do the following:
          (add this condition)
          Misc -> Set user defined variable -> Parameters/Variable = Variable0 and Parameters/Value = 1
          
          Set 2
          When the following conditions are true:
          (add these conditions)
          (symbols in brackets denote what to select in the middle column)
          User variables -> Variable 0 [==] Misc -> Numeric value -> Parameters/Value = 1
          Price data -> Close -> Parameters/Bars ago = 0 [>] Price data -> Close -> Parameters/Bars ago = 1
          Price data -> Close -> Parameters/Bars ago = 1 [>] Price data -> Close -> Parameters/Bars ago = 2
          Price data -> Close -> Parameters/Bars ago = 2 [>] Price data -> Close -> Parameters/Bars ago = 3
          
          Do the following:
          (add these conditions)
          Order management -> Exit short position
          Misc -> Set user defined variable -> Parameters/Variable = Variable0 and Parameters/Value = 0
          Zachary G.NinjaTrader Customer Service

          Comment


            #6
            need your help

            One More thing... by the way your information is helpful.

            Building logic:-
            Looking to build a short logic to enter a trade on a reversal candle after price penetrated SMA moving average.

            Short Scenario:

            Close 1>Close 3
            Price has moved up and touched or penetrated SMA 50.
            price Reversed and closed under the SMA 50 within 2 candles since the price penetration.
            Then Executed the short- entry market.

            Having a hard time coming up with a logic on market wizard to do this.

            Also, Is it possible to have a trailing stop along with multiple exit conditions . will that lead to conflict and multiple orders to exit sent then error message and strategy disabled.

            Comment


              #7
              Hello traderforlife777,

              Here are some tips:

              You could use the CrossAbove or CrossBelow in the middle column when adding conditions to check if the closing price has crossed above or below the SMA.

              You could use a user defined variable to keep track of how many bars have elapsed since the cross over by incrementing it by 1 each time a bar has passed.
              Example:
              Code:
              Misc -> Set user defined variable -> Parameters/Value = Variable0 + 1 (increments Variable0 by 1)
              Then check to see if the closing price is below the SMA and the Variable0 was a number from 0 - 2 (checking to see if the closing price has been below the SMA value within 2 bars)
              Example:
              Code:
              User variables -> Variable0 [<] Misc -> Numeric value -> Parameters/Value = 3
              Price data -> Close [<] Indicators -> SMA -> Parameters/Period = 50
              A trail stop order is automatically cancelled if the managing position is closed by another strategy generated exit order, so you shouldn't have any conflicts.
              Zachary G.NinjaTrader Customer Service

              Comment


                #8
                need your help

                I am trying to build a condition in strategy wizard:

                Long:

                LOW of candle [< or =] 50 SMA then that same candle closes[>] 50 SMA.
                Send market order to buy at the close of that (Trigger Candle).

                If candle closes under the 50 SMA then NO Trade.

                What would be the logic for that.
                If I calculate the strategy at the close of each bar would that be an issue if I want to see a price behavior that is intra candle..

                Let me know if this is making any sense to you.

                All the information below is invaluable.

                Thank you
                george

                Comment


                  #9
                  Hello traderfolife777,

                  Unfortunately, this would go beyond the realms of using the Strategy Wizard and would require custom coding.

                  I would suggest looking at the Educational Resources section of the NinjaScript section of our help guide for helpful information as a good starting off point: http://ninjatrader.com/support/helpG..._resources.htm

                  Please, let us know if we may be of further assistance.
                  Zachary G.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RubenCazorla, Today, 09:07 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post RubenCazorla  
                  Started by BarzTrading, Today, 07:25 AM
                  2 responses
                  28 views
                  1 like
                  Last Post BarzTrading  
                  Started by devatechnologies, 04-14-2024, 02:58 PM
                  3 responses
                  21 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by tkaboris, Today, 08:01 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post tkaboris  
                  Started by EB Worx, 04-04-2023, 02:34 AM
                  7 responses
                  165 views
                  0 likes
                  Last Post VFI26
                  by VFI26
                   
                  Working...
                  X