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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X