Example #1
0
        public Model(SymbolInformation symbol, Learner learner, double costOfTrades)
        {
            this.Symbol       = symbol;
            this.Learner      = learner;
            this.CostOfTrades = costOfTrades;

            // create additional data required for features
            this.High   = this.Symbol.High;
            this.Low    = this.Symbol.Low;
            this.Close  = this.Symbol.Close;
            this.Open   = this.Symbol.Open;
            this.Volume = this.Symbol.Volume;
            this.Days   = this.Symbol.Day;

            this.Ema20  = Indicators.EMA(this.Symbol, SourceType.Close, 20);
            this.Ema50  = Indicators.EMA(this.Symbol, SourceType.Close, 50);
            this.Ema200 = Indicators.EMA(this.Symbol, SourceType.Close, 200);
            this.RSI    = Indicators.RSI(this.Close, 50).Scale(0, 100, -1.0, 1);

            //this.KAMA = Indicators.KAMA(symbol, SourceType.Close, 50);
            this.ST = Indicators.ST(this.Symbol, 50, 3);
            (this.RelativeMACD, this.RelativeSignal) = Indicators.RelativeMACD(this.Close, 20, 200, 9, MovingAverage.EMA);
            this.RelativeMACD           = this.Scale(this.RelativeMACD, -0.15, 0.15);
            this.RelativeSignal         = this.Scale(this.RelativeSignal, -0.15, 0.15);
            this.Ema20_50               = this.Scale(Indicators.RelativeDistance(this.Ema20, this.Ema50), -0.20, 0.20);
            this.Ema50_200              = this.Scale(Indicators.RelativeDistance(this.Ema50, this.Ema200), -0.20, 0.20);
            this.Ema50_Close            = this.Scale(Indicators.RelativeDistance(this.Ema50, this.Close), -0.40, 0.40);
            this.St_Close               = this.Scale(Indicators.RelativeDistance(this.ST, this.Close), -0.30, 0.30);
            this.Vola                   = this.Scale(Indicators.VOLA(this.Symbol, SourceType.Close, 30, 250), 0, 0.7);
            this.obos                   = this.Scale(Indicators.OBOS(this.Symbol, 50), 0, 100);
            var(elrBullish, elrBearish) = Indicators.ELR(this.Symbol, 50);
            this.bullish                = this.Scale(Indicators.Ratio(elrBullish, this.Close), -0.10, 0.10);
            this.bearish                = this.Scale(Indicators.Ratio(elrBearish, this.Close), -0.10, 0.101);
            var(dmi, diPlus, diMinus)   = Indicators.DMI(this.Symbol, 50);
            this.dmi           = this.Scale(dmi, 0, 100);
            this.diPlus        = this.Scale(diPlus, 0, 100);
            this.diMinus       = this.Scale(diMinus, 0, 100);
            this.DayOfWeek     = Scale(Indicators.DayOfWeek(symbol), 0, 6);
            this.Month         = Scale(Indicators.Month(symbol), 1, 12);
            this.RelMacdSignal = this.Scale(Indicators.Distance(RelativeMACD, RelativeSignal), -0.1, 0.1);
            //var corr = new PearsonCorrelation();
            //var sim = corr.Similarity(this.Ema20, this.Ema20);
        }