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

Setting Order to Null

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

    #16
    Thank you, Chelsea.

    I have just moved it to OnBarUpdate and it is now giving me the error that was mentioned by Patrick in Post #13.

    This doesn't make sense because the bar the stop price is 102.05 and the High of the bar that it is basing that stop price off of is 102.04. Therefore it is higher than the high of the bar and it is actually placed where it is supposed to be.

    Could you please let me know what I should be doing to fix this error? I had no problems with the entries or exits prior to moving this to OnBarUpdate.

    Comment


      #17
      Hi jg123,

      Is the code that you moved the code that does cancellations?

      Are you cancelling an order on the same bar that it is entered?

      The error message does not make sense for the code that was moved.
      The code moved should cancel an order not submit a buy order.

      Do you know what code is submitting this buy order?
      (I would recommend you add prints until you find what line is submitting this order)
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hi Chelsea

        The code that I moved to OnBarUpdate() was the code that cancels the orders. Here is the cancel order code:

        Code:
        				if (LongEntry != null
        					&& ToTime(Time[0]) >= RemoveOrderHr
        					&& LongEntry.OrderState != OrderState.Filled)
        				{
        					CancelOrder(LongEntry);
        					Print("" + Time[0] + " Cancel Order");
        					LongEntry = null;
        				}
        I have been using print statements to determine if the entry points are correct, and they definitely are. I have tried it again after you suggested it just to make sure..and they are.

        Attached are two screenshots. One screenshot is the entry code. I am using an Enum and the screenshot shows the portion of the Enum that is active according to my parameters (TrendDirection.Up) and that can also be seen in the Strategy title at the top of the chart. The first parameters says "Up").

        The other screenshot is of the Output window. It shows the print and the entry price. The chart that is also as an attachment shows the candle that it is basing the price off of (1 pip above the high of the range) and shows that the entry price is clearly above the high of the candle.

        This is a really confusing error to me
        Attached Files

        Comment


          #19
          Hi jg123,

          From what is in the output window, it looks like an order was successfully cancelled. Do you have any other code outside of OnBarUpdate that cancels orders?

          I looks like the cancellations may cause unexpected changes in the logic but it looks like the cancellations worked.

          Cancelled custom managed order at 26-May-14 10:00:00 AM: Order='NT-00000/Sim101' Name='BreakoutLong'...

          I think you need to track down exactly what line of code is generating this order.
          (I'm thinking that an order used as a stop loss is being set after the entry order is cancelled maybe..)
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            If that is cancelling it at 10:00 AM then there is another issue. It is cancelling it on the same bar, but that is not what I am expecting. I don't see how that could be happening in the code.

            One of the conditions of the cancel order code is

            [code]
            if (ToTime(Time[0]) >= RemoveOrderHr)
            [code]

            There are two screenshots attached that show the RemoveOrderHr. One of them is the code and the other is my parameters. Neither of them show 10:00 AM.

            I did a print statement in my cancel order code and that print is not showing up so that code is not even being called, therefore it seems that something else is cancelling the order.

            I have combed through my code and have commented out any code for any part of the strategy that cancels any order (whetehr it is related to this part of the strategy or not)
            I can not figure out what on earth is cancelling this order at 10:00 am
            Attached Files

            Comment


              #21
              Hi jg123,

              May we have the script to test?
              I may be able to find the source of the cancellation and buy order.

              If you would like to keep the script private, send the script to platformsupport [at] ninjatrader [dot] com and include a link to this thread.

              Otherwise just post the exported code to your next post.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              4 responses
              31 views
              0 likes
              Last Post algospoke  
              Started by RideMe, 04-07-2024, 04:54 PM
              4 responses
              20 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Started by cre8able, 04-17-2024, 04:16 PM
              6 responses
              53 views
              0 likes
              Last Post cre8able  
              Started by samish18, 04-17-2024, 08:57 AM
              14 responses
              48 views
              0 likes
              Last Post samish18  
              Started by franatas, 12-04-2023, 03:43 AM
              6 responses
              101 views
              0 likes
              Last Post AuroraForbes  
              Working...
              X