Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter on Open in backtesting

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

    Enter on Open in backtesting

    Hi,

    Is it possible to backtest strategy with "Enter on Bar Open" using Strategy Analyzer?

    I searched the forum and saw suggestion to use second more granular data series for that. I tried it using "sampleintrabartest" scrip as a basis. I am using Daily bars as primary and 1 Minute as the secondary data series.

    I want it to check if Open of daily bar is below daily SMA(8)[1] and then enter immediately. Based on "sampleintrabartest" script comments I would expect it to enter on Close of the first 1 minute bar of the same daily bar, but in reality it enters on Close of the first 1 minute bar of the next daily bar. Is it possible to make it enter on the same daily bar using this or any other approach?

    Thanks!
    Last edited by ray111; 07-20-2016, 01:10 PM.

    #2
    Hello Ray111, and thank you for your question.

    Based on the description and code you have given me, I believe you will want to pass a data series in as the first argument to SMA. That is, instead of calling

    SMA(8)[1]

    You will likely want to call

    SMA(BarsArray[1], 8)[1]

    If this does not give you the results you would like, or if there are any other questions we may answer, please let us know. I am including a link to the help guide section on multi time frame scripting for more information.

    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply Jessica. I am using SMA based on daily bars which means it would need to use primary data series for that, correct? BarsArray[1] will make it to calculate SMA based on secondary (1 min data), and that is not what I am trying to achieve.

      Comment


        #4
        Hello ray111, and thank you for this additional information. It is difficult without reviewing a script to imagine how things are set up on my end, although I do see where you mentioned which series was which.

        OnBarUpdate events will be generated both for your minute and daily bars. You will need to ensure that your OnBarUpdate event was triggered by your daily bars (BarsInProgress == 1) before data for the previous day's close will be available in DataSeries objects associated with your daily bars.

        If you have ensured that you are processing inside your minute bars, the current day's data will be available in BarsArray[0][0] and the previous day's data in BarsArray[0][1]. For example, Closes[0][1] will refer to the previous day's close price.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X