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

Simple daily and overnight strategies

Collapse
X
 
  • 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!

    #2
    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

    Comment


      #3
      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

      Comment


        #4
        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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Max238, Today, 01:28 AM
        4 responses
        35 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by timko, Today, 06:45 AM
        2 responses
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by habeebft, Today, 07:27 AM
        0 responses
        7 views
        0 likes
        Last Post habeebft  
        Working...
        X