StraTrader
Search:

Using Indicators in Strategy

Most StraTrader indicators are in “StraTrader.Lib” namespace, so the first thing you have to do in your strategy is to make sure that you reference this namespace. When you create new strategy, this namespace is referenced by default.

Indicators in StraTrader are objects rather than functions. You create object and set its properties rather than call function and pass arguments. So to use indicator you have to create object, set its properties and it will automatically calculate its values on each bar.

All indicators have “Values” property which returns its present and all past values in IDoubleArray object. You can access current value of indicator by calling Values property with [0] index, for example MyIndicator.Values[0], previous value is MyIndicator.Values[1] etc.

Follow these simple steps to user indicator in your strategy:
  • Declare your indicators as member variables of Ticker strategy.
  • Create indicator objects in Init function of your Ticker strategy.
  • If you want to show your indicators on the chart, call ShowOnChart function. Do it in Init function of your Ticker strategy.
  • Indicator will automatically update its values on each bar. In ProcessBar function of your Ticker strategy, you can analyze indicator values and place your orders based on these values.


The following code example demonstrates simple strategy that uses several indicators.

About Us   Contact Us   Download   ©2007-2009 Mike Kramarenko in association with SmartProj.com