private void AlgoSell(List <DailyDataPoint> listOfData, int i, AlgoPicker _algoPicker)
 {
     if (_algoPicker.PickAlgoSell() && _tradeManager.UnFinishedTrade())
     {
         _tradeManager.GetTradeList[_tradeManager.GetTradeList.Count - 1].Sell     = listOfData[i].Close;
         _tradeManager.GetTradeList[_tradeManager.GetTradeList.Count - 1].SellDate = TimeTranslation2(listOfData[i].Date);
     }
 }
 private void AlgoBuy(List <DailyDataPoint> listOfData, int i, AlgoPicker _algoPicker)
 {
     // Last condition is because, can't buy untills tomorrows close
     if (_algoPicker.PickAlgoBuy() && _tradeManager.AddNewTradeOk())
     {
         _tradeManager.AddTrade(new OneTrade {
             Buy = listOfData[i].Close, BuyDate = TimeTranslation2(listOfData[i].Date)
         });
     }
 }
        private void StockChart()
        {
            StockChartGui.LegendLocation = LiveCharts.LegendLocation.None;
            _algoPicker = new AlgoPicker(_dataList, _algoName, _tradeManager);

            CalculateIndicators();
            AlgoSignals();
            PropertiesForStockChart();
            PlotInStockChart();
        }
        private void BuyAndSellSignals(List <DailyDataPoint> listOfData)
        {
            _algoPicker = new AlgoPicker(listOfData, _algoName, _tradeManager);

            // Indicators need to be precalculated for all data before buy and sell signals for the chosen period.
            // Else, there would be a void for no data indicators in the chosen period. Ma200 need 200 days before first data point.
            for (int i = 0; i < listOfData.Count; i++)
            {
                CalcIndicators(listOfData, i);
            }

            for (int i = _startDateIndex; i < _endDateIndex + 1; i++)
            {
                _algoPicker.Index = i;
                AlgoBuy(listOfData, i, _algoPicker);
                AlgoSell(listOfData, i, _algoPicker);
            }
        }