Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execute Trade X number of ticks from outter Boilnger band

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

    Execute Trade X number of ticks from outter Boilnger band

    I'm using the Strategy wizard and I'm having an issue figuring out how to execute a trade from a certain number of ticks from a bollinger band (outter band)).

    Any ideas?

    #2
    Hi TD-Trader747, are you looking for something like the attached? This enters a short by market order when the Close is 4 ticks (offset setting) higher than the upper Bollinger Band.
    Attached Files
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Between 2 and 4 ticks

      Thanks..I think thats it. How about if I wanted it to execute between 2 and 4 ticks ? I added both scenario's using the NT strategy tool in to the same set (Set 1).

      So I have:
      Close[0] + 4 * Ticksize <=Bollinger(xxxx).Lower[0]
      Close[0] + 2 * Ticksize >=Bollinger(xxxx).Lower[0]

      The I have the enter short in the "do the following" area.

      Is this correct?

      Comment


        #4
        That would be correct.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          not executing

          Ok thanks.

          For some reason it is not executing. I have the strategy added to the chart. Is there a setting I'm missing?

          I have the order properties set to the following:
          Set order quantity = by strategy (I just entered 2 on the execution amount.
          Time in Force = GTC

          Also, how would I change the TIME in Force for only x amount of bars?

          Comment


            #6
            Check the Control Center logs for errors. Are you also connected to a live data feed?

            You cannot change TIF for x amount of bars from the Strategy Wizard.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Log

              In the log it says 'automated trading disabled'.

              Where is that setting?

              Comment


                #8
                This refers to the Automated Trading Interface to execute signals from external programs.

                Can you please attach the full code you have now so I can take a look?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Code

                  I didnt include the wizard code that was in it. I also attached the exported strategy..

                  namespace NinjaTrader.Strategy
                  {
                  /// <summary>
                  /// Enter the description of your strategy here
                  /// </summary>
                  [Description("Enter the description of your strategy here")]
                  public class AT1 : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  private int myInput0 = 1; // Default setting for MyInput0
                  // 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()
                  {
                  SetProfitTarget("", CalculationMode.Ticks, 4);
                  SetStopLoss("", CalculationMode.Ticks, 6, false);

                  CalculateOnBarClose = true;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (CrossAbove(EMA(14), Bollinger(2, 14).Lower, 1)
                  && Close[0] + 2 * TickSize >= Bollinger(2, 14).Upper[0]
                  && Close[0] + 4 * TickSize <= Bollinger(2, 14).Upper[0])
                  {
                  EnterLongLimit(2, 0, "");
                  }

                  // Condition set 2
                  if (CrossBelow(EMA(14), Bollinger(2, 14).Lower, 1)
                  && Close[0] + 2 * TickSize >= Bollinger(2, 14).Lower[0]
                  && Close[0] + 4 * TickSize <= Bollinger(2, 14).Lower[0])
                  {
                  EnterShortLimit(2, 0, "");
                  }
                  }

                  #region Properties
                  [Description("")]
                  [Category("Parameters")]
                  public int MyInput0
                  {
                  get { return myInput0; }
                  set { myInput0 = Math.Max(1, value); }
                  }
                  #endregion
                  }
                  }
                  Attached Files

                  Comment


                    #10
                    Thanks - first you want to enter a correct limit price, a limit value of 0 will not work. Try Bid / Ask with an offset from the Price category.

                    Then you will need to rework your rules, as they never evaluate to true and trigger an order...the same bar the EMA 14 crosses above the lower Bollingers will rarely if ever coincide with the Close being 2 ticks higher than the upper Bollinger band.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks

                      Thanks. Actually, the settings are much different (boilnger is much tighter then the default settings I sent you).

                      So in order to close out the order if its not filled with in x amount of bars... I can't do that within the Strategy tool..so what would the code look like for that?

                      Comment


                        #12
                        What do you mean by "close out your order"? If you mean cancelling your order, all you need to do is not resubmit it on the next bar. If you do not call EnterLongLimit on each bar it will automatically expire and cancel out.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Still not running

                          I've attached the code.

                          I made the change to enter on ask or bid price. I then went to the strategies tab and started hit the start button.

                          I put my actual values in so you can see it in action. Any ideas as to what I'm doing wrong?

                          Thanks again for all your help.
                          Attached Files

                          Comment


                            #14
                            Thanks, you will need to check your conditions again, as they appear to be too 'hard' since no trade is triggered even when reverting back to market orders.

                            Also you limit orders for long and short both enter on the ask so you may want to recheck this, too.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              This seems like a old thread, but like to why whey do we enter on 1st bar closing outside, isnt too early, as the trend continues and there could be many bars following in same direction and still closes outside the bar?
                              I enter on 2nd bar that closes inside the band after 1st bar closes outside. But wanted to share how others enter the trade and if this is good method?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              21 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              163 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Started by Mizzouman1, Today, 07:35 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X