// initialization routine, called once before ticks are sent // if multiple tick sources are used, will get called several times // during the lifetime of the object, once per tick source change public override void Init(string pParameters) { // save parameters sent in case they contain optional parameters RealParameters = pParameters; // a Parameter Parser can be instantiated to check optional parameters RParser = new ParameterParser(pParameters); // this is a mandatory list of parameters. // Optional parameters are not specified here // they need to be checked before DParser.Merge is called // or checked from the RealParameters variable DefaultParameters = "PERIODLONG:17;PERIODSHORT:2;MINUTES:10;DELTA1:0.0005;DELTA2:0.0016;"; // parameters as specified by the user PParser = new ParameterParser(pParameters); // mandatory parameter list and default values DParser = new ParameterParser(DefaultParameters); // make a list of parameters from mandatory list // merge user values if existing, otherwise use defaults Parameters = DParser.Merge(PParser); // build a new parameter parser with sanitized parameter and values // now user values have been merged with desired parameters // extraneous, or optional parameters eliminated. PParser = new ParameterParser(Parameters); // get periods to use for the indicator(s) PeriodsLong = (int)PParser.GetDouble("PERIODLONG", 0); PeriodsShort = (int)PParser.GetDouble("PERIODSHORT", 0);; Delta1 = PParser.GetDouble("DELTA1", 0); Delta2 = PParser.GetDouble("DELTA2", 0); // now indicators must be instantiated // your indicator instantiation goes here // end of indicator instantiation // instantiate candlebuilder with desired timeframe Minutes = (int)PParser.GetDouble("MINUTES", 0); // cbx = new cCandleBuilder(Minutes,PeriodsLong+PeriodsShort+1); cbx = new cCandleBuilder(Minutes, PeriodsLong + PeriodsShort + 20); // register candlebuilder as a tick listener, name unimportant Framework.TickServer.RegisterTickListener("cbx", "*", cbx); // register this object as a candle listener // the candle name is important since we might receive // several candles with same period. cbx.RegisterCandleListener("cbx", this); // multiple candlebuilders can be setup by using previous 4 lines. // register this object as a tick listener, name unimportant // this is an optional step to receive ticks in between candles Framework.TickServer.RegisterTickListener("System", "*", this); // start header line of numerical output file Framework.WriteGraphLine("InTrade,Margin,AvgMRLong,AvgMRShort,Der2,MaxAbsDer2"); }