StraTrader
Search:

Defining Strategy Argument

Each strategy can have one or more arguments (parameters). Argument is a public field of type int or double with StrategyArg attribute. The following code demonstrates a strategy with 2 arguments:

000: public class BollingerBands : TickerStrategy
001: {
002:     [StrategyArg(20, 10, 10, 60)]
003:     public int Length = 20;
004:
005:     [StrategyArg(2)]
006:     public double BBLParam;
007:
008:     protected override void DoInit() { ... }
009:     protected override void DoProcessBar() { ... }
010:     protected override void DoProcessTrade() { ... }
011:     protected override void DoReset() { ... }
012: }

First argument named 'Length' has default value 20. When optimizing, by default it is optimized in range 10...60 with step 10.

Second argument named 'BBLParam' has default value 2. It has no default optimization range, but it still can be optimized.

For more code examples please go to Sample Strategies.


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