Exemplo n.º 1
0
 public MySqlFunctionManager(bool allowFuncDefChange)
 {
     this.allowFuncDefChange                = allowFuncDefChange;
     parsingStrateg["CAST"]                 = FunctionParsingStrategy.Cast;
     parsingStrateg["POSITION"]             = FunctionParsingStrategy.Position;
     parsingStrateg["SUBSTR"]               = FunctionParsingStrategy.Substring;
     parsingStrateg["SUBSTRING"]            = FunctionParsingStrategy.Substring;
     parsingStrateg["TRIM"]                 = FunctionParsingStrategy.Trim;
     parsingStrateg["AVG"]                  = FunctionParsingStrategy.Avg;
     parsingStrateg["COUNT"]                = FunctionParsingStrategy.Count;
     parsingStrateg["GROUP_CONCAT"]         = FunctionParsingStrategy.GroupConcat;
     parsingStrateg["MAX"]                  = FunctionParsingStrategy.Max;
     parsingStrateg["MIN"]                  = FunctionParsingStrategy.Min;
     parsingStrateg["SUM"]                  = FunctionParsingStrategy.Sum;
     parsingStrateg["ROW"]                  = FunctionParsingStrategy.Row;
     parsingStrateg["CHAR"]                 = FunctionParsingStrategy.Char;
     parsingStrateg["CONVERT"]              = FunctionParsingStrategy.Convert;
     parsingStrateg["EXTRACT"]              = FunctionParsingStrategy.Extract;
     parsingStrateg["TIMESTAMPADD"]         = FunctionParsingStrategy.Timestampadd;
     parsingStrateg["TIMESTAMPDIFF"]        = FunctionParsingStrategy.Timestampdiff;
     parsingStrateg["GET_FORMAT"]           = FunctionParsingStrategy.GetFormat;
     functionPrototype["ABS"]               = new Abs(null);
     functionPrototype["ACOS"]              = new Acos(null);
     functionPrototype["ADDDATE"]           = new Adddate(null);
     functionPrototype["ADDTIME"]           = new Addtime(null);
     functionPrototype["AES_DECRYPT"]       = new AesDecrypt(null);
     functionPrototype["AES_ENCRYPT"]       = new AesEncrypt(null);
     functionPrototype["ANALYSE"]           = new Analyse(null);
     functionPrototype["ASCII"]             = new Ascii(null);
     functionPrototype["ASIN"]              = new Asin(null);
     functionPrototype["ATAN2"]             = new Atan2(null);
     functionPrototype["ATAN"]              = new Atan(null);
     functionPrototype["BENCHMARK"]         = new Benchmark(null);
     functionPrototype["BIN"]               = new Bin(null);
     functionPrototype["BIT_AND"]           = new BitAnd(null);
     functionPrototype["BIT_COUNT"]         = new BitCount(null);
     functionPrototype["BIT_LENGTH"]        = new BitLength(null);
     functionPrototype["BIT_OR"]            = new BitOR(null);
     functionPrototype["BIT_XOR"]           = new BitXor(null);
     functionPrototype["CEIL"]              = new Ceiling(null);
     functionPrototype["CEILING"]           = new Ceiling(null);
     functionPrototype["CHAR_LENGTH"]       = new CharLength(null);
     functionPrototype["CHARACTER_LENGTH"]  = new CharLength(null);
     functionPrototype["CHARSET"]           = new Charset(null);
     functionPrototype["COALESCE"]          = new Coalesce(null);
     functionPrototype["COERCIBILITY"]      = new Coercibility(null);
     functionPrototype["COLLATION"]         = new Collation(null);
     functionPrototype["COMPRESS"]          = new Compress(null);
     functionPrototype["CONCAT_WS"]         = new ConcatWs(null);
     functionPrototype["CONCAT"]            = new Concat(null);
     functionPrototype["CONNECTION_ID"]     = new ConnectionId(null);
     functionPrototype["CONV"]              = new Conv(null);
     functionPrototype["CONVERT_TZ"]        = new ConvertTz(null);
     functionPrototype["COS"]               = new Cos(null);
     functionPrototype["COT"]               = new Cot(null);
     functionPrototype["CRC32"]             = new Crc32(null);
     functionPrototype["CURDATE"]           = new Curdate();
     functionPrototype["CURRENT_DATE"]      = new Curdate();
     functionPrototype["CURRENT_TIME"]      = new Curtime();
     functionPrototype["CURTIME"]           = new Curtime();
     functionPrototype["CURRENT_TIMESTAMP"] = new Now();
     functionPrototype["CURRENT_USER"]      = new CurrentUser();
     functionPrototype["CURTIME"]           = new Curtime();
     functionPrototype["DATABASE"]          = new Database(null);
     functionPrototype["DATE_ADD"]          = new DateAdd(null);
     functionPrototype["DATE_FORMAT"]       = new DateFormat(null);
     functionPrototype["DATE_SUB"]          = new DateSub(null);
     functionPrototype["DATE"]              = new Date(null);
     functionPrototype["DATEDIFF"]          = new Datediff(null);
     functionPrototype["DAY"]               = new Dayofmonth(null);
     functionPrototype["DAYOFMONTH"]        = new Dayofmonth(null);
     functionPrototype["DAYNAME"]           = new Dayname(null);
     functionPrototype["DAYOFWEEK"]         = new Dayofweek(null);
     functionPrototype["DAYOFYEAR"]         = new Dayofyear(null);
     functionPrototype["DECODE"]            = new Decode(null);
     functionPrototype["DEFAULT"]           = new Default(null);
     functionPrototype["DEGREES"]           = new Degrees(null);
     functionPrototype["DES_DECRYPT"]       = new DesDecrypt(null);
     functionPrototype["DES_ENCRYPT"]       = new DesEncrypt(null);
     functionPrototype["ELT"]               = new Elt(null);
     functionPrototype["ENCODE"]            = new Encode(null);
     functionPrototype["ENCRYPT"]           = new Encrypt(null);
     functionPrototype["EXP"]               = new Exp(null);
     functionPrototype["EXPORT_SET"]        = new ExportSet(null);
     // functionPrototype.put("EXTRACT", new Extract(null));
     functionPrototype["EXTRACTVALUE"]  = new ExtractValue(null);
     functionPrototype["FIELD"]         = new Field(null);
     functionPrototype["FIND_IN_SET"]   = new FindInSet(null);
     functionPrototype["FLOOR"]         = new Floor(null);
     functionPrototype["FORMAT"]        = new Format(null);
     functionPrototype["FOUND_ROWS"]    = new FoundRows(null);
     functionPrototype["FROM_DAYS"]     = new FromDays(null);
     functionPrototype["FROM_UNIXTIME"] = new FromUnixtime(null);
     // functionPrototype.put("GET_FORMAT", new GetFormat(null));
     functionPrototype["GET_LOCK"]       = new GetLock(null);
     functionPrototype["GREATEST"]       = new Greatest(null);
     functionPrototype["HEX"]            = new Hex(null);
     functionPrototype["HOUR"]           = new Hour(null);
     functionPrototype["IF"]             = new IF(null);
     functionPrototype["IFNULL"]         = new IFNull(null);
     functionPrototype["INET_ATON"]      = new InetAton(null);
     functionPrototype["INET_NTOA"]      = new InetNtoa(null);
     functionPrototype["INSERT"]         = new Insert(null);
     functionPrototype["INSTR"]          = new Instr(null);
     functionPrototype["INTERVAL"]       = new Interval(null);
     functionPrototype["IS_FREE_LOCK"]   = new IsFreeLock(null);
     functionPrototype["IS_USED_LOCK"]   = new IsUsedLock(null);
     functionPrototype["ISNULL"]         = new IsNull(null);
     functionPrototype["LAST_DAY"]       = new LastDay(null);
     functionPrototype["LAST_INSERT_ID"] = new LastInsertId(null);
     functionPrototype["LCASE"]          = new Lower(null);
     functionPrototype["LEAST"]          = new Least(null);
     functionPrototype["LEFT"]           = new Left(null);
     functionPrototype["LENGTH"]         = new Length(null);
     functionPrototype["LN"]             = new Log(null);
     // Ln(X) equals Log(X)
     functionPrototype["LOAD_FILE"]       = new LoadFile(null);
     functionPrototype["LOCALTIME"]       = new Now();
     functionPrototype["LOCALTIMESTAMP"]  = new Now();
     functionPrototype["LOCATE"]          = new Locate(null);
     functionPrototype["LOG10"]           = new Log10(null);
     functionPrototype["LOG2"]            = new Log2(null);
     functionPrototype["LOG"]             = new Log(null);
     functionPrototype["LOWER"]           = new Lower(null);
     functionPrototype["LPAD"]            = new Lpad(null);
     functionPrototype["LTRIM"]           = new Ltrim(null);
     functionPrototype["MAKE_SET"]        = new MakeSet(null);
     functionPrototype["MAKEDATE"]        = new Makedate(null);
     functionPrototype["MAKETIME"]        = new Maketime(null);
     functionPrototype["MASTER_POS_WAIT"] = new MasterPosWait(null);
     functionPrototype["MD5"]             = new Md5(null);
     functionPrototype["MICROSECOND"]     = new Microsecond(null);
     functionPrototype["MID"]             = new Substring(null);
     functionPrototype["MINUTE"]          = new Minute(null);
     functionPrototype["MONTH"]           = new Month(null);
     functionPrototype["MONTHNAME"]       = new Monthname(null);
     functionPrototype["NAME_CONST"]      = new NameConst(null);
     functionPrototype["NOW"]             = new Now();
     functionPrototype["NULLIF"]          = new NullIF(null);
     functionPrototype["OCT"]             = new Oct(null);
     functionPrototype["OCTET_LENGTH"]    = new Length(null);
     functionPrototype["OLD_PASSWORD"]    = new OldPassword(null);
     functionPrototype["ORD"]             = new Ord(null);
     functionPrototype["PASSWORD"]        = new Password(null);
     functionPrototype["PERIOD_ADD"]      = new PeriodAdd(null);
     functionPrototype["PERIOD_DIFF"]     = new PeriodDiff(null);
     functionPrototype["PI"]              = new PI(null);
     functionPrototype["POW"]             = new Pow(null);
     functionPrototype["POWER"]           = new Pow(null);
     functionPrototype["QUARTER"]         = new Quarter(null);
     functionPrototype["QUOTE"]           = new Quote(null);
     functionPrototype["RADIANS"]         = new Radians(null);
     functionPrototype["RAND"]            = new Rand(null);
     functionPrototype["RELEASE_LOCK"]    = new ReleaseLock(null);
     functionPrototype["REPEAT"]          = new Repeat(null);
     functionPrototype["REPLACE"]         = new Replace(null);
     functionPrototype["REVERSE"]         = new Reverse(null);
     functionPrototype["RIGHT"]           = new Right(null);
     functionPrototype["ROUND"]           = new Round(null);
     functionPrototype["ROW_COUNT"]       = new RowCount(null);
     functionPrototype["RPAD"]            = new Rpad(null);
     functionPrototype["RTRIM"]           = new Rtrim(null);
     functionPrototype["SCHEMA"]          = new Database(null);
     functionPrototype["SEC_TO_TIME"]     = new SecToTime(null);
     functionPrototype["SECOND"]          = new Second(null);
     functionPrototype["SESSION_USER"]    = new User(null);
     functionPrototype["SHA1"]            = new Sha1(null);
     functionPrototype["SHA"]             = new Sha1(null);
     functionPrototype["SHA2"]            = new Sha2(null);
     functionPrototype["SIGN"]            = new Sign(null);
     functionPrototype["SIN"]             = new Sin(null);
     functionPrototype["SLEEP"]           = new Sleep(null);
     functionPrototype["SOUNDEX"]         = new Soundex(null);
     functionPrototype["SPACE"]           = new Space(null);
     functionPrototype["SQRT"]            = new Sqrt(null);
     functionPrototype["STD"]             = new Std(null);
     functionPrototype["STDDEV_POP"]      = new StdDevPop(null);
     functionPrototype["STDDEV_SAMP"]     = new StdDevSamp(null);
     functionPrototype["STDDEV"]          = new StdDev(null);
     functionPrototype["STR_TO_DATE"]     = new StrToDate(null);
     functionPrototype["STRCMP"]          = new Strcmp(null);
     functionPrototype["SUBDATE"]         = new Subdate(null);
     functionPrototype["SUBSTRING_INDEX"] = new SubstringIndex(null);
     functionPrototype["SUBTIME"]         = new Subtime(null);
     functionPrototype["SYSDATE"]         = new Sysdate(null);
     functionPrototype["SYSTEM_USER"]     = new User(null);
     functionPrototype["TAN"]             = new Tan(null);
     functionPrototype["TIME_FORMAT"]     = new TimeFormat(null);
     functionPrototype["TIME_TO_SEC"]     = new TimeToSec(null);
     functionPrototype["TIME"]            = new Time(null);
     functionPrototype["TIMEDIFF"]        = new Timediff(null);
     functionPrototype["TIMESTAMP"]       = new Timestamp(null);
     // functionPrototype.put("TIMESTAMPADD", new Timestampadd(null));
     // functionPrototype.put("TIMESTAMPDIFF", new Timestampdiff(null));
     functionPrototype["TO_DAYS"]             = new ToDays(null);
     functionPrototype["TO_SECONDS"]          = new ToSeconds(null);
     functionPrototype["TRUNCATE"]            = new Truncate(null);
     functionPrototype["UCASE"]               = new Upper(null);
     functionPrototype["UNCOMPRESS"]          = new Uncompress(null);
     functionPrototype["UNCOMPRESSED_LENGTH"] = new UncompressedLength(null);
     functionPrototype["UNHEX"]               = new Unhex(null);
     functionPrototype["UNIX_TIMESTAMP"]      = new UnixTimestamp(null);
     functionPrototype["UPDATEXML"]           = new UpdateXml(null);
     functionPrototype["UPPER"]               = new Upper(null);
     functionPrototype["USER"]          = new User(null);
     functionPrototype["UTC_DATE"]      = new UtcDate(null);
     functionPrototype["UTC_TIME"]      = new UtcTime(null);
     functionPrototype["UTC_TIMESTAMP"] = new UtcTimestamp(null);
     functionPrototype["UUID_SHORT"]    = new UuidShort(null);
     functionPrototype["UUID"]          = new Uuid(null);
     functionPrototype["VALUES"]        = new Values(null);
     functionPrototype["VAR_POP"]       = new VarPop(null);
     functionPrototype["VAR_SAMP"]      = new VarSamp(null);
     functionPrototype["VARIANCE"]      = new Variance(null);
     functionPrototype["VERSION"]       = new Version(null);
     functionPrototype["WEEK"]          = new Week(null);
     functionPrototype["WEEKDAY"]       = new Weekday(null);
     functionPrototype["WEEKOFYEAR"]    = new Weekofyear(null);
     functionPrototype["YEAR"]          = new Year(null);
     functionPrototype["YEARWEEK"]      = new Yearweek(null);
 }
