Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I need help with Bollinger Bands strategy

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

    I need help with Bollinger Bands strategy

    I have created a simple BB strategy that buys when close price crosses above lower band and sells when close price crosses below upper band. The problem I am having is that ther are many places throughout the chart where there no buys or sells even though close price condition is met. My code is below. Thank you

    Code:
        [Description("Enter the description of your strategy here")]
        public class BollingerStrategy1 : Strategy
        {
            #region Variables
            // Wizard generated variables
            // User defined variables (add any user defined variables below)
            #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
    
                CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
                if (CrossAbove(Close, Bollinger(2, 14).Lower, 1))
                {
                    EnterLong(DefaultQuantity, "");
                }
    
                // Condition set 2
                if (CrossBelow(Close, Bollinger(2, 14).Upper, 1))
                {
                    ExitLong("", "");
                }
    
            }
    
            #region Properties
            #endregion
        }
    }

    #2
    relogical, thanks for the post and welcome to our forums here - to which Bollinger Band settings are you comparing the strategy signals? Are you sure you're using the same paramters for those as the strategy would (it uses the default 14, 2) settings here...given a short period and relatively high deviation value I wouldn't expect all swings to generate a signal...but of course would depend on market and timeframe traded. To see visually when a condition trigger would occur it can be very helpful to draw from the strategy as well -

    http://www.ninjatrader.com/support/h...gy_actions.htm (last section here please)

    Comment


      #3
      Visually I can see the bars crossing the lower and upper bands but there are no buys or sells executed. Only some positions are executed but not all.

      Comment


        #4
        Can you please post a screen-shot of the behavior you would get including the confirmation drawing objects added?

        Thanks,

        Comment


          #5
          Chart image attached
          Attached Files

          Comment


            #6
            Thanks, I see no crossing of the Close price on your screenshot for the marked times?

            Please add a drawing on the conditions to easily verify what signals to expect from your script.

            Comment


              #7
              Agreed. What you are indicating would be the LOW crossing below the lower BB, not the close. I don't think there is an error in your code. I think you might be expecting something else from it, though.

              EDIT: In fact, I'm not even sure why the BUY and SELL orders were triggered on the bars indicated in your graphic. I would not have expected any trades from this time period, since none of the bar closes were above or below the BBs.
              Last edited by Kevin_in_GA; 06-07-2012, 08:18 AM.

              Comment


                #8
                BB on MACD

                Is there any way to place a Bolinger band ,applied to to a MACD sug graph,and hav eit apply to the BB and not the pirce chart plez?

                Comment


                  #9
                  laredo,

                  I would suggest creating a new thread to discuss this as we may need to ask you a few questions related to what it is you are trying to do, that and it isn't specifically related to what the original poster was discussing.

                  You can create a new thread by going here : http://www.ninjatrader.com/support/f...splay.php?f=15

                  Then, click the "New Thread" button like in the screen shot.
                  Attached Files
                  Adam P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  61 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  40 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  21 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  23 views
                  0 likes
                  Last Post TheRealMorford  
                  Started by Mindset, 02-28-2026, 06:16 AM
                  0 responses
                  51 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X