Beispiel #1
0
        static public double CalculateTimeOfOnePips(string sourceDirectory, string symbolName, ResetTimeAnalysis.SideAnalyser side)
        {
            InputData inData = new InputData();

            inData.LoadFromDirectory(sourceDirectory, null);

            double swap = 0;

            if (ResetTimeAnalysis.SideAnalyser.Buy == side)
            {
                swap = inData.SwapBuy;
            }
            if (ResetTimeAnalysis.SideAnalyser.Sell == side)
            {
                swap = inData.SwapSell;
            }

            FuturePredictor fPredictor            = new FuturePredictor(inData.Data);
            List <StratergyParameterRange> ranges = new BuyLimitAndWaitConfigReader().GetRanges(new List <string>());

            StrategyParameter currParam = ranges[0].GetAllParameters().Last();
            IEnumerable <int> buyArray, sellArray;

            ResetTimeAnalysis.CalculatePoints(currParam, inData, out buyArray, out sellArray);

            string            profitSymbol = ForexSuite.SymbolsManager.GetProfitSymbol(symbolName);
            double            coefToUSD    = ForexSuite.QuotesManager.ConvertCurrency(profitSymbol, "USD", DateTime.Now.AddMonths(-7), ForexSuite.SymbolsManager.ValueFromPips(profitSymbol, 1));
            ResetTimeAnalyzer rta          = new ResetTimeAnalyzer(currParam["TP"], 1 / 60d, fPredictor.Bids, fPredictor.Asks, coefToUSD, swap);

            if (side == SideAnalyser.Buy)
            {
                rta.Process(buyArray, null);
            }
            else
            {
                rta.Process(null, sellArray);
            }
            if (rta.RealProfit == 0)
            {
                throw new ApplicationException("RealProfit=0");
            }
            return(rta.AverageTime / rta.RealProfit);
        }
Beispiel #2
0
        public void CompareOneAndMultiplyAnalyses()
        {
            UnilateralTickCollection <int> bids = new UnilateralTickCollection <int>(s_bids);
            UnilateralTickCollection <int> asks = new UnilateralTickCollection <int>(s_asks);

            ResetTimeAnalyzer first  = new ResetTimeAnalyzer(0.01, 1 / 60d, bids, asks, 1);
            ResetTimeAnalyzer second = new ResetTimeAnalyzer(0.01, 1 / 60d, bids, asks, 1);


            first.Process(s_buy, s_sell);
            second.Process(s_buy, s_sell);

            Assert.IsTrue(first.TakeProfit == second.TakeProfit);
            Assert.IsTrue(first.TimeFactor == second.TimeFactor);
            Assert.IsTrue(first.AverageTime == second.AverageTime);
            Assert.IsTrue(first.AverageLoss == second.AverageLoss);
            Assert.IsTrue(first.SigmaTime == second.SigmaTime);
            Assert.IsTrue(first.SigmaLoss == second.SigmaLoss);
            Assert.IsTrue(first.ResettingPercentage == second.ResettingPercentage);

            second.Process(s_buy, s_sell);
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.TakeProfit, second.TakeProfit));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.TimeFactor, second.TimeFactor));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.AverageTime, second.AverageTime));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.AverageLoss, second.AverageLoss));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.SigmaTime, second.SigmaTime, 0.001));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.SigmaLoss, second.SigmaLoss, 0.001));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.ResettingPercentage, second.ResettingPercentage));

            second.Process(s_buy, s_sell);
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.TakeProfit, second.TakeProfit));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.TimeFactor, second.TimeFactor));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.AverageTime, second.AverageTime));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.AverageLoss, second.AverageLoss));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.SigmaTime, second.SigmaTime, 0.001));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.SigmaLoss, second.SigmaLoss, 0.001));
            Assert.IsTrue(NumericalMethods.IsApproximatelyEqual(first.ResettingPercentage, second.ResettingPercentage));
        }