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

OnBarUpdate, OnMarketData, and Rejected Orders

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

    OnBarUpdate, OnMarketData, and Rejected Orders

    After being plagued by "Buy stop or buy stop limit orders can't be placed below the market" rejection orders, I am coming to the realization that I need a robust solution.

    As I understand, this error is occuring because I am attempting to place a stoploss on the wrong side of the market (stop above price if long). Is this correct? These errors seem to be happening later in the trade, as price action is approaching my stop (which I update).

    Questions:

    1. What is the difference between OnBarUpdate with COBC=false, and OnMarketData?

    2. Before placing my stop, I want to compare my desired stop to price action, and if my desired stop is on the wrong side of price, exit via some other means (so as to avoid the rejected order). Might this work? Would this best be done via OnMarketData?

    3. Do you have links to non-trivial examples of OnMarketData?

    Thanks!

    #2
    Serac, you're correct in understanding - this can occur if you try modifying to a stop price that would make the order invalid.

    OnBarUpdate() is called for incoming ticks / barupdates, OnMarketData() is called on each each Level 1 data event - http://www.ninjatrader.com/support/h...aeventargs.htm

    For Last price you can either use COBC false and Close[0] in OnBarUpdate() or the OnMarketData() - you would need to keep in mind though there's no guaranteed call sequence for both methods as those act generally multi-threaded.

    For your stop order issue you would need to check against the current bid / ask prices, this could be done via GetCurrentAsk() / GetCurrentBid() in OnBarUpdate().
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand et al,

      I guess I am going to hijack my own thread. This is the same problem. But, after Bertrand's help, different symptoms.

      After further investigation (and a foray into unmanaged orders and back again), I see that my strategy works, but then falls apart as it does not exit when it should exit.

      Setting TraceOrders = True, the Output window is yielding a "SignalName does not have a matching FromEntrySignal to exit" error. I guess I do not understand this error, because tracing upwards, I can see that that FromEntrySignal is still in an active position.

      In the reply below, I am copying the first instance of this error. The error repeats many, many times (1000+?). The strategy is COBC = false.

      I'm not sure how to go about debugging this. Usually TraceOrders is illustrative. This confused me. A search through past NT support shows scant information.

      Thanks for any help!

      Comment


        #4
        1/4/2012 11:11:58 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Cont Short B' Mode=Price Value=1.29255136293263 Currency=0 Simulated=False

        1/4/2012 11:11:58 PM Amended stop order: Order='ac8fe2f05dba45be8e3e867352945b3e/Replay101' Name='Stop loss' State=Accepted Instrument='$EURUSD' Action=BuyToCover Limit price=0 Stop price=1.29255 Quantity=0.1M Strategy='ShadowSniper17' Type=Stop Tif=Gtc Oco='c0a0425611884cb4afdb2a442a8f525b-567' Filled=0 Fill price=0 Token='ac8fe2f05dba45be8e3e867352945b3e' Gtd='12/1/2099 12:00:00 AM'

        1/4/2012 11:13:38 PM Entered internal PlaceOrder() method at 1/4/2012 11:13:38 PM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=0.1M LimitPrice=0 StopPrice=0 SignalName='MACD Exit' FromEntrySignal='Cont Short B'

        1/4/2012 11:13:38 PM Ignored PlaceOrder() method at 1/4/2012 11:13:38 PM: Action=BuyToCover OrderType=Market Quantity=0.1M LimitPrice=0 StopPrice=0 SignalName='MACD Exit' FromEntrySignal='Cont Short B' Reason='SignalName does not have a matching FromEntrySignal to exit'

        1/4/2012 11:13:38 PM Entered internal PlaceOrder() method at 1/4/2012 11:13:38 PM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=0.1M LimitPrice=0 StopPrice=0 SignalName='MACD Exit' FromEntrySignal='Cont Short B'

        1/4/2012 11:13:38 PM Ignored PlaceOrder() method at 1/4/2012 11:13:38 PM: Action=BuyToCover OrderType=Market Quantity=0.1M LimitPrice=0 StopPrice=0 SignalName='MACD Exit' FromEntrySignal='Cont Short B' Reason='SignalName does not have a matching FromEntrySignal to exit'

        The Enter-internalPlaceOrder -> Ignore PlaceOrder() cycle repeats many times after this...

        Comment


          #5
          Hi Serac, could you please send me the full TraceOrders output from the strategy along with a description of the methods you use in it to my attn to support at ninjatrader dot com?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Bertrand,

            E-mail sent. Let me know if you do not get it.

            Comment


              #7
              Thanks, I just got it and will look into matters.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by naanku, Today, 07:25 PM
              0 responses
              3 views
              0 likes
              Last Post naanku
              by naanku
               
              Started by milfocs, Today, 07:23 PM
              0 responses
              1 view
              0 likes
              Last Post milfocs
              by milfocs
               
              Started by PaulMohn, Today, 06:59 PM
              0 responses
              6 views
              0 likes
              Last Post PaulMohn  
              Started by bortz, 11-06-2023, 08:04 AM
              48 responses
              1,750 views
              0 likes
              Last Post carnitron  
              Started by Jonker, 04-27-2024, 01:19 PM
              3 responses
              23 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X