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

A Sell stop order has been ignored error ??

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

    A Sell stop order has been ignored error ??


    Hello Ninjatrader,

    My strategy uses the SubmitOrderUnmanaged() (and runs at OnEachTick) to open a stop limit sell order on a 5 min chart (tick replay enabled)

    When this order gets filled the strategy submits a new (unmanaged) stoploss order.. (buytocover stoplimit)
    However in some cases this stoploss order gets ignored as you can see in the logs below :
    I have logged the current ask & bid prices and enabled order tracing. The ask & bid are at 3320.5 at the moment i create my stop limit order for price 3322.25

    The ninjatrader log window shows this SL order gets ignored since the stop price is greater or equal then the close price of the current bar.
    Why is this ? The current bar is still open and still developing at the moment i place my order (My strategy uses OnEachTick).
    I dont see why this preliminary close price of the current bar should be of any relevance to the order(s) i'm submitting ?
    I mean it should not matter whether i submit the order from a 10-tick or 1 day chart ?
    All that should matter is the current bid/ask prices imo ?

    How can i fix this ?
    regards

    Erwin


    Ninjatrader log:
    Code:
    Strategy 'TestStrategy/183135895': A Sell stop order placed at '1/2/2020 9:40:00 AM' has been ignored
    [B]since the stop price is greater than or equal to the close price of the current bar[/B].
    This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
    Output window log containing the order trace (and my own) log:
    Code:
    1/17/2020 9:40:00 AM open short open limit order price:3320.5
    1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135895': Entered internal SubmitOrderUnmanaged() method at 1/17/2020 9:40:00 AM: BarsInProgress=0 Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=3320.50 StopPrice=3320.50 SignalName='short1'
    1/17/2020 9:40:00 AM onorder update called ->order short1 got filled
    1/17/2020 9:40:00 AM create new stoploss order for price  3322.25 [B]current ask:3320.5 current bid:3320.5[/B]
    1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135895': Entered internal SubmitOrderUnmanaged()
    method at 1/17/2020 9:40:00 AM: BarsInProgress=0 Action=BuyToCover OrderType=StopLimit Quantity=1
    LimitPrice=0 [B]StopPrice=3322.25[/B] SignalName='shortsl1'
    
    1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135895': Ignored SubmitOrderUnmanaged() method
    at 1/17/2020 9:40:00 AM: BarsInProgress=0 Action=BuyToCover OrderType=StopLimit Quantity=1 LimitPrice=0
    StopPrice=3322.25 SignalName='shortsl1'
    FromEntrySignal=''[B] Reason='Invalid order price, please see log tab'[/B]


    Click image for larger version  Name:	Capture.JPG Views:	0 Size:	147.1 KB ID:	1084458Click image for larger version  Name:	Capture3.JPG Views:	0 Size:	125.8 KB ID:	1084460Click image for larger version  Name:	Capture2.JPG Views:	0 Size:	87.1 KB ID:	1084459
    Last edited by EB Worx; 01-20-2020, 03:55 PM.
    EB Worx
    NinjaTrader Ecosystem Vendor - EB Worx

    #2
    Hello Erwin Beckers ,

    Was this a realtime order or a historical order?

    Based on the message knowing the ask/bid won't be helpful to understand the problem, we would instead need to know what the Close price was at that time. If the order price was on the wrong side of the close price the warning would be correct and you would need to use a different price for that order.

    How are you collecting the ask/bid prices in your script? That also could relate to the problem depending on how the prices were gathered and when the order was being submitted.


    I look forward to being of further assistance.



    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      >Was this a realtime order or a historical order?
      Historical.. I simply add the strategy to a 5min chart (with tick replay enabled) and when i enabled the strategy and then i can see that it 'replays' the historical data and places historical orders in the past up all the way up to the current time. So yes a historical order
      As shown one of the orders at 1/17/2020 fails

      >we would instead need to know what the Close price was at that time.
      I modified the code a little bit to show the Close[0], Low[0] and High[0] at the moment i place the order (see log below)
      But like i said , my strategy works OnEachTick and the close of the current bar is irrelevant and should not have any impact on the orders placed imo

      Code:
      1/17/2020 9:40:00 AM open short quantity:1 limit:3320.5 stoploss:3322.25 takeprofit:3318.5
      1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135900': Entered internal SubmitOrderUnmanaged() method at 1/17/2020 9:40:00 AM:
      BarsInProgress=0 Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=3320.50 StopPrice=3320.50 SignalName='short1'
      
      1/17/2020 9:40:00 AM  [B]order short1 filled with avg fill price:3320.5[/B]
      1/17/2020 9:40:00 AM [B]create SL order for price 3322.25  /ask:3320.5 bid:3320.5 close[0]:3320.5 low[0]:3320.5 high[0]:3323.5[/B]
      1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135900': Entered internal SubmitOrderUnmanaged() method at 1/17/2020 9:40:00 AM:
      BarsInProgress=0 Action=BuyToCover OrderType=StopLimit Quantity=1 LimitPrice=0 StopPrice=3322.25 SignalName='shortsl1'
      1/17/2020 9:40:00 AM Strategy 'TestStrategy/183135900': Ignored SubmitOrderUnmanaged() method at 1/17/2020 9:40:00 AM:
      BarsInProgress=0 Action=BuyToCover OrderType=StopLimit Quantity=1 LimitPrice=0 StopPrice=3322.25
      SignalName='shortsl1' FromEntrySignal='' Reason='[B]Invalid order price, please see log tab[/B]'

      Ninjatrader log:
      Code:
      2020-01-21 16:43:07:348|3|4|Strategy 'TestStrategy/183135900': [B]A BuyToCover stop order placed at '1/17/2020 9:40:00 AM' has
      been ignored since the stop price is less than or equal to the close price of the current bar.
      This is an invalid order and subsequent orders may also be ignored[/B]. Please fix your strategy.
      >How are you collecting the ask/bid prices in your script?
      I just added them for logging purposes only since i thought you might need them. They are not used at all by the strategy itself.
      The ask/bid prices i get with the GetCurrentAsk() and GetCurrentBid().


      > If the order price was on the wrong side of the close price the warning would be correct
      As you can see the Close[0] is 3320.5 and the order is a buy to cover stop limit at 3322.25.

      Hope this helps

      Erwin
      Last edited by EB Worx; 01-21-2020, 03:56 PM.
      EB Worx
      NinjaTrader Ecosystem Vendor - EB Worx

      Comment


        #4
        Any ideas?
        EB Worx
        NinjaTrader Ecosystem Vendor - EB Worx

        Comment


          #5
          Hello Erwin Beckers,

          Thank you for the reply.

          To further explore why you are seeing the warning I would likely need to see the specific logic used in that use case. I was not able to see this warning when testing a similar scenario where I am submitting the same type of unmanaged historical orders with tick replay.

          If this is an warning you get in the same location each time you test I would suggest to try and make a simple example script which executes just that order at that time to demonstrate the warning. With that type of a sample I can explore that further from my end to see if this would be expected in that use case. If this is happening randomly through the data I would suggest a similar approach but to just simplify what you are doing as much as possible to see what is needed to get the warning. With the values known for the order in question a sample could be made with those values to see if we still see the problem so we can diagnose it.

          You may also want to try clearing the historical data cache and then re download the data to see if that helps.
          To delete the cache, follow the steps below.
          1. Shut down NinjaTrader.
          2. Open the Documents > NinjaTrader 8 > db folder.
          3. Delete the sub-folder named 'cache'.
          4. Restart NinjaTrader and test.


          I look forward to being of further assistance.

          JesseNinjaTrader Customer Service

          Comment


            #6
            Thx Jesse

            I'll make a small test strategy for you and post it here since this happens everytime at the same place so you can test it yourself

            Erwin
            EB Worx
            NinjaTrader Ecosystem Vendor - EB Worx

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Christopher_R, Today, 12:29 AM
            0 responses
            7 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,235 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            3 views
            0 likes
            Last Post thread
            by thread
             
            Started by jclose, Yesterday, 09:37 PM
            0 responses
            7 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,415 views
            0 likes
            Last Post Traderontheroad  
            Working...
            X