Ejemplo n.º 1
0
        public override void Init(string pParameters)
        {
            this.InitializeParameters(pParameters, "CCI:14;TCCI:6;MINUTES:5;");

            CCIPeriods  = (int)PParser.GetDouble("CCI", 0);
            TCCIPeriods = (int)PParser.GetDouble("TCCI", 0);
            Minutes     = (int)PParser.GetDouble("MINUTES", 0);

            CCI      = new iCCI(CCIPeriods);
            TCCI     = new iCCI(TCCIPeriods);
            CCISlope = new iDerivatives();

            CCIH  = new CQueue(CCIPeriods * 3);
            TCCIH = new CQueue(CCIPeriods * 3);

            // OPTIMIZATION PARAMETER CHECK
            // if parameters are erroneous (TurboCCI length > CCI)
            // do not register candle listeners
            // SystemTester will then not send us any ticks
            // and go to the next iteration
            // need 6 cci bars to determine trend

            if ((TCCIPeriods < CCIPeriods) || (CCIPeriods < 6))
            {
                cbx = new cCandleBuilder(Minutes, 10);
                Framework.TickServer.RegisterTickListener("cbx", "*", cbx);
                cbx.RegisterCandleListener("cbx", this);
                Framework.TickServer.RegisterTickListener("System", "*", this);

                Framework.WriteGraphLine("InTrade,Margin,C,CCI,CCIDelta,CCISpeed,TCCI,TypeOfTrade,Direction,BelowFifty,ZLR");
            }
        }
Ejemplo n.º 2
0
        // 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);
        }
Ejemplo n.º 3
0
        public static void TestCCI()
        {
            iCCI cci = new iCCI(20);

            cci.ReceiveTick(1302.67, 1302.67, 1263.23, 1263.84);
            cci.ReceiveTick(1268.65, 1294.65, 1261, 1292.3101);
            cci.ReceiveTick(1274.76, 1274.76, 1251, 1251);
            cci.ReceiveTick(1280.27, 1304.02, 1280.27, 1295.3);
            cci.ReceiveTick(1286.75, 1310.33, 1270.73, 1304.6);
            cci.ReceiveTick(1306.13, 1322.4301, 1299.53, 1320.09);
            cci.ReceiveTick(1328.35, 1347.27, 1314.96, 1315.45);
            cci.ReceiveTick(1305.72, 1305.72, 1279.09, 1279.6801);
            cci.ReceiveTick(1272.9399, 1292.36, 1270.59, 1291.4);
            cci.ReceiveTick(1286.85, 1292.73, 1267.6899, 1275.88);
            cci.ReceiveTick(1292.91, 1298.5, 1258.85, 1259.9399);
            cci.ReceiveTick(1244.52, 1263.9, 1233.08, 1252.13);
            cci.ReceiveTick(1233.9399, 1242.91, 1216.1899, 1216.45);
            cci.ReceiveTick(1229.47, 1232.96, 1216.24, 1221.09);
            cci.ReceiveTick(1209.13, 1209.72, 1177.41, 1184.9301);
            cci.ReceiveTick(1170.95, 1200.45, 1169.04, 1182.17);
            cci.ReceiveTick(1195.6, 1227.23, 1184.12, 1222.29);
            cci.ReceiveTick(1231.85, 1239.62, 1206.91, 1221.61);

            cci.ReceiveTick(1213.77, 1235.08, 1198.12, 1199.16);
            double v;

            v = cci.Value();
            if ((v != 0) || (cci.isPrimed()))
            {
                Framework.Logger(2, "ERROR: CCI should not be primed yet");
            }

            cci.ReceiveTick(1187.48, 1190.74, 1160.0699, 1172.0601);
            v = cci.Value();
            if (Math.Abs(v - (-136.0742924)) < 0.001)
            {
                Framework.Logger(2, "CCI returned correct value -136.074");
            }

            cci.ReceiveTick(1180.26, 1214.01, 1160.71, 1213.72);
            v = cci.Value();
            if (Math.Abs(v - (-87.47)) < 0.01)
            {
                Framework.Logger(2, "CCI returned correct value -87.47");
            }
        }
        // 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");
        }