Forex_Strategy_Builder.Actions.Calculate C# (CSharp) Метод

Calculate() приватный Метод

Calculates the strategy.
private Calculate ( bool recalcIndicators ) : void
recalcIndicators bool true - to recalculate all the indicators.
Результат void
        void Calculate(bool recalcIndicators)
        {
            bool isUPBVChanged = Data.Strategy.AdjustUsePreviousBarValue();

            // Calculates the indicators by slots if it's necessary
            if (recalcIndicators)
                foreach(IndicatorSlot indSlot in Data.Strategy.Slot)
                {
                    string    indicatorName = indSlot.IndicatorName;
                    SlotTypes slotType      = indSlot.SlotType;
                    Indicator indicator     = Indicator_Store.ConstructIndicator(indicatorName, slotType);

                    indicator.IndParam = indSlot.IndParam;

                    indicator.Calculate(slotType);

                    indSlot.IndicatorName  = indicator.IndicatorName;
                    indSlot.IndParam       = indicator.IndParam;
                    indSlot.Component      = indicator.Component;
                    indSlot.SeparatedChart = indicator.SeparatedChart;
                    indSlot.SpecValue      = indicator.SpecialValues;
                    indSlot.MinValue       = indicator.SeparatedChartMinValue;
                    indSlot.MaxValue       = indicator.SeparatedChartMaxValue;
                    indSlot.IsDefined      = true;
                }

            // Searches the indicators' components to determine the Data.FirstBar
            Data.FirstBar = Data.Strategy.SetFirstBar();

            // Logging
            Data.Log("Calculate the strategy");

            // Calculates the backtest
            Backtester.Calculate();
            Backtester.CalculateAccountStats();

            Data.IsResult = true;
            if (isUPBVChanged) RebuildStrategyLayout();
            smallIndicatorChart.InitChart();
            smallIndicatorChart.Invalidate();
            smallBalanceChart.SetChartData();
            smallBalanceChart.InitChart();
            smallBalanceChart.Invalidate();
            SetupJournal();
            infpnlAccountStatistics.Update(
                Backtester.AccountStatsParam,
                Backtester.AccountStatsValue,
                Backtester.AccountStatsFlags,
                Language.T("Account Statistics"));

            return;
        }
Actions