Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Q about Historical Backtesting sequence of events

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

    Q about Historical Backtesting sequence of events

    I have been using NT for about a year, primarily testing intraday trading strategies using a 3rd party datafeed.

    Recently, I have been testing longer term strategies in the strategy analyzer using historical EOD data from the yahoo connector.

    My strategy instantiates two indicators, in the Initialize() method, ad subscribes to events I have coded in the indicators. I.e:
    private indType ind1 = new ind1()
    ind1.onNewEvent += ind1eventHandler (OnNewEvent)
    add(ind1);

    when i run this strategy live, the coding works fine. When I run this strategy in the strategy analyzer I notice the event isn't being thrown, in the parent strategy. Additionally, by adding Print("action") statements to the OnBarUpdate() sections of both the strategy and the indicators, as well as inside the event_thrown methods, and then tracking the sequence of the statements in the output window, it appears to me that ALL the data points (bars) are being processed by the strategy and THEN subsequently, all the bars are being processed by the indicators. It appears this way because ALL the messages from the from the Strategy.onBarUpdate are appearing in the output window followed by ALL the messages by the indicator.onBarUpdate messages.

    So my question is, when bars are analyzed historically, what is the the sequence of events, specifically when is the indicator.onbarupdate being thrown, when is the strategy.onbarupdate being thrown? Is there a way to implement an event_thrown structure where the indicator.onbarupdate is thrown prior to the stratgey.onbarupdate, and that sequence for each bar?

    ajhg4

    #2
    Welcome to our forums ajhg4 and sorry for my late reply here...

    Please try working with the Update() method to update embedded indicator values as needed in a backtest - http://www.ninjatrader-support.com/H...V6/Update.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand, thank you for the prompt reply. I'm a little confused, perhaps I am taking the help dialogue a little too litterally. First of all I am not accessing any public properties in the indicators, I have coded the indicators so that when a certain value is achieved if throws and event which is subscribed to by the strategy, such as

      if(OnValue != null)
      OnValue();

      when the event is triggered in the strategy i perform an action.

      ind1_OnValue { Print("text"); EnterLong() ;}

      i know the ind1_OnValue is never being triggered in the strategy because i never see the message indicating it has.

      Secondly, since I am not accessing any public properties of the indicator, is it possible to call ind1.Update() from the stragey.OnBarUpdate() ?

      ajhg4

      Comment


        #4
        ajhg4,

        I guess we are not sure what you mean without seeing the relationship with complete code. In general, you would want to follow this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=4991
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh, Bertrand - thank you for the responses. I have implemented a indicator.Update() from within the Strategy.OnBarUpdate() and it has resolved the issue.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by f.saeidi, Today, 01:32 PM
          0 responses
          0 views
          0 likes
          Last Post f.saeidi  
          Started by traderqz, Today, 12:06 AM
          9 responses
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          117 responses
          2,766 views
          1 like
          Last Post jculp
          by jculp
           
          Started by Mongo, Today, 11:05 AM
          5 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by SightCareAubetter, Today, 12:50 PM
          0 responses
          2 views
          0 likes
          Last Post SightCareAubetter  
          Working...
          X