• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy on bar close

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

    strategy on bar close

    hello...
    I test my strategy on EOD data and would like to enter position on Close[0]. But the strategy open the position on Open next bar. And this is problem, because the different between Close[0] and Open next bar is big. How can I how can I solve the problem?
    See the picture.

    Thank you
    Lico
    Last edited by licovata; 02-12-2019, 09:45 AM.

    #2
    Hello licovata,

    Thanks for your post.

    Strategies will have the by default use a Calculate mode of OnBarClose. The open of the next bar signals a bar closure so the event happens on the open of the next bar. This is because NinjaScripts are event based (based on incoming tick data) rather then being strictly based on time.

    If you would like to have the strategy take action before the close of a bar, you can have the strategy Calculate OnPriceChange or OnEachTick. This will have the strategy constantly update for the developing bar with each incoming tick or price change.

    More information on Calculate modes can be referenced here - https://ninjatrader.com/support/help.../calculate.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      I have a similar inquiry. Mostly for exits i have issue when i view in after hours on historical data and a tick based bar ie renko. You close a bar, your condition are meet to update a exit order based on for example the close of a 50 brick size bar. To close another bar up is 50 ticks, to close another bar down is 100 ticks. You have your stop order 40 ticks below the Close(0) that meet all your conditions. However........... the order fills at the close of the next bar which is 60 ticks lower,

      the strategy is build On Bar Close and if you run the strategy "on each tick" or "on price change" when applying to the chart NOTHING different happens. IS THE because of the nature of the input series or does the calculate NOT override what is built into the Strategy

      Comment


        #4
        Additional information is for the Entry orders that are created on bar close YOU can create a buy stop that will not fill until the next bar close if the direction of the bar does not change, but if the direction is change for the entry you do NOT have to wait until the next bar close 100 ticks above the last bar close THE STRATEGY will send the order half way between the 2 bars. EXAMPLE if you place your Buy Stop order on a reversal type bar at 40 ticks above the last Close Bar "Close[0] the fill will be 50 ticks above the Close[0] and will not wait for the bar close 100 ticks above the last bar close.

        THIS is what I expected to see on Exit orders but is not the case

        Comment


          #5
          Hello DTSSTS,

          Order fill simulations and default strategy behavior for backtests vary between historical data and with realtime data. We also should not confuse the filling of orders with the way the strategy processes OnBarUpdate as these are different concepts in NinjaTrader.

          When backtesting, we are using historical data and the strategy will default to using Calculate.OnBarClose for efficiency. (Calculating each tick or price change on historical data can be expensive) This can be overridden using Tick Replay, and having the strategy set its own Calculate mode. This would be for processing historical data in OnBarUpdate with a specific Calculate mode and will not create more accurate order fill simulations.

          Order fill simulations will either use bid/ask/volume data when testing realtime, but only the OHLC values for the data series the strategy is applied against will be used to simulate order fills from historical data. Backtests can use High Order Fill Resolution to simulate order fills with single tick granularity. Tick Replay is not compatible with High Order Fill Resolution, so scripts that use Tick Replay will need to have the single tick data series added to it and have orders submitted to the single tick data series. Please see SampleIntrabarBacktest for an example.
          Publicly available resources on the items discussed can be found below.

          Discrepancies Between Realtime and Backtest - https://ninjatrader.com/support/help...ime_vs_bac.htm

          Historical Fill Algorithm and High Order Fill Resolution - https://ninjatrader.com/support/help...ical_fill_.htm

          SampleIntrabarBacktest - https://ninjatrader.com/support/help...ipt_strate.htm

          Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

          Please let us know if you have any additional questions.
          JimNinjaTrader Customer Service

          Comment


            #6
            so are you saying in a realtime live trading situation that the fill should be the stopmarket order price plus any slippage of course

            Comment


              #7
              Hello DTSSTS,

              Yes, for a real time order fill simulation on a Sim or Playback account, the current bid/ask and volume will determine the order fill instead of the using OHLC values, so the fill price of the market order (filled by bid/ask) + slippage would be seen for the order fill.

              Let us know if you have any additional questions.
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Bobisam, Yesterday, 04:57 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by voltlon, Yesterday, 05:18 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by Johnny Santiago, Today, 04:50 AM
              2 responses
              9 views
              0 likes
              Last Post Johnny Santiago  
              Started by rickyblah12, Yesterday, 08:17 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by jamarc, Today, 02:30 AM
              0 responses
              4 views
              0 likes
              Last Post jamarc
              by jamarc
               
              Working...
              X