Exemplo n.º 1
0
        public static void TestDaysHeightsAlternation(string toolName)
        {
            const int maxContinuationLength = 5;
            const int maxAverageDaysLength  = 20;

            var repository = new HistoryRepository(toolName, false);

            var output = new List <string>();

            var headers = new List <string> {
                "Length of average interval", "Continuation length", "Alternates count", "Continuation count", "Alternates percent"
            };
            var tableOutput = new List <List <string> >();

            for (int averageDaysLength = 5; averageDaysLength <= maxAverageDaysLength; ++averageDaysLength)
            {
                output.Add("Length of average interval: " + averageDaysLength);
                output.Add("");
                for (int continuationLength = 1; continuationLength < maxContinuationLength; ++continuationLength)
                {
                    var     current          = ProbabilityAnalyzer.TesCandlesHightAlternation(repository.Days.Select(day => day.Params).ToList(), continuationLength, averageDaysLength);
                    decimal alternatePercent = Math.Round(current.Item1 / ((decimal)current.Item1 + current.Item2), 2);
                    output.Add("Continuation length: " + continuationLength);
                    output.Add("Alternates count: " + current.Item1 + ", continuation count: " + current.Item2 + ", alternates percent: " + alternatePercent);
                    output.Add("");
                    tableOutput.Add(new List <string> {
                        averageDaysLength.ToString(), continuationLength.ToString(), current.Item1.ToString(), current.Item2.ToString(), alternatePercent.ToString(new CultureInfo("en-us"))
                    });
                }
                output.Add("");
            }
            TablesWriter.PrintExcel("AlternationTest " + toolName + ".xlsx", headers, tableOutput);
            File.WriteAllLines("AlternationTest " + toolName + ".txt", output);
        }
Exemplo n.º 2
0
        public static void TestCorrectedExtremumsFast(string toolName, int startStop, int endStop, int stopStep,
                                                      int startTrStop, int endTrStop, int trStopStep, int pegTopSize)
        {
            var repository = new HistoryRepository(toolName, false);

            var headers = new List <string> {
                "Stop", "Trailing stop", "Breakeven size"
            };

            headers.AddRange(TradesResult.GetHeaders());
            var table = new List <List <string> >();

            for (int stop = startStop; stop <= endStop; stop += stopStep)
            {
                for (int trStop = Math.Max(startTrStop, stop); trStop <= endTrStop; trStop += trStopStep)
                {
                    for (double breakevenSize = 0.0; breakevenSize <= 0.61; breakevenSize += 0.2)
                    {
                        var strat = new CorrectedExtremumStrategy(stop, pegTopSize, breakevenSize, trStop);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop.ToString("D4") + "_" + trStop.ToString("D4") + "_" +
                                         ((int)(100 * breakevenSize)).ToString("D2") + ".txt");

                        var currentText = new List <string> {
                            stop.ToString(), trStop.ToString(), breakevenSize.ToEnString()
                        };
                        currentText.AddRange(result.GetTableRow());
                        table.Add(currentText);
                    }
                }
            }

            TablesWriter.PrintExcel("out.xlsx", headers, table);
        }