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

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use different values for Close[0] on indicator calculation

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

    Use different values for Close[0] on indicator calculation

    Hello--

    Using an SMA(10) of the closing price in a chart set to COBC = false as an example, the values on the previous 9 bars will be fixed (i.e., Close[9], Close[8], Close[7], ..., Close[1]) and Close[0] will vary based upon the intrabar movements before the final movement and the bar closes and moves to the next bar--at which point everything just moves forward one position and the calculations start all over again.

    My question is whether or not it would be possible to pass an indicator a fixed value to complete the calculation. For instance, on the SMA(10), I would pass the previous 9 closing prices because they are done and locked, but the current bar has a high and low between 100.00 and 90.00. Would it be possible for me to somehow pass 92.50 or 94.75 or 98.25 or whatever value I wanted to as a substitute value for use in the calculation of the SMA(10)?

    I have done this in the past by just writing a small routine that actually calculates the entire SMA or EMA or whatever out for backtesting purposes, but before I start doing that for other more in depth indicators I figured that I should see if NT7 has a way for me to pass a different "Close[0]" to the indicator while still having the indicator use the locked in historical prices for the balance of the indicator calculations.

    I'm interested in this because let's say that I am using a 60 minute bar primary series and I want to backtest a strategy that attempts to replicate the results as if COBC was set to false (i.e., intrabar orders could be fired). If you were to just run the backtest on the 60 minute bar series, clearly an order would have fired on the signal bar--but the NT back test engine would have to wait to put you into the trade until the open of the next bar, which is not how things would have gone down during a live/SIM trade. Therefore, I'm interested in the idea of running a for loop using the High[0] and Low[0] as upper and lower bounds to pass values to the indicators in question to see when the indicator value and order would have fired (for instance, when did a fast SMA cross a slow SMA). Furthermore, because a couple of prices could have made the indicator fire, I would also have some code that would assume a conservative entry price for longs (i.e., start from the High and work to the low, and take the first price to calculate that would have triggered a live/SIM order) and shorts (i.e., start from the Low and work to the High, and take the first price that would have triggered a live/SIM order).

    I know the above sounds complicated, but I'm trying to use a belts and suspenders back testing approach that will allow me be more confident in my back test results, as using a 1 minute secondary series to determine the "live/SIM" order prices does not provide the confidence that I am seeking (i.e., highly volatile instruments like CL can move 10 ticks in a minute, thereby yielding a crummy backtest simulation).

    Please let me know if you have any questions or you need clarifications.

    Thanks for your help,

    Aventeren

    #2
    Check out the DataSeries class for starters.

    http://www.ninjatrader.com/support/h...ries_class.htm

    Comment


      #3
      Originally posted by sledge View Post
      Check out the DataSeries class for starters.

      http://www.ninjatrader.com/support/h...ries_class.htm
      Your 7 words just helped it to all clicked into place. Perhaps I'll post back what I did to get input.

      My hope is that this will replace having to add in a secondary series for backtesting purposes, yet still produce fairly solid results.

      Only time will tell.

      Thanks for your help, Sledge.

      Aventeren
      Last edited by aventeren; 02-25-2014, 10:10 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by StarTrader, 07-11-2020, 11:27 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by rtwave, Yesterday, 04:11 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by sachin shetty, 07-11-2020, 08:49 PM
      1 response
      21 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by P-Sionic, Today, 06:41 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by DannyB85, Yesterday, 02:30 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Working...
      X