Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to understand strategy calculation logic

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

    Trying to understand strategy calculation logic

    In the following daily bar image, is bar0 Nov8 and bar1 nov7 regardless of whether CalculateOnBarClose is true or false?

    Click image for larger version

Name:	NOV8.jpg
Views:	1
Size:	113.8 KB
ID:	906473

    #2
    Hi Joe,

    The CalculateOnBarClose setting of true means the bars ago reference of [0] would be the 7th, while a setting of false means [0] would be the 8th. Please see attached for a quick reference:
    Attached Files

    Comment


      #3
      Trying to understand strategy calculation logic

      The strategy on the following T-bond futures chart has a tight profit goal=10 ticks and stop loss=10 ticks so that both goals are often hit on a day bar.

      CalculateOnBarClose = true ... so apparently, because Ninja doesn't know whether the profit goal or stop loss was touched first, it conservatively assumes the stop is hit first. Just to be sure, IS THAT TRUE? ... If true, is there anyway to modify that logic?
      Click image for larger version

Name:	NOV8---2.jpg
Views:	1
Size:	639.8 KB
ID:	881069

      Comment


        #4
        Hello joemiller,

        Thanks for your post.

        When applying your strategy to a chart, historical trades are made on the bars and are performed as if CalculateOnBarClose is true, regardless of its setting in your strategy. This is because historical bars only consist of the Open, High, Low and Close values. So historically, outside of the 4 values, how the bar was built is unknown and the strategy will only execute once per bar.

        In applying the strategy to historical bars, yes a conservative approach is built in where if the stoploss can be hit, it is hit. If the stop loss cannot be hit then the profit target will be hit in the example of small stop/profit and large bars.

        If you want to test your strategy historically, with daily bars and small targets/stops you can use market replay where all of the ticks that make up each bar are available.

        Alternatively, you can add a faster dataseries to your strategy, and not use the Set methods (setStopLoss or SetProfitTarget) but instead use ExitLongStopMarket() and ExitLongLimit() and applying them to the faster dataseries with the overload of the two methods, please see these references:
        http://ninjatrader.com/support/helpG...itlongstop.htm
        http://ninjatrader.com/support/helpG...gstoplimit.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        65 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X