Exemplo n.º 2
0
        public SimulationOutput ComputeSimulation(SimulationInput input)
        {
            var securities = _repository.GetSecurities();
            var underlying = securities.FirstOrDefault(x => x.SecurityType == SecurityType.Underlying);
            var future     = securities.FirstOrDefault(x => x.SecurityType == SecurityType.Future);
            var call       = securities.FirstOrDefault(x => x.SecurityType == SecurityType.Option);

            ReturnCalculator.ComputeReturn(underlying.DataSeries);

            var output = new SimulationOutput();

            output.Type = SimulationType.FixedVol;

            if (input != null && input.TimeWindow.HasValue)
            {
                output.TimeWindow = input.TimeWindow;
            }
            else
            {
                output.TimeWindow = 252;
            }

            if (input != null && input.Sigma.HasValue && input.Sigma.Value != 0)
            {
                output.Sigma = input.Sigma / 100;
            }
            else
            {
                output.Sigma = StdDev.ComputeStdDev(underlying.DataSeries, 252);
            }

            if (input != null && input.RiskFree.HasValue)
            {
                output.RiskFree = input.RiskFree / 100;
            }
            else
            {
                output.RiskFree = 4.5 / 100;
            }


            var minDate = call.DataSeries.Min(x => x.Date);

            var initialVol = EWMA.ComputeInitalVol(underlying.DataSeries, input.Lambda.Value, minDate, input.TimeWindow.Value);

            var    count = 0;
            double volYesterday = 0, returnYesterday = 0;

            call.DataSeries
            .OrderByDescending(x => x.Date)
            .ToList()
            .ForEach(x =>
            {
                var underPrice = future.DataSeries.Where(y => y.Date == x.Date).FirstOrDefault();

                if (underPrice != null)
                {
                    var simulationDataSerie                  = new SimulationDataSerie();
                    simulationDataSerie.Volatility           = output.Sigma.Value;
                    simulationDataSerie.Date                 = x.Date;
                    simulationDataSerie.BlackAndScholesPrice =
                        BlackAndScholes.ComputePrice(underPrice.Price, call.Strike, output.RiskFree.Value, output.Sigma.Value, (x.TTM.Value / 252.0), 0);

                    simulationDataSerie.Black76Price =
                        Black76.ComputePrice(underPrice.Price, call.Strike, output.RiskFree.Value, output.Sigma.Value, (x.TTM.Value / 252.0), 0);

                    simulationDataSerie.UnderlyingPrice = underPrice.Price;
                    simulationDataSerie.MarketPrice     = x.Price;

                    if (count == 0)
                    {
                        simulationDataSerie.EWMAVol = initialVol;
                    }
                    else
                    {
                        simulationDataSerie.EWMAVol = EWMA.ComputeVol(volYesterday, returnYesterday, input.Lambda.Value);
                    }

                    simulationDataSerie.BlackAndScholesPriceEWMA =
                        BlackAndScholes.ComputePrice(underPrice.Price, call.Strike, output.RiskFree.Value, simulationDataSerie.EWMAVol * 100, (x.TTM.Value / 252.0), 0);

                    simulationDataSerie.Black76PriceEWMA =
                        Black76.ComputePrice(underPrice.Price, call.Strike, output.RiskFree.Value, simulationDataSerie.EWMAVol, (x.TTM.Value / 252.0), 0);

                    returnYesterday = underlying.DataSeries.OrderByDescending(y => y.Date).First(y => y.Date < x.Date).Return;
                    volYesterday    = simulationDataSerie.EWMAVol;

                    output.DataSeries.Add(simulationDataSerie);
                    count++;
                }
            });

            output.DataSeries = output.DataSeries.OrderBy(x => x.Date).ToList();

            return(output);
        }
