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:	317
Size:	57.2 KB
ID:	1105139

      Click image for larger version

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

Name:	NT Atr Stop.JPG
Views:	259
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 NullPointStrategies, Today, 05:17 AM
        0 responses
        19 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X