Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

On Bar Close

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

    On Bar Close

    I am testing a strategy where the primary time frame is a range bar (50 ticks).

    The exit is up or down an Average True Range.

    The problem is the target or stop is hit but the position isn't closed until the primary bar completes, which can be quite far off.

    I tried to add a secondary 1 minute time series and also tried setting on bar close to on each tick... I am getting the same results.

    Is there any way around this?

    thank you


    #2
    Hello sdauteuil,

    Thanks for your post.

    How are you testing this, in the strategy analyzer, Live data, or playback with Market replay data?

    What exit methods are you using?

    What is the Calculate setting of the strategy?

    Comment


      #3
      Testing with the strategy Analyzer

      I am setting a variable equal to a 14 period average true range when the strategy is flat.

      I have exits set to sell at the average position price Plus or Minus the ATR. This logic works fine.
      The problem is it doesn't close when the exit price is hit it waits till the bar closes after hitting the exit price.


      Click image for larger version

Name:	NT Set Atr.JPG
Views:	321
Size:	57.2 KB
ID:	1105139

      Click image for larger version

Name:	NT Atr Targ.JPG
Views:	286
Size:	57.7 KB
ID:	1105140Click image for larger version

Name:	NT Atr Stop.JPG
Views:	267
Size:	57.3 KB
ID:	1105141

      Comment


        #4
        Hello sdauteuil,

        Thanks for your reply.

        In the strategy analyzer, the strategy will only run as if Calculate.OnBarClose was set regardless of how you have the Calculate set. This is because the strategy analyzer only uses historical data that does not include all of the ticks of the bar and only the OHLC values of the bar to work with. the code then would only execute at the end of the bar and order submitted would be filled on the next bar.

        You could try using Calculate.OnEachTick or Calculate.OnPriceChange with tick replay enabled in the strategy analyzer, however, you would need to ensure that you have historical tick data available for the duration of the analysis period. This will be significantly slower due to the tick data processing so I would suggest just check a few recent days for the test period to see if that helps.

        An alternative would be to unlock the strategy code and set the orders to the 1 minute series instead of the range bars.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        163 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        82 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        125 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        206 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        185 views
        0 likes
        Last Post CarlTrading  
        Working...
        X