Exemplo n.º 3
0
 protected bool Equals(RatioValue other)
 {
     return(Ratio.Equals(other.Ratio) && StdDev.Equals(other.StdDev) && DotProduct.Equals(other.DotProduct));
 }
Exemplo n.º 4
0
        //(BarHistory bars, BarHistory barsFirst, BarHistory barsSecond, int periodRegression, int periodRegressionMomentum,
        public override void Populate()
        {
            BarHistory bars         = Parameters[0].AsBarHistory;
            Int32      period       = Parameters[1].AsInt;
            Int32      emaPeriod    = Parameters[2].AsInt;
            Double     cutoffConst  = Parameters[3].AsDouble;
            Double     curtailCoeff = Parameters[4].AsDouble;

            DateTimes = bars.DateTimes;

            var FirstValidValue = Math.Max(period, emaPeriod) * 3;

            if (FirstValidValue > bars.Count || FirstValidValue < 0)
            {
                FirstValidValue = bars.Count;
            }

            if (FirstValidValue <= 0 || DateTimes.Count == 0)
            {
                return;
            }

            // Based on WL4 coding: http://wl4.wealth-lab.com/cgi-bin/WealthLab.DLL/libraryview?item=245
            var dsInter = new TimeSeries(DateTimes);

            dsInter[0] = 0d;

            // 'Typical' is the AveragePriceC.Series in WLP
            for (int bar = 1; bar < bars.Count; bar++)
            {
                dsInter[bar] = Math.Log(bars.AveragePriceHLC[bar]) - Math.Log(bars.AveragePriceHLC[bar - 1]);
            }

            // StdDev over 30-day time period (30 bars)
            dsInter = new StdDev(dsInter, 30);
            var dsCutoff = dsInter * cutoffConst * bars.Close;

            // dsAve = Average volume with 1 bar delay
            var dsAve = new FastSMA(bars.Volume, period) >> 1;
            var dsMax = dsAve * curtailCoeff;

            var dsMF  = bars.AveragePriceHLC - (bars.AveragePriceHLC >> 1);
            var dsSer = new TimeSeries(DateTimes);
            var dsVFI = new TimeSeries(DateTimes);

            // Optimized summation over period.
            double PrevVfi = 0.0;

            for (int bar = 0; bar < bars.Count; bar++)
            {
                double Old = 0.0;
                if (bar > period)
                {
                    Old = dsSer[bar - period - 1];
                }

                double Value = Math.Min(bars.Volume[bar], dsMax[bar]);
                double New   = 0.0;
                if (dsMF[bar] > dsCutoff[bar])
                {
                    New = Value;
                }
                else if (dsMF[bar] < (-1 * dsCutoff[bar]))
                {
                    New = -1 * Value;
                }

                dsSer[bar] = New;
                dsVFI[bar] = PrevVfi - Old + New;
                PrevVfi    = dsVFI[bar];
            }

            dsVFI /= dsAve;

            // Smooth VFI and store in result series
            var dsEma = new EMA(dsVFI, emaPeriod);

            for (int bar = 0; bar < bars.Count; bar++)
            {
                Values[bar] = dsEma[bar];
            }
        }
