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

EnterLongStop() use

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

    EnterLongStop() use

    I set CalculateOnBarClose to "true", so OnBarUpdate() is called only on bar close.
    I want to use EnterLongStop() , but my understanding is that order will be alive only until bar close - looks like order will not be executed in this case? So, question:
    Is it possible to use EnterLongStop() when CalculateOnBarClose is set to "true" or do I have to use Advanced Order Handling in this case?

    #2
    Hello MarkZ,

    For your order to remain live the condition would have to still be true or you may use the Advanced Order Handling "liveUntilCancelled" method.

    You may view the following thread for an example on how to keep order alive using the Advanced Order Handling method.
    JCNinjaTrader Customer Service

    Comment


      #3
      Your info link is useful, thanks.
      However, your answer is not useful. I've asked a very simple and clear question (Is it possible to use EnterLongStop() when CalculateOnBarClose is set to "true" w/o Advanced Order Handling). The answer is YES or NO.
      Your answer is evasive and unclear. Is it "NO"?

      Comment


        #4
        Hello MarkZ,

        If your condition to EnterLongStop() is still true on the next bar update then your order will remain. In this scenario you would not need to use the Advanced Order Handling Method, so the answer is Yes in this case.

        If your condition to EnterLongStop() is not true on the next bar update then your order will be canceled. In this scenario you would need to use the Advanced Order Handling Method, so the answer is No in this case.

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Q1. By "your condition to EnterLongStop()", I assume, you mean stopPrice being reached, correct?
          Q2. Are you saying that order originated from EnterLongStop() at the time of bar close will last until the close of the next bar ?

          Comment


            #6
            To correct my post #3 - your link is NOT useful either. It's full of dead links (non-existent URLs) and comments are as confusing as can be. Judge for yourself:
            "
            protected override void OnBarUpdate()
            {
            /* This code sample demonstrates the difference between orders that have liveUntilCancelled = true and false.
            The default setting for limit orders is for the orders to be cancelled if the conditions that caused the order are no longer true (liveUntilCancelled = false).
            Lets say in OnBarUpdate() the entry condition is if (Close[0] >= Close[1]). If the condition evaluates to true, or the current close is greater than the previous close,
            the order will be placed. Then on the next bar, the close is lower then the previous close so the conditions are no longer true. Thus, the limit order would be cancelled.
            For more information on this auto-expire behavior, please see the “Order Submission for Entry and Exit Methods– Basic Operation” section from this link:

            In another example, we have the same entry conditions. This time, there are 5 bars that all close higher than the previous close.
            The order would not be cancelled for any of those five bars because the condition remains true. Until a bar closes lower, the order will not be cancelled.

            There is an overload for stop and limit order methods that includes a bool flag named "liveUntilCancelled". This flag is what will decide how the order needs to be cancelled.
            The overload is this: EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName);
            For more information, please visit http://www.ninjatrader-support.com/H...EnterLongLimit. */

            // Get a price for entries.
            entryPrice = Low[0] - 2 * TickSize;

            /* CrossAbove/Below conditions usually do not evaluate to true for several bars in a row.
            If we submitted with liveUntilCancelled = false our order would be cancelled on the next bar as the condition is no longer true.
            If we wanted to persist our order we would want to use liveUntilCancelled = true. */
            if (CrossAbove(SMA(Fast), SMA(Slow), 1))
            {
            /* This order is kept alive until explicitly cancelled. For information on how to explicitly cancel this order please see this reference sample:
            http://www.ninjatrader-support2.com/...ad.php?t=18890 */
            EnterLongLimit(0, true, DefaultQuantity, entryPrice, "live until cancelled long");
            }

            if (Close[0] > Open[0])
            {
            // This EnterLongLimit is cancelled if the conditions that caused it are no longer true. It is then resubmitted upon the conditions being true again.
            EnterLongLimit(0, false, DefaultQuantity, entryPrice, "long order to be resubmitted");
            }

            if (CrossBelow(SMA(Fast), SMA(Slow), 1))
            ExitLong();
            }
            "

            Comment


              #7
              1.5 hours later still waiting for answers to 2 simple questions in my post #5

              Comment


                #8
                Hello MarkZ,

                The answer to both questions is yes.

                As for the links they are working on my end, have you tried right clicking the links and coping the address to open them in a different tab or browser?

                For example this one is to our Help Guide on Advanced Order Handling.


                Happy to be of further assistance.
                JCNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cutzpr, Today, 08:54 AM
                0 responses
                6 views
                0 likes
                Last Post cutzpr
                by cutzpr
                 
                Started by benmarkal, Today, 08:44 AM
                0 responses
                11 views
                0 likes
                Last Post benmarkal  
                Started by Tin34, Today, 03:30 AM
                2 responses
                26 views
                0 likes
                Last Post Tin34
                by Tin34
                 
                Started by sastrades, Yesterday, 09:59 AM
                2 responses
                41 views
                0 likes
                Last Post brucerobinson  
                Started by ETFVoyageur, Today, 12:52 AM
                1 response
                24 views
                0 likes
                Last Post Leeroy_Jenkins  
                Working...
                X