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

Limit order being treated as Market order

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

    Limit order being treated as Market order

    I am using Strategy builder to build code to enter an order a tick above the high of a candle that exhibits certain criteria. (in this case the Gold Candle) When I run back testing, if the next candle has a lower open than my entry price, the order is placed there as if it was a market order placed. I have printed out the entry variable and it is correct, but the order fills at the other price.

    if ((Close[1] < Open[1])
    && (Close[0] > Open[0])
    && (Low[0] < Low[1])
    && (High[0] < High[1])
    && (Close[0] > Close[1])
    && (Close[0] > EMA1[0])
    && (BarCounter1[0] > 60)
    && (BarCounter1[0] < 80))
    {
    EntryLong = (High[0] + (1 * TickSize)) ;
    BarBrush = Brushes.Gold;
    StopLong = (High[0] - 35) ;
    Print(Convert.ToString(EntryLong));
    }

    // Set 2
    if (EntryLong > 0)
    {
    EnterLongLimit(Convert.ToInt32(Contracts), EntryLong, @"Long");
    Print(Convert.ToString(EntryLong));

    Click image for larger version

Name:	chart.jpg
Views:	32
Size:	52.0 KB
ID:	1282322​​



    Starts
    12-14-2023
    Ends
    12-14-2023

    #2
    Hello BrJessey,

    Thank you for your post.

    Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics. Instead these are filled based on logical rules from processing historical data.
    • When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data.
      • This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known
      • Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

    Intra-bar granularity adds a second data series such as a 1 tick series using AddDataSeries() so that the strategy or indicator has the individual ticks in the historical data in between the High and Low of the primary series.
    In NinjaTrader 8, there have been two new enhancements so that programmers may not have to manually add this secondary series and code the script for high accuracy fills (Order Fill Resolution) or for intra-bar actions (TickReplay) depending on the needs of the script.


    Note: bar types that are IsRemoveLastBarSupported cannot be used with TickReplay and generally cause inaccurate results when backtesting in historical data.

    Note: High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.


    Please see this forum post for a detailed explanation:
    https://forum.ninjatrader.com/forum/...-backtest-live

    If you have any other questions, please let me know.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X