// constructor, called only once, setup multiple tick variables public oIndicatorDump(int pPeriods) { iPeriods = pPeriods; ATR = new iATR(pPeriods); BB = new iBollingerBands(iPeriods, -1); CCI = new iCCI(iPeriods); Derivatives = new iDerivatives(); EMA = new iEMA(iPeriods); FMA = new iFMA(iPeriods); HMA = new iHMA(iPeriods); MACD = new iMACD(12, 26, 9); Momemtum = new iMomemtum(iPeriods); RSI = new iRSI(iPeriods); Renko = new iRenko(iPeriods); SMA = new iSMA(iPeriods); STARCBands = new iSTARCBands(iPeriods, 2); STDDEV = new iSTDDEV(iPeriods); Slope = new iSlope(); StochRSI = new iStochRSI(iPeriods); Stochastics = new iStochastics(3, 2, 1); Stub = new iStub(iPeriods); Trend = new iTrend(iPeriods); TrueRange = new iTrueRange(); WMA = new iWMA(iPeriods); }
public override void Init(string pParameters) { this.InitializeParameters(pParameters, "BB:20;WIDTH:-1;HMA:10;BWT:0.0008;BWRT:0.0002;TS:0.0003;MINUTES:5;"); State = 0; iPeriods = (int)PParser.GetDouble("BB", 0); iWidth = (int)PParser.GetDouble("WIDTH", 0); iHMALen = (int)PParser.GetDouble("HMA", 0); Minutes = (int)PParser.GetDouble("MINUTES", 0); BWThreshold = PParser.GetDouble("BWT", 0); BWReversalThreshold = PParser.GetDouble("BWRT", 0); TrailingStop = PParser.GetDouble("TS", 0); BBands = new iBollingerBands(iPeriods, iWidth); HMA = new iHMA(iHMALen); SMASlope = new iSlope(); cbx = new cCandleBuilder(Minutes, 10); Framework.TickServer.RegisterTickListener("cbx", "*", cbx); cbx.RegisterCandleListener("cbx", this); Framework.TickServer.RegisterTickListener("System", "*", this); Framework.WriteGraphLine("InTrade,Margin,B+,C,HMA,SMA,B-,State,BWidth,MinBWidth,EntryRecommend"); }
public static void TestBBands() { iBollingerBands BB; BB = new iBollingerBands(10, -1); BB = new iBollingerBands(20, -1); BB = new iBollingerBands(50, -1); BB = new iBollingerBands(21, -1); double[] val = { 6.92, 6.89, 6.82, 6.82, 6.83, 6.79, 6.75, 6.71, 6.71, 6.66, 6.59, 6.56, 6.59, 6.56, 6.61, 6.68, 6.65, 6.68, 6.54, 6.49, 6.42 }; for (int i = 0; i < val.GetUpperBound(0) + 1; i++) { BB.ReceiveTick(val[i]); } double BP, MA, BM, pb, bw; BB.Value(out BP, out MA, out BM, out pb, out bw); if (Math.Abs(MA - 6.68) < 0.01) { Framework.Logger(2, "MA Returns correct value: " + MA); } if (Math.Abs(BP - 6.94) < 0.01) { Framework.Logger(2, "BP Returns correct value: " + BP); } if (Math.Abs(BM - 6.41) < 0.01) { Framework.Logger(2, "BM Returns correct value: " + BM); } }
// 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) { this.InitializeParameters(pParameters, "PERIODS:17;MINUTES:10;"); // get periods to use for the indicator(s) Periods = (int)PParser.GetDouble("PERIODS", 0); Derivatives = new iDerivatives(); HMA = new iHMA(Periods); HMAD1 = new CQueue(Periods); FMA = new iFMA(Periods); Deriv1 = new CQueue(Periods); Deriv2 = new CQueue(Periods); BBands = new iBollingerBands(Periods, -1); StochRSI = new iStochRSI(Periods); CCI = new iCCI(Periods); // instantiate candlebuilder with desired timeframe Minutes = (int)PParser.GetDouble("MINUTES", 0); // cbx = new cCandleBuilder(Minutes,PeriodsLong+PeriodsShort+1); cbx = new cCandleBuilder(Minutes, Periods); // 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,C,TP,FMA,HMA,Deriv1,Deriv2,SMA,BBand1,BBand2,%b,Bandwidth,StochRSI,CCI"); }