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 rocketman7, Today, 01:00 AM
    0 responses
    1 view
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 04-23-2024, 09:53 PM
    2 responses
    74 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    193 views
    0 likes
    Last Post Hasadafa  
    Working...
    X