Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit on close appears before opening the trade

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

    Exit on close appears before opening the trade

    Hi,

    I'm running a strategy on backtest.
    When changing the "exit on close" to true, then I see on the graph that the close of the trade appears before the open.
    In addition, the close price doesn't make sense.
    Btw, it happens for both long and short positions.

    See attached screenshots.

    10x,
    Attached Files

    #2
    Hello shayhz,

    The Exit on close when true, will cause an exit at the end of the session. It would be expected this would be before the open.

    What bar type are you running this on?

    Do you have multiple series in your script?

    Are the wicks of the candles appearing on the chart or have these been set to transparent?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I'm running on a daily time frame, so end of the session supposed to be end of the daily bar at the next bar, no ?
      When I'm placing "enterLong" order on bar close, then the position price is at the open of the next day.
      In that case, I expect that the end of the session is the close of the next day candle.

      I'm trying to simulate buying at the open and selling at the close, without working on lower time frames than daily.

      Btw, the wicks are not transparent....

      10x,

      Comment


        #4
        Hello shayhz,

        I would not expect the Exit on close to work when using a daily bar.
        It would be required to have a multi-time frame script with intra-day granularity to allow the Exit on close to trigger before the close of the session.

        Support for the development of custom automated trading strategies using NinjaScript.


        Do you have a second data series added to your script?

        Is this Exit on close occurring once at the end of the chart before real-time data is loaded?

        Do you see the Exit on close occurring more than once on the chart?

        When NinjaTrader is running with Calculate on bar close (COBC) as true, orders are placed after the bar closes using logic calculated from that bar.

        Below is a link to the help guide on Calculate on bar close.


        This means that any orders that are triggered from that bar are submitted after the bar closes as the new bar opens. As the order is placed as the new bar opens and the timestamp of the order is within the time of the next bar, the order will show on the next bar.

        If the strategy were running with COBC as false, or if the script has intra-bar granularity and submitted orders on a smaller timeframe, this would cause the timestamp of the order to be within the bar it is triggered on as the order may be submitted intra-bar. This order would show on the same bar as the bar that triggered the order submission.

        This is outlined in the help guide Discrepancies: Real-Time vs Backtest.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by AveryFlynn, Today, 04:57 AM
        0 responses
        4 views
        0 likes
        Last Post AveryFlynn  
        Started by RubenCazorla, 08-30-2022, 06:36 AM
        3 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Started by f.saeidi, Yesterday, 12:14 PM
        9 responses
        25 views
        0 likes
        Last Post f.saeidi  
        Started by Tim-c, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by FrancisMorro, Today, 03:24 AM
        0 responses
        5 views
        0 likes
        Last Post FrancisMorro  
        Working...
        X