• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Simple daily and overnight strategies

  • Filter
  • Time
  • Show
Clear All
new posts

    Simple daily and overnight strategies

    I am trying to build some simple daily and overnight strategies but can´t currently find the right conditions for that in NT8 Strategy Bulilder:
    I would like to build the following 4 strategies:
    1. Enter long position at candle (daily, weekly, monthly) close and close this long position at next candles open (= overnight long position)
    2. Enter short position at candle close and close this short position at next candles open (= overnight short position)
    3. Enter long position at candle open and close this long position at same candles close (= daily long position)
    4. Enter short position at candle open and close this short position at same candles close (= daily short position)
    Is somebody able to help? Thx in advance!

    Hello Traderjoe2017,

    Thanks for your first post!

    Using the Strategy Builder, this logic would have to be created with time checks since the Strategy Builder has limited Multi Time Frame capabilities and does not offer IsFirstTickOfBar.

    For example, 1 & 2 you could create a time check for when the session closes and then to submit your long or short entry here. You can then use a time check to check when the open occurs to exit at the open.

    For 3 & 4, the same steps would be taken for checking the time of the open, submitting your order to enter, and then exiting with a time check for the daily close.

    Time checks - https://ninjatrader.com/support/help...imeComparisons

    A more accurate approach to this would involve unlocking the strategy and adding a 1440 minute data series that uses an appropriate Trading Hours template to match your daily time frame. Then use BarsInProgress == 1 checks in your OnBarUpdate() code to take actions on this data series. Any logic that occurs in BarsInProgress == 1 with IsFirstTickOfBar will be the open of that bar. I have included links for our NinjaScript Editor tutorial which can be used to help transition from the Strategy Builder to writing your own strategies. I have also included associated documentation that can be referenced for accomplishing this task.

    NinjaScript Editor 401 - https://www.youtube.com/watch?v=BA0W4ECyVdc

    Multi Time Frame & Instruments - https://ninjatrader.com/support/help...nstruments.htm

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    Also, if it interests you, we could have a representative of our EcoSystem reach out with additional information on NinjaScript Consultants who would be happy to create this strategy for you at your request.

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service


      Hello Jim, thanks for your quick response, much appreciated.

      Unfortunately, for the backtests I would like to run I do not have any minute data, so your 2. solution is not applicable .
      Regarding the first suggestion by creating time checks seems to be no alternative as well, please see the attached files. It seems to me as if daily bars are not sensitive for any time values.
      Any other ideas?
      Attached Files


        Hello Traderjoe2017,

        You will ultimately need more granular data than daily data to be able to calculate on the open of a bar, or to calculate intrabar.

        Backtests will calculate OnBarClose for performance reasons. Tick Replay can be used and the strategy can be set to Calculate OnEachTick or OnPriceChange when processing historical data, however, you would need tick data to be able to build those bars with Tick Replay and calculate on IsFirstTickOfBar.

        If you just have daily data you will only be able to process daily OHLC data points and those data points would only be available once the bar closes. If you have realtime tick data, then the strategy could start processing bars built with realtime data with Calculate.OnEachTick or Calculate.OnPriceChange. That would only be the case for realtime data testing, as historical backtesting will use historical OHLC values for the bars used in the backtest.

        I've included some further reading for differences between historical and realtime data and I have included a link to our Data by Provider grid which breaks down our supported providers and the data they offer.

        Discrepancies between Historical and Realtime data - https://ninjatrader.com/support/help...ime_vs_bac.htm

        Data by Provider - https://ninjatrader.com/support/help...y_provider.htm

        You may also consider testing your strategy with the Playback Connection with Market Replay data if you plan on getting more granular data further down the line.

        Playback Connection - https://ninjatrader.com/support/help...connection.htm

        Please let us know if we can be of further assistance.
        JimNinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by RobertoPaez, Today, 06:47 PM
        0 responses
        Last Post RobertoPaez  
        Started by catinabag, Today, 06:45 PM
        0 responses
        Last Post catinabag  
        Started by darkgreen, Today, 03:35 PM
        0 responses
        Last Post darkgreen  
        Started by GTBrooks, Today, 02:44 PM
        3 responses
        Last Post GTBrooks  
        Started by GLFX005, Today, 12:22 PM
        4 responses
        Last Post NinjaTrader_Kate