Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market price not matching close[0]

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

    Market price not matching close[0]

    My strategy moves ExitShortStopMarket (or Long depending on the trade) to new price once a PnL is achieved. Running on Playback, I occasionally receive the error: "Plauback101: Buy stop or buy stop limit orders can't be placed below the market." I expect the error is related to a gap in market price. I put a check in the code to return from OnBarUpdate (Calculate.OnPriceChange) if the price jumps by more than one tick. I still receive the error even though the chart shows that Close[0] is at right price compared to the buy or sell stop limit. I attached a screen capture from the chart window to explain more. Is there a way around this problem?
    Attached Files
    Last edited by hgheith; 05-14-2017, 02:08 PM. Reason: Upload attachement

    #2
    Hello hgheith,

    I would recommend adding a check that the price you are about to change the order to is below the ask (for a buy order).

    if (myNewPrice < GetCurrentAsk())
    {
    myStop = ExitShortStopMarket(myNewPrice);
    }
    else
    {
    myStop = ExitShortStopMarket(GetCurrentAsk());
    }

    In a fast moving market, it is possible for the price to change before the order can be submitted. Placing further below the ask would help for the change order to be accepted.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X