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


analyzer restrictions

  • Filter
  • Time
  • Show
Clear All
new posts

    analyzer restrictions

    Can analyzer be set up to deny anyone from running on each tick and on price change data since it wont work right any way?
    Shouldnt it only allow strategies with On Bar close? thanks

    Strategy Analyzer already does that -- it always ignores your
    Calculate setting and always uses OnBarClose internally.

    Because of the limitations of historical data, the Strategy Analyzer
    can only call your OnBarUpdate at the close of each bar, thus
    OnEachTick and OnPriceChange are ignored by the Strategy

    In contrast, when your strategy is running with a real-time data
    feed, oh Lord yes, the Calculate setting there is very important.

    Strategy Analyzer testing != Real-time execution
    Last edited by bltdavid; 12-06-2021, 11:13 PM.


      Strategy Analyzer testing. Funny. How does it approach the issue?
      Just curious on how it works


        Hello ezrollin and JennyMalin,

        Thank you for your posts.

        bltdavid is correct here.

        You should expect that a strategy running real-time (live brokerage account, live market simulation, Market Replay etc...) will produce different results than the performance results generated during a backtest over historical data on a chart or in the Strategy Analyzer. This difference may be more easily seen on certain Bars types (e.g. Point and Figure, renko) than others due to their inherent nature in bar formation.

        During a backtest you can select conservative or liberal fill algorithms which will produce different results. Fills are determined based on 4 data points, the OHLC of a bar, since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

        Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

        Also, here is a link to the differences on real-time vs backtest (historical).

        Adding intra-bar granularity can help with this if your strategy normally runs OnEachTick or OnPriceChange in real time.

        Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.

        In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).

        Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:

        High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.

        Further information regarding the Strategy Analyzer may be found in our help guide here:

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service


          Sorry, actually my original question was: in knowing all that already, shouldnt it deny or at least have a warning to stop rookies from wasting their time doing it the wrong way that wont work right anyway thanks


            Hmm, still awfully vague there .. for ex, what is the 'wrong way'?

            Seriously, what do you mean by 'wrong way' -- SA only works one way.
            What is Strategy Analyzer supposed to protect the rookie from doing?
            Are we still talking about the Calculate setting?

            Anyways, since you asked, here's my subjective take on an answer.

            Simply put: No.
            The Strategy Analyzer is already doing the default thing, which is OnBarClose.
            The fact that you can't change that is a matter of learning and understanding
            the product.

            What I mean is, you'll note that the Strategy Analyzer does not have a property
            setting for 'Calculate' in its property grid
            , so right there, score 1 for protecting
            the rookie.

            You'll also note that Strategy Analyzer operates in a way that is completely
            consistent with the default flavor of the entire product -- which is OnBarClose.
            That is, both users and programmers have to go out of their way to understand
            and change Calculate to something other than the default OnBarClose. This is
            a consistent experience throughout the product.

            My point is, you can go pretty far with NinjaTrader (very far indeed) with out
            ever having to know or care or understand that Calculate even exists, much less
            what it does. Especially the truly esoteric advanced details of what it does when
            working with it inside NinjaScript.

            My last defensive comment is this: rookies do not get a pass. They have to read
            documentation and study the NinjaTrader product's advanced features in order to
            properly use those advanced features. If you're talking NinjaScript, same thing.
            NinjaScript is not a toy. It is not a kiddie language, an afterthought, or a throw
            away topic. It is a huge and very complex framework, with very deep roots that
            are internal and mostly hidden from view. The exposed portions that we see are
            like small tropical islands popping up from a massive underwater sea floor.

            And that ocean floor is huge. It's called Microsoft .NET and the C# programming
            language, neither of which are toys either.

            Sorry, let me take a breath ...

            If someone does something 'wrong', I'm not exactly sure I can immediately
            accept that Strategy Analyzer is at fault, or that it should have protected the
            user from doing it the 'wrong' way. I mean, the number of 'wrong' ways a
            user can do something in the NinjaScript framework is quite huge.

            Programming is a very serious skill. It can require years and years of
            study, and even more years of practice. The C# language is no different.

            Just my 2˘.


            Latest Posts


            Topics Statistics Last Post
            Started by Bhavika, Yesterday, 09:03 PM
            1 response
            Last Post NinjaTrader_BrandonH  
            Started by slimcactus, Today, 10:26 AM
            1 response
            Last Post NinjaTrader_Jesse  
            Started by Monares, Today, 10:49 AM
            3 responses
            Last Post NinjaTrader_JustinD  
            Started by d122y, Today, 10:20 AM
            1 response
            Last Post NinjaTrader_ChrisL  
            Started by trader3000a, Today, 06:41 AM
            1 response
            Last Post NinjaTrader_Jesse