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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Brevo, Today, 01:45 AM
    0 responses
    2 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    238 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    4 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X