PDA

View Full Version : Indicator: Getting indicator values from a specified time


NinjaTrader_Josh
07-29-2009, 11:46 AM
Reference sample for NinjaTrader 6.5.xxxx.x or greater.

Sometimes, you may want to access a value from a historical point in time, but have not kept track of the value to make this readily available. With NinjaScript, it is possible to pick a bar based on time to access that value. GetBar() returns the number of bars ago that holds the same timestamp of the time you request. This sample demonstrates how to get an indicator value from 9:30AM of the previous trading day.

This reference sample demonstrates the following concepts:

Obtaining a Simple Moving Average value from a specific time by referencing the bar number for that time.

Important methods and properties used include:

GetBar() (http://www.ninjatrader.com/support/helpGuides/nt7/getbar.htm)

Other methods and properties of interest include:

DrawLine() (http://www.ninjatrader.com/support/helpGuides/nt7/drawline.htm)
DayOfWeek (http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek.aspx)

Import instructions for NinjaTrader 6.5.XXXX.X or greater:

Download the file contained in this thread to your PC desktop
From the Control Center window, select the menu File > Utilities > Import NinjaScript
Select the downloaded file