Beispiel #1
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);
        }
        /// <summary>
        /// Adds a new Close Filter to the strategy.
        /// </summary>
        /// <returns>The number of new Close Filter Slot.</returns>
        public int AddCloseFilter()
        {
            CloseFilters++;
            var aIndSlotOld = (IndicatorSlot[])Slot.Clone();

            Slot = 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++)
            {
                Slot[slot] = aIndSlotOld[slot];
            }

            // Create the new slot.
            Slot[newSlotNumb] = new IndicatorSlot {
                SlotType = SlotTypes.CloseFilter
            };

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

            return(newSlotNumb);
        }
Beispiel #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);
        }
Beispiel #4
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;
        }
        /// <summary>
        /// Removes all close filters from the strategy.
        /// </summary>
        public void RemoveAllCloseFilters()
        {
            CloseFilters = 0;
            var indSlotOld = (IndicatorSlot[])Slot.Clone();

            Slot = new IndicatorSlot[Slots];

            // Copy all slots except the close filters.
            for (int slot = 0; slot < Slots; slot++)
            {
                Slot[slot] = indSlotOld[slot];
            }
        }
        /// <summary>
        /// Creates a strategy
        /// </summary>
        private void CreateStrategy(int openFilters, int closeFilters)
        {
            StrategyName = "Unnamed";
            OpenFilters  = openFilters;
            CloseFilters = closeFilters;
            Slot         = new IndicatorSlot[Slots];

            for (int slot = 0; slot < Slots; slot++)
            {
                Slot[slot] = new IndicatorSlot {
                    SlotNumber = slot, SlotType = GetSlotType(slot)
                };
            }
        }
Beispiel #7
0
        /// <summary>
        /// Creates a strategy
        /// </summary>
        void CreateStrategy(int openFilters, int closeFilters)
        {
            strategyName      = "Unnamed";
            this.openFilters  = openFilters;
            this.closeFilters = closeFilters;
            indicatorSlot     = new IndicatorSlot[Slots];

            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot]            = new IndicatorSlot();
                indicatorSlot[slot].SlotNumber = slot;
                indicatorSlot[slot].SlotType   = GetSlotType(slot);
            }

            return;
        }
Beispiel #8
0
        /// <summary>
        /// Moves a filter downwards.
        /// </summary>
        public void MoveFilterDownwards(int slotToMove)
        {
            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;
        }
        /// <summary>
        /// Moves a filter upwards.
        /// </summary>
        public void MoveFilterUpwards(int slotToMove)
        {
            if (slotToMove <= 1 || Slot[slotToMove].SlotType != Slot[slotToMove - 1].SlotType)
            {
                return;
            }
            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++)
            {
                Slot[slot].SlotNumber = slot;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Moves a filter upwards.
        /// </summary>
        public void MoveFilterUpwards(int slotToMove)
        {
            Data.Log("Move a Filter Upwards");

            if (slotToMove > 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;
        }
        /// <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;
            }

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

            Slot = new IndicatorSlot[Slots];

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

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

            // Sets the slot numbers.
            for (int slot = 0; slot < Slots; slot++)
            {
                Slot[slot].SlotNumber = slot;
            }
        }
Beispiel #12
0
        /// <summary>
        /// Creates a strategy
        /// </summary>
        private void CreateStrategy(int openFilters, int closeFilters)
        {
            StrategyName = "Unnamed";
            OpenFilters = openFilters;
            CloseFilters = closeFilters;
            Slot = new IndicatorSlot[Slots];

            for (int slot = 0; slot < Slots; slot++)
            {
                Slot[slot] = new IndicatorSlot {SlotNumber = slot, SlotType = GetSlotType(slot)};
            }
        }
Beispiel #13
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;

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

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

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

            // Sets the slot numbers.
            for (int slot = 0; slot < Slots; slot++)
                Slot[slot].SlotNumber = slot;
        }
Beispiel #14
0
        /// <summary>
        /// Removes all close filters from the strategy.
        /// </summary>
        public void RemoveAllCloseFilters()
        {
            CloseFilters = 0;
            var indSlotOld = (IndicatorSlot[]) Slot.Clone();
            Slot = new IndicatorSlot[Slots];

            // Copy all slots except the close filters.
            for (int slot = 0; slot < Slots; slot++)
                Slot[slot] = indSlotOld[slot];
        }
        /// <summary>
        /// Creates a strategy
        /// </summary>
        void CreateStrategy(int openFilters, int closeFilters)
        {
            strategyName = "Unnamed";
            this.openFilters  = openFilters;
            this.closeFilters = closeFilters;
            indicatorSlot = new IndicatorSlot[Slots];

            for (int slot = 0; slot < Slots; slot++)
            {
                indicatorSlot[slot] = new IndicatorSlot();
                indicatorSlot[slot].SlotNumber = slot;
                indicatorSlot[slot].SlotType   = GetSlotType(slot);
            }

            return;
        }
Beispiel #16
0
        /// <summary>
        /// Adds a new Close Filter to the strategy.
        /// </summary>
        /// <returns>The number of new Close Filter Slot.</returns>
        public int AddCloseFilter()
        {
            CloseFilters++;
            var aIndSlotOld = (IndicatorSlot[]) Slot.Clone();
            Slot = 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++)
                Slot[slot] = aIndSlotOld[slot];

            // Create the new slot.
            Slot[newSlotNumb] = new IndicatorSlot {SlotType = SlotTypes.CloseFilter};

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

            return newSlotNumb;
        }
Beispiel #17
0
        /// <summary>
        /// Adds a new Open Filter to the strategy.
        /// </summary>
        /// <returns>The number of new Open Filter Slot.</returns>
        public int AddOpenFilter()
        {
            OpenFilters++;
            var aIndSlotOld = (IndicatorSlot[]) Slot.Clone();
            Slot = 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++)
                Slot[slot] = aIndSlotOld[slot];

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

            // Create the new slot.
            Slot[newSlotNumb] = new IndicatorSlot {SlotType = SlotTypes.OpenFilter};

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

            return newSlotNumb;
        }
        /// <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;
        }