Example #1
0
 public static CompanyPatternResults Create(CandleStickPattern pattern, Record companyRecord, List <PatternScanResults> scanResults, List <CandleStick> candleSticks, bool containsSelectedPattern)
 => new CompanyPatternResults
 {
     PatternScanResults      = scanResults,
     CompanyRecord           = companyRecord,
     ContainsSelectedPattern = containsSelectedPattern,
     CandleSticks            = candleSticks,
     Pattern = pattern
 };
Example #2
0
 public void SetCandlestickFlag(CandleStickPattern flag, bool isSet)
 {
     if (isSet)
     {
         CandlestickFlags |= flag;
     }
     else
     {
         CandlestickFlags &= ~flag;
     }
 }
        private async Task <List <PatternScanResults> > GetPatternScanResultsAsync(List <CandleStick> candleSticks, CandleStickPattern patternToScanFor)
        {
            List <PatternScanResults> patternScanResults = new List <PatternScanResults>();

            int[] patternIndexLoc = new int[candleSticks.Count()];
            int   out1            = 0;
            int   out2            = 0;

            object[] parameters = new object[] { 1, candleSticks.Count() - 1, candleSticks.Select(x => (float)x.Open).ToArray(),
                                                 candleSticks.Select(x => (float)x.High).ToArray(), candleSticks.Select(x => (float)x.Low).ToArray(), candleSticks.Select(x => (float)x.Close).ToArray(), 0, out1, out2, patternIndexLoc };

            Type thisType = typeof(TicTacTec.TA.Library.Core);

            try
            {
                MethodInfo theMethod = thisType.GetMethod("CdlMorningStar");
                var        result    = theMethod.Invoke(this, parameters);
            }
            catch (AmbiguousMatchException)
            {
                MethodInfo[] methods = thisType.GetMethods();

                var result = methods[0].Invoke(this, parameters);

                if ((RetCode)result == RetCode.Success)
                {
                    out1 = (int)parameters[7];
                    out2 = (int)parameters[8];
                }
            }

            //Create PatternScanResults
            int iterator = 0;

            foreach (var candle in candleSticks)
            {
                var isPatternTriggered = patternIndexLoc[iterator] != 0 ? true : false;
                var patternScanResult  = PatternScanResults.Create(candle, isPatternTriggered);

                if (isPatternTriggered)
                {
                    patternScanResults.Add(patternScanResult);
                }

                iterator++;
            }

            return(patternScanResults);
        }
Example #4
0
 public bool GetCandlestickFlag(CandleStickPattern flag)
 {
     return((CandlestickFlags &= flag) == flag);
 }