Exemplo n.º 1
0
        /// <summary>
        /// Duplicates a filter.
        /// </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 addedSlot = AddOpenFilter();
                    Slot[addedSlot] = 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;
                }
            }
        }
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>
        /// Removes all close filters from the strategy.
        /// </summary>
        public void RemoveAllCloseFilters()
        {
            Data.Log("Removing All Closed Filters");

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

            // Copy all slots except the close filters.
            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot] = aIndSlotOld[slot];
            }
        }
Exemplo n.º 5
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;
                }
            }
        }
Exemplo n.º 6
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[] aIndSlotOld = (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] = aIndSlotOld[slot];
            }

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

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

            return;
        }