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

Bollinger Band Entry Strategy - Orders All Over the Place

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

    Bollinger Band Entry Strategy - Orders All Over the Place

    I have a TDAmeritrade / ThinkorSwim can I thought I could automate with NinjaTrader. It was pretty straight forward in terms of entry and I'm not sure if its a limitation of backtest but long story short is that I can't even get a simple order automated based on bar open compared to Bollinger bands.
    In this example I am simply opening an order if at the open of the bar is less than than standard Bollinger band low enter long. However, it's opening positions above the lower BB. I've used Price - Open 0 bars ago, I've used Strategy Current day OHL input series open as I've seen recommended. Neither works either intraday nor daily.
    Attached is the simple code and chart results from PFE. Any help is super appreciated since I've had this for two payment cycles and can't even get the first part of the strategy to work right!

    Attached Files

    #2
    Why not just choose price (close) crossing above lower BB? If you change to "OnBarClose" then the next bar will enter the position. Or for "OnEachTick" you can still use Price (close) cross above lower BB and it will enter as soon as the price crosses above the lower

    Comment


      #3
      Oh I see, you also have "Exit on session close" selected, but on a 1 day chart, so that might cause you issues but I'm not sure

      Comment


        #4
        Hello Steve4616,

        Thank you for your post.

        I note that your screenshot does not show chart data in the Strategy Analyzer. Please ensure you can open a chart of the time frame you're attempting to test over. If you are connected to a live connection that provides historical data for the instrument selected, this data should automatically be downloaded when the Strategy Analyzer is used.

        Keep in mind that on historical data like is used in the Strategy Analyzer, what you're seeing is a backtest over that historical data. 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. 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, 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. Therefore, any actions triggered on a bar will take place on the next bar's open.

        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'.

        For example, in this case, if a bar has an open below the lower bollinger and triggers an entry, that entry would not be seen until the following bar, whose open may not be below the bollinger. In real time, however, this order would have been placed on the bar that triggered it.

        Also, here is a link to the differences on real-time vs backtest (historical).
        http://ninjatrader.com/support/helpG...ime_vs_bac.htm

        Adding intra-bar granularity can help with this.

        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:

        https://ninjatrader.com/support/foru...mance?t=102504

        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.

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,290 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        9 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        62 views
        0 likes
        Last Post halgo_boulder  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        8 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        25 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X