Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Last 3 previous bar are NOT ALL X condition qualifiers before entering

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

    Last 3 previous bar are NOT ALL X condition qualifiers before entering

    Hello:

    Let's just use the standard SMA NT crossover as a base for discussion

    What condition code can be added to where it only

    1. Enters Short ONLY if the last 3 previous bars are NOT ALL higher highs in a row (i.e. green)?

    and

    2. Enters Long ONLY if the last 3 previous bars are NOT ALL lower lows in a row (i.e. red)?

    Thanks guys...



    Please let me know if anything also needs to be placed in the Variables section etc if you would...

    #2
    Hi Birdog,

    Thank you for your post.

    You would want to use the function n bars down and n bars up

    You can use these two to check for lowest lows consecutively and for highest highs.

    http://www.ninjatrader.com/support/h..._bars_down.htm
    http://www.ninjatrader.com/support/h...?n_bars_up.htm

    Let me know if I can be of further assistance
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hi Birdog,

      Thank you for your post.

      You would want to use the function n bars down and n bars up

      You can use these two to check for lowest lows consecutively and for highest highs.

      http://www.ninjatrader.com/support/h..._bars_down.htm
      http://www.ninjatrader.com/support/h...?n_bars_up.htm

      Let me know if I can be of further assistance
      Do you have a sample of it in code running on a strategy (i.e. n bars down and n bars up)?

      What are the differences and nuances of this an using bars ago?

      and

      Is there a shorter way to express this (can it be consolidated into 1 expression or command rather than 3 separate ones as seen below?):

      Code:
      && Open[0] > Close[1] && Open[0] > Close[2] && Open[0] > Close[3])
      Thanks...smile
      Last edited by birdog; 12-07-2013, 07:31 AM.

      Comment


        #4
        Originally posted by NinjaTrader_Cal View Post
        Hi Birdog,

        Thank you for your post.

        You would want to use the function n bars down and n bars up

        You can use these two to check for lowest lows consecutively and for highest highs.

        http://www.ninjatrader.com/support/h..._bars_down.htm
        http://www.ninjatrader.com/support/h...?n_bars_up.htm

        Let me know if I can be of further assistance
        Can you show some code of where to have both the up and down Nbars in the same code for longs and shorts? How does it know if the value is for up or down bars if you have it for BOTH longs and shorts...the "if" statement does not seem to differentiate...just has (value == 1) so just a little confused about that...

        @koganam could you comment?

        Comment


          #5
          Originally posted by birdog View Post
          Can you show some code of where to have both the up and down Nbars in the same code for longs and shorts? How does it know if the value is for up or down bars if you have it for BOTH longs and shorts...the "if" statement does not seem to differentiate...just has (value == 1) so just a little confused about that...

          @koganam could you comment?
          I would if I could, but the question is not clear to me. You specify using the SMA as an example, then you compare properties of individual bars. The two are at variance.

          Comment


            #6
            Originally posted by koganam View Post
            I would if I could, but the question is not clear to me. You specify using the SMA as an example, then you compare properties of individual bars. The two are at variance.
            Hi @koganam

            Thanks for looking into this...

            Oh...sorry...let me try this:

            I am incorporating these two:




            When I put in the Long for NbarsUp it works, but when I add in the NbarsDown I get error generating the code because of a apparent conflict.

            Additionally, when I am adding the additionally condition for Longs I am putting && (value == 1) which is fine by itself, but when adding for Shorts the above link still shows I put the same value of && (value == 1) . Both have no apparent text text in the condition to let it know if it is for a Long or for a Short for the NBars per the two above links.

            Does that help?
            Last edited by birdog; 12-07-2013, 02:36 PM.

            Comment


              #7
              Originally posted by birdog View Post
              Hi @koganam

              Thanks for looking into this...

              Oh...sorry...let me try this:

              I am incorporating these two:




              When I put in the Long for NbarsUp it works, but when I add in the NbarsDown I get error generating the code because of a apparent conflict.

              Additionally, when I am adding the additionally condition for Longs I am putting && (value == 1) which is fine by itself, but when adding for Shorts the above link still shows I put the same value of && (value == 1) . Both have no apparent text text in the condition to let it know if it is for a Long or for a Short for the NBars per the two above links.

              Does that help?
              What is value supposed to represent in the context. Unfortunately, without knowing what you are trying to do, I cannot see how your code manages to fit your intent. I cannot see what might be so secret about what you are doing in this instance. I might be better able to help if you showed what you have written, and how it fails to meet your purposes. I really cannot decipher the snippets.

              Comment


                #8
                Originally posted by koganam View Post
                What is value supposed to represent in the context. Unfortunately, without knowing what you are trying to do, I cannot see how your code manages to fit your intent. I cannot see what might be so secret about what you are doing in this instance. I might be better able to help if you showed what you have written, and how it fails to meet your purposes. I really cannot decipher the snippets.
                I think the messaging is losing some of the context. Nothing at all...just trying to keep it simple without a bunch of code etc. However, I believe I figured it out last night after spending like 3 hours on it. So, fyi, and others in the future...here is what I did (it seems to work but of course I am no where close to your caliber of coding at this time...smile).

                The other links I gave you appear to be wrong so:




                double valueDown = NBarsDown(3, true, true, true)[0]; //(added "Down" to identify it as unique vs. just "value")
                double valueUp = NBarsUp(3, true, true, true)[0]; //(added "Up" to identify it as unique vs. just "value")

                if (CrossBelow(Close, highestHigh, 1) && (valueDown == 1) //now it compiles cause it is not just "value")
                EnterLong();

                if (CrossAbove(Close, highestHigh, 1) && (valueUp == 1) //now it compiles cause it is not just "value")
                EnterLong();

                Sorry for the confusion...I think part of it was probably because I gave you links that did not work as the ones here now do...

                Thanks @koganam (if you have some input on it or comments your are certainly welcome to please)...smile

                As always, thanks for your input!

                Comment


                  #9
                  Originally posted by birdog View Post
                  I think the messaging is losing some of the context. Nothing at all...just trying to keep it simple without a bunch of code etc. However, I believe I figured it out last night after spending like 3 hours on it. So, fyi, and others in the future...here is what I did (it seems to work but of course I am no where close to your caliber of coding at this time...smile).

                  The other links I gave you appear to be wrong so:




                  double valueDown = NBarsDown(3, true, true, true)[0]; //(added "Down" to identify it as unique vs. just "value")
                  double valueUp = NBarsUp(3, true, true, true)[0]; //(added "Up" to identify it as unique vs. just "value")

                  if (CrossBelow(Close, highestHigh, 1) && (valueDown == 1) //now it compiles cause it is not just "value")
                  EnterLong();

                  if (CrossAbove(Close, highestHigh, 1) && (valueUp == 1) //now it compiles cause it is not just "value")
                  EnterLong();

                  Sorry for the confusion...I think part of it was probably because I gave you links that did not work as the ones here now do...

                  Thanks @koganam (if you have some input on it or comments your are certainly welcome to please)...smile

                  As always, thanks for your input!
                  That is pretty much it: track them separately, because they are separate.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  657 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  373 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  579 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X