Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Paul H.NinjaTrader Customer Service

    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
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        6 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        216 views
        1 like
        Last Post PaulMohn  
        Working...
        X