Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy/Sell 4 ticks below/above entry order

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

    Buy/Sell 4 ticks below/above entry order

    Hello,

    My strategy (already coded) buys/sells when stochastics is below 10 or above 90 respectively, what would be the code to insert if I want the strategy to actually buy 4 ticks below the actual order or sell 4 ticks above.

    Could anybody give me a hint?

    Thanks,

    Alan

    #2
    futuros, you mean then to have a price move confirm or deny the signal? So placing for example a StopMarket / StopLimit order 4 ticks above or below the signal bar extremes?

    The different order types and Enter() methods for using those would be discussed in this tip -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Yes, exactly, StopLimit order 4 ticks above or below the signal bar extremes...do you have an example (already coded in some other strategy) that I can use?

      Thanks...

      Comment


        #4
        I have attached a small example for you, this will place a stop limit order for the next bar after our condition to enter (here close crossing the prior day high) occurred. If it would not fill on the bar it was submitted on > it would expire. If you want to persist the order longer you can unlock the wizard code and use liveUntilCancelled and then CancelOrder() after a certain # of bars. The following sample will show how that could be approached -

        When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until
        Attached Files
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand, in this example that you sent me is my understanding that the strategy is buying X amount of ticks above the signal? (High[0] + Offset * TickSize)

          What I actually want is to buy x amount of ticks below the signal bar, so my code would be: EnterLongLimit(DefaultQuantity, Low[0] - Offset * TickSize, Low[0] - Offset * TickSize, "EnterLSL");

          Am I right?

          Thanks for your help...

          Comment


            #6
            Your understanding is correct for my example given. You can then instead work with a normal limit (EnterLongLimit) order that you place for the entry then at Low[0] - your offset (4 * TickSize).

            The same order expiration considerations would apply though (for any non market order in our managed mode).
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Bertrand, what is the "offset" refers to? can I avoid the offset? Like this maybe:

              EnterLongLimit(DefaultQuantity, Low[0] - 4 * TickSize, Low[0] - 4 * TickSize, "EnterLong");

              or if I have to "keep" the offset, can I place your same code in the properties region?

              [Description("StopLimitOffset")]
              [GridCategory("Parameters")]
              public int Offset
              {
              get { return offset; }
              set { offset = Math.Max(0, value); }
              }

              Comment


                #8
                You can rename the offset also to something else if you wanted. The limit order will only have one component, the limit price. With the offset you would setup how many ticks away from the signal bars high / low you want the order to be placed then.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Bertrand I don't want to bother you all day, just one last question, if I don't want the "offset" is this line of code correct? : EnterLongLimit(DefaultQuantity, Low[0] - 4 * TickSize, Low[0] - 4 * TickSize, "EnterLong");

                  Comment


                    #10
                    No worries, for the normal limit order use -

                    EnterLongLimit(DefaultQuantity, Low[0] - 4 * TickSize, "EnterLong");

                    There's no stop and limit price here, just the limit price.

                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jclose, Today, 09:37 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post jclose
                    by jclose
                     
                    Started by WeyldFalcon, 08-07-2020, 06:13 AM
                    10 responses
                    1,413 views
                    0 likes
                    Last Post Traderontheroad  
                    Started by firefoxforum12, Today, 08:53 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post firefoxforum12  
                    Started by stafe, Today, 08:34 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post stafe
                    by stafe
                     
                    Started by sastrades, 01-31-2024, 10:19 PM
                    11 responses
                    169 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X