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

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 yertle, Today, 08:38 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by love2code2trade, Yesterday, 01:45 PM
    3 responses
    22 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by trilliantrader, Today, 08:16 AM
    2 responses
    6 views
    0 likes
    Last Post trilliantrader  
    Started by samish18, Today, 08:31 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by Creamers, 09-08-2023, 10:26 AM
    6 responses
    157 views
    0 likes
    Last Post JonyGurt  
    Working...
    X