Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ask and bid prices in testing strategies

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

    Ask and bid prices in testing strategies

    Hi, I have a problem with ask and bid prices in the builder. How can I set that every buy (regardless of whether we open or close a position) will be made at ask; and every sale will be made at bid.

    For example, the current market price is 5. I want to buy at a price of 1 and sell it at a price of 10. That is, the ASK price must at least touch 1 and the BID price must at least touch 10, otherwise the execution will not be done as planned. In the builder, I can only choose between ask or bid or last, but in that case the backtest generates unrealistic results ... So is there any way to set "for every buy use the ask price" and "use bid price for every sale"?

    Thank you

    I'll be very grateful for the advice

    #2
    Hello Bonifac,

    Thanks for your question.

    The Strategy Builder can use GetCurrentBid and GetCurrentAsk to get the current bid/ask price which you can use for order submissions. These return the Close price with historical data since bid/ask would not be available then.

    GetCurrentBid - https://ninjatrader.com/support/help...currentbid.htm

    Backtesting uses the OHLC data points of a bar to simulate order fills, it does not use bid/ask/volume to simulate order fills like we can using the Sim101 account against realtime data or the Playback account when connected to Playback with Market Replay data.

    Discrepancies between realtime and backtest - https://ninjatrader.com/support/help...ime_vs_bac.htm

    If you would like to have these orders filled at these levels for backtesting then you can submit these orders to a single tick bid or ask series. This requires unlocking the code and taking an approach like the example below.

    Backtesting with intrabar granularity - https://ninjatrader.com/support/help...ipt_strate.htm

    Using Historical Bid/Ask Series - https://ninjatrader.com/support/help..._ask_serie.htm

    Please let me know if I can be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    69 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    42 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X