Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

placing a limit order 1 tick above signal bar

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

    placing a limit order 1 tick above signal bar

    hello
    I have strategy and I am having trouble placing an order 1 tick above signal bar. I have the code like this:
    EnterLongLimit(Convert.ToInt32(ContractSize), (High[0] + (1 * TickSize)) , "");
    but it is opening an order when that signal bar close + 1 tick and not place the limit 1 tick above signal bar.

    any help would be greatly appreciated. thank you



    #2
    Hello babouin77,

    Thanks for your post.

    A limit order to enter long must be placed below the current price. A limit order will fill at the specified price or better. When you place the long limit above the current price, the current price is a better price so it fills as a market order immediately. So this would be the expected behavior of the long limit placed above the market.

    The order type you would need to use to enter long above the current price is EnterLongStopMarket() or EnterLongStopLimit().
    References:



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      so what would the code be if I want to place an order 1 tick above the signal bar?

      Comment


        #4
        EnterLongStopMarket() or EnterLongStopLimit(). i just saw it
        thanks i will give it a shot

        Comment


          #5
          EnterLongStopLimit(Convert.ToInt32(ContractSize), (High[0] + (1 * TickSize)) , "");

          would this do the job?

          Comment


            #6
            Hello babouin77,

            Thanks for your reply.

            "EnterLongStopLimit(Convert.ToInt32(ContractSi ze), (High[0] + (1 * TickSize)) , ""); would this do the job?"
            No, you need to enter the stop price as well which can be the same price as the limit. Please review the method overloads in the referenced help guide section in post#2

            Keep in mind that in the managed approach, limit-type orders will be automatically canceled if they are not filled on the bar they are submitted.
            Reference: https://ninjatrader.com/support/help...d_approach.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I am sorry I did not understand. what do you mean i need to enter the stop price.... my stop price is 1 tick above the signal bar. can you show me an example at least on what the code should be?

              and yes if on the next signal bar it is not filled i want it to cancel.

              Comment


                #8
                would this work?




                "EnterLongStopLimit(Convert.ToInt32(ContractSi ze), (High[0] + (1 * TickSize), High[0]) , ""); would this do the job?"

                Comment


                  #9
                  or would this be better



                  EnterLongStopMarket(bool isLiveUntilCancelled, (Convert.ToInt32(ContractSize), (High[0] + (1 * TickSize), "myEntryOrder");

                  then in the code i will have this

                  // If more than 2 bars has elapsed, cancel the entry order if (CurrentBar > barNumberOfOrder + 2) CancelOrder(myEntryOrder);

                  would this be better

                  Comment


                    #10
                    Hello babouin77,

                    Thanks for your reply.

                    Yes, your example in post #8 would work as it matched the overload of: EnterLongStopLimit(int quantity, double limitPrice, double stopPrice, string signalName)

                    Here is an example:

                    EnterLongStopLimit(Convert.ToInt32(ContractSize), (High[0] + (1 * TickSize), High[0] + (1 * TickSize));

                    The example is based on the overload: EnterLongStopLimit(int quantity, double limitPrice, double stopPrice)

                    Here is an example from the help guide:

                    EnterLongStopLimit(High[0] + 2 * TickSize, High[0], "SMA Cross Entry");
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      paul thanks a lot. that worked. I have a question about the cancelling the order....

                      so i have the code:

                      EnterLongStopLimit(0, true, Convert.ToInt32(ContractSize), (High[0] + (1 * TickSize), High[0] + (1 * TickSize), "");
                      barNumberOfOrder = CurrentBar;

                      if (CurrentBar > barNumberOfOrder + 2)
                      CancelOrder(myEntryOrder);

                      but it is not cancelling is there anything in particular i have to do to cancel the order after 2 bars no fill?

                      Comment


                        #12
                        Hello babouin77,

                        Thanks for your reply.

                        Yes, you would need to assign the entry to an order object so that CancelOrder() knows the order to cancel.

                        Please see the example from the help guide: https://ninjatrader.com/support/help...ancelorder.htm
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Paul...

                          I am using this
                          EnterShortStopMarket(0,true, Convert.ToInt32(ContractSize), ShortEntry, "Short");
                          which places a limit order 1 tick below the bar... but sometimes i get these erros that i will attach esp when the market moves fast. what can I do to avoid them?
                          Attached Files

                          Comment


                            #14
                            Hello babouin77,

                            Thanks for your note.

                            This error message means that the strategy attempted to change an order to the wrong side of the market. If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

                            You could consider placing your stop loss order further from the current price.

                            You could also consider changing the strategy to use RealtimeErrorHandlingStopCancelCloseIgnoreErrors for its error handling; you could then capture the rejection in OnOrderUpdate, and then either try to resubmit the stop at a different price or submit an exit order to close the position.

                            You can find more information about real-time error handling for strategies here, along with an example of capturing the rejection:
                            https://ninjatrader.com/support/help...orhandling.htm

                            Let us know if we may assist further.
                            Brandon H.NinjaTrader Customer Service

                            Comment


                              #15
                              so if I have this entry
                              EnterLongStopMarket(0, true, Convert.ToInt32(ContractSize), LongEntry, "Long");

                              and it is giving me an error and disable the strategy how can I re enter for example with a different long entry on errors?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 03:20 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post cre8able  
                              Started by Fran888, 02-16-2024, 10:48 AM
                              3 responses
                              47 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Started by martin70, 03-24-2023, 04:58 AM
                              15 responses
                              114 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by The_Sec, Today, 02:29 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X