Ejemplo n.º 1
0
        public async Task Ema_MA_Success()
        {
            // Arrange
            var loggerMock = Mock.Of <ILogger <CsvLoader> >();
            var parser     = new CsvLoader(loggerMock);
            var fileH1     = Path.Combine(Directory.GetCurrentDirectory(), "RTS-12.20_H1.csv");
            var bars       = await parser.LoadBars(fileH1);

            var chartManager = new ChartManager(bars);

            chartManager.Finish();
            var ema = new MovingAverage(chartManager.Chart, 50);

            // Act
            var emaValues = ema.EmaValue();


            // Assert
            bars.Should().NotBeEmpty();
            bars.Should().HaveCount(863);
        }
        public override void Run(IChart chart)
        {
            base.Run(chart);

            var movingAverage = new MovingAverage(chart, _period);

            var ema = movingAverage.EmaValue();

            if (ema.Length == 0)
            {
                return;
            }

            if (_tradeManager.GetOrders(_magicNumber).Any())
            {
                ClosePosition(ema);
            }

            if (!_tradeManager.GetOrders(_magicNumber).Any())
            {
                OpenPosition(ema);
            }
        }