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

Bid Ask and Last prices

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

    Bid Ask and Last prices

    I am trying to code a strategy that goes long or short at the open of a bar depending on whether the open price of the bar is above or below an SMA line.

    The problem I have is when the SMA line is close to the open price of the bar.

    In one example the Bid price was 1259.4, the Ask price was 1259.7, the Last Price was 1259.7 and the SMA line at the open was at 1259.5.

    When looking a at the bar chart, the bar open was at 1259.7. Does the bar Open price refer to the Last Price or the Ask price?

    Also, my code looks at the open price and compares it the SMA line. It seems like the open price is referring to the Bid price because the strategy as I have it now went short at the open of the bar at the 1259.4 price.

    It is confusing since the bar open is printed above the SMA line at 1259.7 yet the strategy went short as if the bar opened below the SMA line.

    How can I code it so that the strategy refers to the correct open price of the bar as it is printed on the screen when deciding to go long or short? Should I be comparing the Last price at the open instead of the Bid price?

    #2
    Hello,

    Looking at the last price may do the trick here. I recommend testing that to see if the fills are more accurate. Also, if you reference Close[0] on the current bar, that will refer to the last price. The candles should be painting based on the Bid price, unless you have something different set in the Data Series window.

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by futtrader, 04-21-2024, 01:50 AM
    5 responses
    56 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Started by PeakTry, Today, 10:49 AM
    0 responses
    2 views
    0 likes
    Last Post PeakTry
    by PeakTry
     
    Started by llanqui, Today, 10:32 AM
    0 responses
    5 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by StockTrader88, 03-06-2021, 08:58 AM
    45 responses
    3,992 views
    3 likes
    Last Post johntraderuser2  
    Started by TAJTrades, Today, 09:46 AM
    0 responses
    8 views
    0 likes
    Last Post TAJTrades  
    Working...
    X