Exemplo n.º 5
0
        //populate
        public override void Populate()
        {
            BarHistory bars   = Parameters[0].AsBarHistory;
            Int32      period = Parameters[1].AsInt;

            DateTimes = bars.DateTimes;

            if (period <= 0 || bars.Count == 0)
            {
                return;
            }

            var FirstValidValue = period;

            if (FirstValidValue > bars.Count || FirstValidValue < 0)
            {
                FirstValidValue = bars.Count;
            }

            var RelVol = new TimeSeries(DateTimes);

            if (FirstValidValue > 1)
            {
                RelVol[FirstValidValue - 1] = 0d;
            }

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                double av     = FastSMA.Calculate(bar, bars.Volume, period);
                double sd     = new StdDev(bars.Volume, period)[bar];
                double relVol = (bars.Volume[bar] - av) / sd;
                RelVol[bar] = relVol;
            }

            var aMove   = ((bars.Close - (bars.Close >> 1)) / bars.Close >> 1).Abs();
            var theMin  = new Lowest(aMove, period);
            var theMax  = new Highest(aMove, period);
            var theMove = new TimeSeries(DateTimes);
            var theVol  = new TimeSeries(DateTimes);

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                if ((theMax[bar] - theMin[bar]) > 0)
                {
                    theMove[bar] = 1.0 + ((aMove[bar] - theMin[bar]) * (10d - 1d)) / (theMax[bar] - theMin[bar]);
                }
            }

            var theMinV = new Lowest(RelVol, period);
            var theMaxV = new Highest(RelVol, period);

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                if ((theMaxV[bar] - theMinV[bar]) > 0)
                {
                    theVol[bar] = 1.0 + ((RelVol[bar] - theMinV[bar]) * (10d - 1d)) / (theMaxV[bar] - theMinV[bar]);
                }
            }

            var vByM   = theVol / theMove;
            var avF    = new SMA(vByM, period);
            var sdF    = new StdDev(vByM, period);
            var theFoM = (vByM - avF) / sdF;

            for (int bar = 0; bar < bars.Count; bar++)
            {
                Values[bar] = theFoM[bar];
            }
        }
