Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BOOL example needed

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

    BOOL example needed

    I have a condition that's fairly simple yet. For some reason, I can't get it to work in the strategy builder. I have a breakout that takes an entry once price closes above a level. Instead of entering on the breakout candle I want the next candle to be green before entry is made. Thus we have 2 conditions that need to be satisfied prior to entry.

    Anyone have an example of this for builder

    #2
    Hello Teebone21,

    Thank you for your post.

    First, are you wanting to wanting to enter on the bar right after the cross above happens? Or, do you want the strategy to wait until after the close of the bar it happened on to make sure that bar is green (which would mean entering on two bars after the crossover)?

    If so, you may need to use a bool if you are using CrossAbove().

    One set would check if CrossAbove is true, then set your bool to true.

    The next set will check if the bool is true, and if the Close is less than the Open (meaning a red bar) and set the bool to false so it will not enter / continue onto the next set.

    The last set will check if the bool is true, and if the Close is greater then the Open (a green bar) and if so you can add an action to enter.

    I have added a sample script you can look at demonstrating this (it uses Calculate.OnBarClose).

    Please note this also depends if you are calculating OnBarClose or OnEachTick/OnPriceChange. Calculating OnEachTick/OnPriceChange will cause OnBarUpdate to update on the "current forming bar" instead of the previously formed bar.

    Calculate - https://ninjatrader.com/support/help.../calculate.htm
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Hello Teebone21,

      Thank you for your post.

      First, are you wanting to wanting to enter on the bar right after the cross above happens? Or, do you want the strategy to wait until after the close of the bar it happened on to make sure that bar is green (which would mean entering on two bars after the crossover)?

      If so, you may need to use a bool if you are using CrossAbove().

      One set would check if CrossAbove is true, then set your bool to true.

      The next set will check if the bool is true, and if the Close is less than the Open (meaning a red bar) and set the bool to false so it will not enter / continue onto the next set.

      The last set will check if the bool is true, and if the Close is greater then the Open (a green bar) and if so you can add an action to enter.

      I have added a sample script you can look at demonstrating this (it uses Calculate.OnBarClose).

      Please note this also depends if you are calculating OnBarClose or OnEachTick/OnPriceChange. Calculating OnEachTick/OnPriceChange will cause OnBarUpdate to update on the "current forming bar" instead of the previously formed bar.

      Calculate - https://ninjatrader.com/support/help.../calculate.htm
      Thank you for the reply. I would like to enter 2 bars after the cross over. But the second bar after the crossover has to close green Is in order for the buy condition to happen on Open of 3rd bar

      Comment


        #4
        Hello,

        In that case, you can set it up as described in my previous reply with the bool.

        Please let us know if you have any other questions.

        Comment


          #5
          Originally posted by NinjaTrader_Gaby View Post
          Hello,

          In that case, you can set it up as described in my previous reply with the bool.

          Please let us know if you have any other questions.
          Thanks for the example. What you provided only enters after the close as normal. I tried added 2 bool conditions and still no luck. It seems like it should be simple but it doesnt work for some reason.

          Comment


            #6
            example of what i am looking for
            Click image for larger version

Name:	image.png
Views:	109
Size:	25.1 KB
ID:	1274219

            Comment


              #7
              Hello,

              Since you need the to track if the bools are triggering on specific bars and not any bars, it may be better to put this in one condition:

              if (Close[0] > Open[0] && Close[2] < MyPriceLevel && Close[1] > MyPriceLevel)

              Please see this forum post which has an example script:

              https://forum.ninjatrader.com/forum/...ly#post1131172

              If you have any questions, please let me know

              Comment


                #8
                Originally posted by NinjaTrader_Gaby View Post
                Hello,

                Since you need the to track if the bools are triggering on specific bars and not any bars, it may be better to put this in one condition:

                if (Close[0] > Open[0] && Close[2] < MyPriceLevel && Close[1] > MyPriceLevel)

                Please see this forum post which has an example script:

                https://forum.ninjatrader.com/forum/...ly#post1131172

                If you have any questions, please let me know
                i was unable to complete my project after multiple attempts. I figured a simple bool could solve the issues or just using candle close comparison. I may just pay someone to recreate this. Thank you for your assistance

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                43 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                124 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                65 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                42 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X