• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BollingerPercentB2

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

    BollingerPercentB2

    I downloaded the BollingerPercentB2 indicator from this Forum and inserted it into a NinjaScript strategy. However, the strategy doesn't "know" the indicator. The trades are executed in a manner completely unrelated to the logic. Can I correctly use a downloaded indicator within a NinjaScript strategy?

    #2
    Hi TedLincoln, welcome to the NinjaTrader support forums! Can you please post the code you used so we can take a look? Thank you!
    BertrandNinjaTrader Customer Service

    Comment


      #3
      THIS IS THE STRATEGY I USED. BECAUSE THE "LOW PCT" ON THIS INDICATOR IS A NEGATIVE NUMBER, I USED VARIOUS COMPARATORS; ALL TO NO AVAIL.

      For the indicator code, please look at the code for indicator
      "BollingerPercentB2" Take note of the command "CalculateOnBarClose = false." This looks suspect.
      [

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Fade Bollinger high and low line.
      /// </summary>
      [Description("Fade Bollinger high and low line.")]
      public class BollingerFade : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int highLine = 60; // Default setting for HighLine
      private int lowLine = 60; // Default setting for LowLine
      // 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()
      {
      Add(BollingerPercentB2(20, 2));

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (BollingerPercentB2(20, 2).PctB_High[0] >= HighLine)
      {
      EnterShort(DefaultQuantity, "");
      }

      // Condition set 2
      if (BollingerPercentB2(20, 2).PctB_Low[0] >= LowLine)
      {
      EnterLong(DefaultQuantity, "");
      }
      }

      #region Properties
      [Description("High Bollinger Band")]
      [Category("Parameters")]
      public int HighLine
      {
      get { return highLine; }
      set { highLine = Math.Max(1, value); }
      }

      [Description("Low Bollinger Band")]
      [Category("Parameters")]
      public int LowLine
      {
      get { return lowLine; }
      set { lowLine = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        Hi Ted, since you use CalculateOnBarClose = false in your strategy, please open up the BollingerPercentB2 indicator script and delete any CalculateOnBarClose setting you see there, then hit F5 to compile all again. The retest this strategy on live data. Thanks!
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I want this strategy to work in a simple fashion: when the PCTB_High => 50 go short, when the PCTB_Low =< -50 go long. I can't get this to work properly. Can you put this together correctly, and ship it to me? Otherwise, am I limited to only using the indicator notwithstanding any strategy? If this is the case, I would be greatly disappointed.

          Comment


            #6
            Hi Ted, have you tried setting this basic strategy up in our Strategy Wizard?

            It does not require programming and allows you to configure your strategies with a point & click approach - http://www.ninjatrader-support.com/H...rdScreens.html

            Later you can view your strategy code to make a smoother transition to programming more advanced concepts in the NinjaScript editor.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Your response: "have you tried setting this basic strategy up in our Strategy Wizard?" Of course!! Try setting up this simple strategy, and send me the code. Otherwise, I must assume that there is no viable response from your end.

              Comment


                #8
                Ted,

                If it doesn't go into the Strategy Wizard then it is likely the indicator you downloaded was never programmed in a manner to allow for this. You need to contact the original author of the indicator for support on how to use it programmatically.

                We currently do not offer custom programming services. If this is something you want you may want to consider one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
                JoshNinjaTrader Customer Service

                Comment


                  #9
                  Just make these changes and it should do what you want.

                  private int highLine = 50;
                  private int lowLine = -50;

                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (BollingerPercentB2(20, 2).PctB_High[0] >= HighLine)
                  {
                  EnterShort(DefaultQuantity, "");
                  }

                  // Condition set 2
                  if (BollingerPercentB2(20, 2).PctB_Low[0] <= LowLine)
                  {
                  EnterLong(DefaultQuantity, "");
                  }
                  }

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by StealthM93, Today, 07:58 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post StealthM93  
                  Started by Mykro, Today, 11:01 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by bauerjj10, Today, 12:24 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by Newtrader101, Today, 06:01 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_EricB  
                  Started by Steve L, Today, 03:50 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X