Exemplo n.º 6
0
        public InSyncIndex(Bars bars, string description)
            : base(bars, description)
        {
            base.FirstValidValue = 20;

            if (bars.Count < 20)
            {
                return;
            }

            DataSeries BOLInSLB = StdDev.Series(bars.Close, 20, StdDevCalculation.Sample) * 2;

            BOLInSLB = Community.Indicators.FastSMA.Series(bars.Close, 20) - BOLInSLB;

            DataSeries BOLInSUB = StdDev.Series(bars.Close, 20, StdDevCalculation.Sample) * 2;

            BOLInSUB = Community.Indicators.FastSMA.Series(bars.Close, 20) + BOLInSUB;

            DataSeries BOLInS2 = BOLInSUB - BOLInSLB;

            BOLInS2 = (bars.Close - BOLInSLB) / BOLInS2;

            EMV        emv     = EMV.Series(bars, 13);
            DataSeries EMVSer  = Community.Indicators.FastSMA.Series(emv, 10);
            DataSeries EMVInS2 = EMVSer - Community.Indicators.FastSMA.Series(EMVSer, 10);

            DataSeries MACDSer  = Community.Indicators.FastSMA.Series(MACD.Series(bars.Close), 10);
            DataSeries MACDInS2 = MACD.Series(bars.Close) - MACDSer;

            int        Period    = 18;
            DataSeries DPOSeries = bars.Close - (Community.Indicators.FastSMA.Series(bars.Close, Period) >> ((Period / 2) + 1));

            DataSeries PDOSer  = Community.Indicators.FastSMA.Series(DPOSeries, 10);
            DataSeries PDOInS2 = DPOSeries - PDOSer;

            DataSeries ROCSer  = EMA.Series(ROC.Series(bars.Close, 10), 10, EMACalculation.Modern);
            DataSeries ROCInS2 = ROC.Series(bars.Close, 10) - ROCSer;

            DataSeries BOLInSLL = bars.Close * 0;
            DataSeries CCInS    = bars.Close * 0;
            DataSeries EMVInSB  = bars.Close * 0;
            DataSeries EMVInSS  = bars.Close * 0;
            DataSeries MACDInSB = bars.Close * 0;
            DataSeries MACDInSS = bars.Close * 0;
            DataSeries MFIInS   = bars.Close * 0;
            DataSeries PDOInSB  = bars.Close * 0;
            DataSeries PDOInSS  = bars.Close * 0;
            DataSeries ROCInSB  = bars.Close * 0;
            DataSeries ROCInSS  = bars.Close * 0;
            DataSeries RSIInS   = bars.Close * 0;
            DataSeries STODInS  = bars.Close * 0;
            DataSeries STOKInS  = bars.Close * 0;

            for (int bar = base.FirstValidValue; bar < bars.Count; bar++)
            {
                if (BOLInS2[bar] < 0.05)
                {
                    BOLInSLL[bar] = -5;
                }
                else
                if (BOLInS2[bar] > 0.95)
                {
                    BOLInSLL[bar] = +5;
                }

                if (CCI.Series(bars, 14)[bar] > +100)
                {
                    CCInS[bar] = +5;
                }
                else
                if (CCI.Series(bars, 14)[bar] < -100)
                {
                    CCInS[bar] = -5;
                }

                if ((EMVInS2[bar] < 0) & (EMVSer[bar] < 0))
                {
                    EMVInSB[bar] = -5;
                }
                if ((EMVInS2[bar] > 0) & (EMVSer[bar] > 0))
                {
                    EMVInSS[bar] = +5;
                }

                if ((MACDInS2[bar] < 0) & (MACDSer[bar] < 0))
                {
                    MACDInSB[bar] = -5;
                }
                if ((MACDInS2[bar] > 0) & (MACDSer[bar] > 0))
                {
                    MACDInSS[bar] = +5;
                }

                if (MFI.Series(bars, 20)[bar] > 80)
                {
                    MFIInS[bar] = +5;
                }
                else
                if (MFI.Series(bars, 20)[bar] < 20)
                {
                    MFIInS[bar] = -5;
                }

                if ((PDOInS2[bar] < 0) & (PDOSer[bar] < 0))
                {
                    PDOInSB[bar] = -5;
                }
                if ((PDOInS2[bar] > 0) & (PDOSer[bar] > 0))
                {
                    PDOInSS[bar] = +5;
                }

                if ((ROCInS2[bar] < 0) & (ROCSer[bar] < 0))
                {
                    ROCInSB[bar] = -5;
                }
                if ((ROCInS2[bar] > 0) & (ROCSer[bar] > 0))
                {
                    ROCInSS[bar] = +5;
                }

                if (RSI.Series(bars.Close, 14)[bar] > 70)
                {
                    RSIInS[bar] = +5;
                }
                else
                if (RSI.Series(bars.Close, 14)[bar] < 30)
                {
                    RSIInS[bar] = -5;
                }

                if (StochD.Series(bars, 14, 3)[bar] > 80)
                {
                    STODInS[bar] = +5;
                }
                else
                if (StochD.Series(bars, 14, 3)[bar] < 20)
                {
                    STODInS[bar] = -5;
                }

                if (StochK.Series(bars, 14)[bar] > 80)
                {
                    STOKInS[bar] = +5;
                }
                else
                if (StochK.Series(bars, 14)[bar] < 20)
                {
                    STOKInS[bar] = -5;
                }

                base[bar] = 50 +
                            CCInS[bar] + BOLInSLL[bar] + RSIInS[bar]
                            + STODInS[bar] + MFIInS[bar] + EMVInSB[bar]
                            + EMVInSS[bar] + ROCInSS[bar] + ROCInSB[bar]
                            + STOKInS[bar] + MACDInSS[bar] + MACDInSB[bar]
                            + PDOInSS[bar - 10] + PDOInSB[bar - 10];
            }
        }