Log() public static method

Saves a text line in the log file.
public static Log ( string logLine ) : void
logLine string
return void
Exemplo n.º 1
0
        /// <summary>
        /// Duplicates an logic condition.
        /// </summary>
        public void DuplicateFilter(int slotToDuplicate)
        {
            Data.Log("Duplicate a Filter");

            if (Slot[slotToDuplicate].SlotType == SlotTypes.OpenFilter && OpenFilters < MaxOpenFilters ||
                Slot[slotToDuplicate].SlotType == SlotTypes.CloseFilter && CloseFilters < MaxCloseFilters)
            {
                IndicatorSlot tempSlot = Slot[slotToDuplicate].Clone();

                if (Slot[slotToDuplicate].SlotType == SlotTypes.OpenFilter)
                {
                    int iAddedslot = AddOpenFilter();
                    Slot[iAddedslot] = tempSlot.Clone();
                }

                if (Slot[slotToDuplicate].SlotType == SlotTypes.CloseFilter)
                {
                    int addedslot = AddCloseFilter();
                    Slot[addedslot] = tempSlot.Clone();
                }

                // Sets the slot numbers.
                for (int slot = 0; slot < Slots; slot++)
                {
                    indicatorSlot[slot].SlotNumber = slot;
                }
            }

            return;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new Close Filter to the strategy.
        /// </summary>
        /// <returns>The number of new Close Filter Slot.</returns>
        public int AddCloseFilter()
        {
            Data.Log("Adding a Close Filter");

            closeFilters++;
            IndicatorSlot[] aIndSlotOld = (IndicatorSlot[])indicatorSlot.Clone();
            indicatorSlot = new IndicatorSlot[Slots];
            int newSlotNumb = Slots - 1; // The number of new close filter slot.

            // Copy all old slots.
            for (int slot = 0; slot < newSlotNumb; slot++)
            {
                indicatorSlot[slot] = aIndSlotOld[slot];
            }

            // Create the new slot.
            indicatorSlot[newSlotNumb]          = new IndicatorSlot();
            indicatorSlot[newSlotNumb].SlotType = SlotTypes.CloseFilter;

            // Sets the slot numbers.
            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot].SlotNumber = slot;
            }

            return(newSlotNumb);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a new Open Filter to the strategy.
        /// </summary>
        /// <returns>The number of new Open Filter Slot.</returns>
        public int AddOpenFilter()
        {
            Data.Log("Adding an Open Filter");

            OpenFilters++;
            IndicatorSlot[] aIndSlotOld = (IndicatorSlot[])indicatorSlot.Clone();
            indicatorSlot = new IndicatorSlot[Slots];
            int newSlotNumb = OpenFilters; // The number of new open filter slot.

            // Copy the open slot and all old open filters.
            for (int slot = 0; slot < newSlotNumb; slot++)
            {
                indicatorSlot[slot] = aIndSlotOld[slot];
            }

            // Copy the close slot and all close filters.
            for (int slot = newSlotNumb + 1; slot < Slots; slot++)
            {
                indicatorSlot[slot] = aIndSlotOld[slot - 1];
            }

            // Create the new slot.
            indicatorSlot[newSlotNumb]          = new IndicatorSlot();
            indicatorSlot[newSlotNumb].SlotType = SlotTypes.OpenFilter;

            // Sets the slot numbers.
            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot].SlotNumber = slot;
            }

            return(newSlotNumb);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Calculates the strategy.
        /// </summary>
        /// <param name="recalcIndicators">true - to recalculate all the indicators.</param>
        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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes all close filters from the strategy.
        /// </summary>
        public void RemoveAllCloseFilters()
        {
            Data.Log("Removing All Closed Filters");

            CloseFilters = 0;
            IndicatorSlot[] indSlotOld = (IndicatorSlot[])indicatorSlot.Clone();
            indicatorSlot = new IndicatorSlot[Slots];

            // Copy all slots except the close filters.
            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot] = indSlotOld[slot];
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Moves a filter downwards.
        /// </summary>
        public void MoveFilterDownwards(int slotToMove)
        {
            Data.Log("Move a Filter Downwards");

            if (slotToMove < Slots - 1 && Slot[slotToMove].SlotType == Slot[slotToMove + 1].SlotType)
            {
                IndicatorSlot tempSlot = Slot[slotToMove + 1].Clone();
                Slot[slotToMove + 1] = Slot[slotToMove].Clone();
                Slot[slotToMove]     = tempSlot.Clone();

                // Sets the slot numbers.
                for (int slot = 0; slot < Slots; slot++)
                {
                    indicatorSlot[slot].SlotNumber = slot;
                }
            }

            return;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Removes a filter from the strategy.
        /// </summary>
        public void RemoveFilter(int slotToRemove)
        {
            if (Slot[slotToRemove].SlotType != SlotTypes.OpenFilter &&
                Slot[slotToRemove].SlotType != SlotTypes.CloseFilter)
            {
                return;
            }

            Data.Log("Remove a Filter");

            if (slotToRemove < CloseSlot)
            {
                OpenFilters--;
            }
            else
            {
                CloseFilters--;
            }
            IndicatorSlot[] indSlotOld = (IndicatorSlot[])indicatorSlot.Clone();
            indicatorSlot = new IndicatorSlot[Slots];

            // Copy all filters before this that has to be removed.
            for (int slot = 0; slot < slotToRemove; slot++)
            {
                indicatorSlot[slot] = indSlotOld[slot];
            }

            // Copy all filters after this that has to be removed.
            for (int slot = slotToRemove; slot < Slots; slot++)
            {
                indicatorSlot[slot] = indSlotOld[slot + 1];
            }

            // Sets the slot numbers.
            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot].SlotNumber = slot;
            }

            return;
        }