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

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.

    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 kaywai, 09-01-2023, 08:44 PM
      5 responses
      601 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      22 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      16 views
      0 likes
      Last Post Pattontje  
      Started by flybuzz, 04-21-2024, 04:07 PM
      17 responses
      230 views
      0 likes
      Last Post TradingLoss  
      Started by agclub, 04-21-2024, 08:57 PM
      3 responses
      17 views
      0 likes
      Last Post TradingLoss  
      Working...
      X