Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trade exit, condition still true, stop re-entering

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

    Trade exit, condition still true, stop re-entering

    Hi,

    I have a simple strategy in the wizard. It is working OK without stops and targets set. It is very basic (it´s my first one, trying to learn).....

    The basic condition is that it goes long on break of previous candle high...... OK, simple enough, working fine. It also reverses and goes short on break down of previous candle low.... OK, fine.

    Now I have added a small target to it, 5 cents. This is working fine also, it closes the initial trade at 5cents target... BUT as soon as it closes the trade it then immediately goes long again, as we are above the last candle high still.

    How do I stop it re-entering as soon as it takes the profit target?

    #2
    Hello ScottieDog,

    Thank you for your post.

    Depending on what you are waiting for after the target fills you can use BarsSinceExit() before placing another entry: http://www.ninjatrader.com/support/h...ssinceexit.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Im trying to add this in the wizard.

      I´ve found the "Bars since exit" in the conditions, but when I chose "time series bars ago1" I get an error message saying "return type of left expression "int32" and right expression "datatime" do not match"

      How do I add this condition in the wizard?

      Comment


        #4
        One way to tackle this can be to add a boolean variable to keep track whether or not trade is already taken.
        For example,

        //In Initialize section
        bool TradeTaken = false;

        At the trade entry, check and take entry only if TradeTaken==false, and at the same time, set the bool flag to true.

        if (TradeTaken==false)
        {
        //take entry
        TradeTaken=true;
        }

        Hope this works!

        Comment


          #5
          Originally posted by ScottieDog View Post
          Im trying to add this in the wizard.

          I´ve found the "Bars since exit" in the conditions, but when I chose "time series bars ago1" I get an error message saying "return type of left expression "int32" and right expression "datatime" do not match"

          How do I add this condition in the wizard?
          You will want to use BarSinceEntry and compare to a Numeric value.

          I'm not exact sure where you were access a date time type, however the attached should help get you started.
          Attached Files
          MatthewNinjaTrader Product Management

          Comment


            #6
            That was a help. Thank-you.

            Comment


              #7
              How would I add

              "or hasn´t traded before" to the condition, using the wizard?

              I have this...

              Code:
              && BarsSinceEntry() > 1
              I want it to be
              Code:
              && BarsSinceEntry() > 1
              OR never traded before

              Comment


                #8
                I found that I can write this

                Code:
                // Only enter if at least 10 bars has passed since our last exit or if we have never traded yet
                    if ((BarsSinceExit() > 10 || BarsSinceExit() == -1)

                So I know that I have to write || for "or"... but how do I do this in the wizard?

                Comment


                  #9
                  Hello ScottieDog,

                  You cannot write an || ('or') statement inside of the Strategy Wizard, so you would have to use two different "Sets" (Example Set1 and Set2) to be able to define this. So for example you could put BarsSinceExit() > 10 in Set1 and then BarsSinceExit() == -1 in Set2 and have the same thing.

                  Let us know if you have any questions.
                  JCNinjaTrader Customer Service

                  Comment


                    #10
                    OK: Great. Understood.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by argusthome, Yesterday, 10:06 AM
                    0 responses
                    22 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    19 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    14 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post TheRealMorford  
                    Started by Mindset, 02-28-2026, 06:16 AM
                    0 responses
                    41 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Working...
                    X