Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bollinger Band buy/sell indicator.

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

    Bollinger Band buy/sell indicator.

    Is there a custom indicator that shows a buy signal when the price crosses below the bollinger band and shows a sell signal when the price crosses above the bollinger band?

    I've searched the Ninjatrader filesharing db but I couldn't find one that simple. If it is possible to code it, how would I do it?

    #2
    Hi KageRyu,

    Thanks for the post and welcome to the NinjaTrader forums! I'm not aware of a strategy that does exactly this, but it is possible to code or even create in the strategy wizard. If you want to get started with code right away, the following sample can help indicator crossover strategies.


    You can also create these expressions in the strategy wizard, which is NinjaTrader's point and click interface for defining trade conditions and actions. See the following link for help building this expression. These sections should help get you started: How to compare plot values of multi-plot indicators and How to create a cross over condition

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      So I took a crack at the wizard and tried to make my own strategy. Can you take a look at the code and tell what I did wrong. I set the conditions so that a diamond shape figure will show up if the price crosses above the upper/lower plot of the Bollinger band.

      Thank you very much.
      Attached Files

      Comment


        #4
        The Y value where you draw the diamonds is 0, so not visible. See lines below which draw diamonds at bar highs or lows.

        if (CrossAbove(Close, Bollinger(2, 20).Upper, 1)
        && CrossBelow(Close, Bollinger(2, 20).Lower, 1))
        {
        DrawDiamond("My diamondHigh" + CurrentBar, false, 0, High[0], Color.Red);
        DrawDiamond("My diamondLow" + CurrentBar, false, 0, Low[0], Color.Blue);
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          So...attempt #2.

          I tried setting the "Y" such that it would show at the open price. However it still didn't work. What am I doing wrong?
          Attached Files

          Comment


            #6
            Your condition is likely too restrictive. You're checking that open crossed below the lower band and above the upper band on the same bar. Seems extremely rare if not impossible. Apply the bollinger indicator and check if you see any occurrence of this.

            If you instead meant to check whether one or the other occurred, join your conditions with OR operator rather than and. If you use the same tag, it's replaced. So no need for two draw statements.

            if (CrossAbove(Open, Bollinger(2, 20).Upper, 1)
            || CrossBelow(Open, Bollinger(2, 20).Lower, 1))
            {
            DrawDiamond("My diamond" + CurrentBar, true, 0, Open[0], Color.Red);
            }
            Last edited by NinjaTrader_RyanM1; 09-15-2011, 10:22 AM.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              bollinger band automated strategy

              hey,
              i made a bollinger band strategy similar to the one stated above.
              i was wondering how you would program it so that when the price breaks below the bollinger band, the program checks for the next bar.
              If the next bar opens above the bottom BB then go in on a long position.
              If price crosses above the top bollinger band, i want the program to wait and check the next bar and ensure that it opens lower than the top bollinger band.

              i also made a prototype of my program. However, when i run it on my sim accountant in real time, it makes no trades even if there are buy and sell signals.
              tell me if there is something wrong with my strategy.
              Attached Files

              Comment


                #8
                Hi fruitfly,

                Thanks for the post and welcome to the NinjaTrader forums. It sounds like you want to create sequences with your strategy. You can create these using C# bool variables or the built in user variables. Please see the link below for an example of sequences with user variables:


                If you are new to running real time strategies, first thing I would check is that there are not potential sync issues. If you see it colored yellow in strategies tab of control center, this means that it's waiting until the strategy reaches a flat state before submitting orders. More info on running real time strategies is available here;


                If you checked that out but still not seeing entries as you expect, next step is to debug it with Print() statements and TraceOrders output. These tools allow you to check all values, follow code flow, and check messages related to strategy order submission. You can read more about debugging NinjaScript here:
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by The_Sec, Yesterday, 03:37 PM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by vecnopus, Today, 06:15 AM
                0 responses
                1 view
                0 likes
                Last Post vecnopus  
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                5 views
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                27 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                36 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X