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

Changing Indicator values prior to OnBarClose

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

    Changing Indicator values prior to OnBarClose

    Hi,

    I am developing a strategy that uses Renko bars, but I've also added a secondary 1 tick data series for more granularity. However, when I backtest and view the associated tick data, as well as the values of indicators included in the strategy (all of which are based on the primary data series), the values of the indicators are changing prior to a bar of the primary data series closing. In other words, as intra bar ticks occur, the indicator value will sometimes change (but not always) even though the associated bar has not closed. Is this normal behaviour? To clarify, the Calculate setting is "OnBarClose".

    Frequently, when I run a backtest, trades will be reflected in the back test which were not taken while the strategy was running in real time. I am trying to understand why this is the case. I think it may be because indicator values appear to be changing intrabar, which is affecting whether or not a condition is met on bar close.

    If this is normal behaviour, is there a way to code the strategy so that the indicator values don't change until the actual bar closes (while still including the 1 tick series)?

    Any help would be appreciated.


    #2
    Hello RideMe,

    Thank you for your post.

    Please provide an example demonstrating when the values seem to be changing intrabar. Have you been able to verify this with print statements? The following post goes into detail about using prints to debug your script's behavior:


    One challenge presented by Renko bars is their functionality to remove the previous bar in the series and replace it with a new Open price; this could potentially be affecting your backtest results as this is not something that can be simulated in the Strategy Analyzer. This is mentioned on the following page:


    One alternative is to test your strategy using the Playback Connection instead, as this builds the bars as if they were in real-time:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi Emily,

      Thank you for getting back to me. Yes, I have verified this with print statements (via streamwriter). For example, when back testing, I'll look at each trade's status quo (in terms of indicator values) by tick increments (increments that are similar to the renko bar's range that I use) throughout each trade. Below is an example from a back test.... The time of the print is consistent with the bar's time on the chart (and the preceding and folllowing bar had different time stamps). The columns below are time stamp, price, ticks (or current price - entry price), and stochastic reading, respectively. As you can see, while the bar was still forming the stochastic value dropped from 80 to 78.56. This is not that unique....this seems to occur on many bars, and it is not just the stochastic reading that will change.
      2/9/2023 9:44:35 AM 1945.3 2.3 80.08308895
      2/9/2023 9:44:35 AM 1945.2 2.2 80.08308895
      2/9/2023 9:44:35 AM 1945 2 80.08308895
      2/9/2023 9:44:35 AM 1945.1 2.1 80.08308895
      2/9/2023 9:44:35 AM 1944.9 1.9 80.08308895
      2/9/2023 9:44:35 AM 1944.8 1.8 80.08308895
      2/9/2023 9:44:35 AM 1944.7 1.7 80.08308895
      2/9/2023 9:44:35 AM 1944.7 1.7 80.08308895
      2/9/2023 9:44:35 AM 1944.8 1.8 80.08308895
      2/9/2023 9:44:35 AM 1944.9 1.9 80.08308895
      2/9/2023 9:44:35 AM 1945 2 80.08308895
      2/9/2023 9:44:35 AM 1945.1 2.1 80.08308895
      2/9/2023 9:44:35 AM 1945.2 2.2 80.08308895
      2/9/2023 9:45:35 AM 1944.7 1.7 78.56793744
      2/9/2023 9:45:35 AM 1944.8 1.8 78.56793744
      2/9/2023 9:45:35 AM 1944.9 1.9 78.56793744

      I am aware of the issues with Renko bars, which is why I have the tick data series in my strategy. I have also tested my strategy with the playback connection. In many cases, the trade will occur during the playback, but it skips it during live trading. I have also had instances where trades that showed up in back tests (same data, and same period), simply stopped showing up in back test results, only to return days later. My thought is that if indicator values are sometimes changing intra bar, then on any given instance when a back test is done, one of the alternate readings is being used, which results in a different trade/trade outcome.

      Comment


        #4
        It seems I can't read because the time did in fact change...let me double check this and get back to you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        16 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        4 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,785 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,407 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X