/// <summary>
 /// Public constructor
 /// </summary>
 public IndicatorComp()
 {
     compName           = "Not defined";
     dataType           = IndComponentType.NotDefined;
     chartType          = IndChartType.NoChart;
     chartColor         = Color.Red;
     firstBar           = 0;
     previous           = 0;
     isDynInfo          = true;
     values             = new double[] { };
     posPriceDependence = PositionPriceDependence.None;
 }
 /// <summary>
 /// Public constructor
 /// </summary>
 public IndicatorComp()
 {
     compName   = "Not defined";
     dataType   = IndComponentType.NotDefined;
     chartType  = IndChartType.NoChart;
     chartColor = Color.Red;
     firstBar   = 0;
     previous   = 0;
     isDynInfo  = true;
     values     = new double[] { };
     posPriceDependence = PositionPriceDependence.None;
 }
Exemple #3
0
 private bool IsSignalComponent(IndComponentType componentType)
 {
     return(componentType == IndComponentType.AllowOpenLong ||
            componentType == IndComponentType.AllowOpenShort ||
            componentType == IndComponentType.CloseLongPrice ||
            componentType == IndComponentType.ClosePrice ||
            componentType == IndComponentType.CloseShortPrice ||
            componentType == IndComponentType.ForceClose ||
            componentType == IndComponentType.ForceCloseLong ||
            componentType == IndComponentType.ForceCloseShort ||
            componentType == IndComponentType.OpenClosePrice ||
            componentType == IndComponentType.OpenLongPrice ||
            componentType == IndComponentType.OpenPrice ||
            componentType == IndComponentType.OpenShortPrice);
 }
Exemple #4
0
        private void ShowResult(IIndicator indicator)
        {
            Console.WriteLine(indicator.ToString());
            Console.WriteLine("Slot type: {0}", indicator.IndParam.SlotType);
            Console.WriteLine("Logic rule: {0}", indicator.IndParam.ListParam[0].Text);

            foreach (IndicatorComp component in indicator.Component)
            {
                if (component == null)
                {
                    continue;
                }
                IndComponentType type = component.DataType;
                int    bars           = component.Value.Length;
                string name           = component.CompName;
                double value          = component.Value[bars - 1];

                double val    = Math.Abs(value);
                string format = val < 10 ? "F5" : val < 100 ? "F4" : val < 1000 ? "F3" : val < 10000 ? "F2" : val < 100000 ? "F1" : "F0";
                if (!component.ShowInDynInfo)
                {
                    continue;
                }
                if (type == IndComponentType.AllowOpenLong || type == IndComponentType.AllowOpenShort ||
                    type == IndComponentType.ForceClose || type == IndComponentType.ForceCloseLong ||
                    type == IndComponentType.ForceCloseShort)
                {
                    Console.WriteLine("{0}: {1}   ", name, (value < 1 ? "No" : "Yes"));
                }
                else
                {
                    Console.WriteLine("{0}: {1}", name, value.ToString(format));
                }
            }

            Console.WriteLine();
        }
        /// <summary>
        /// Adjusts the closing direction.
        /// </summary>
        private TradeDirection GetClosingDirection(TradeDirection baseDirection, IndComponentType compDataType)
        {
            TradeDirection newDirection = baseDirection;

            if (compDataType == IndComponentType.ForceClose)
            {
                newDirection = TradeDirection.Both;
            }
            else if (compDataType == IndComponentType.ForceCloseShort)
            {
                if (baseDirection == TradeDirection.None)
                    newDirection = TradeDirection.Long;
                else if (baseDirection == TradeDirection.Short)
                    newDirection = TradeDirection.Both;
            }
            else if (compDataType == IndComponentType.ForceCloseLong)
            {
                if (baseDirection == TradeDirection.None)
                    newDirection = TradeDirection.Short;
                else if (baseDirection == TradeDirection.Long)
                    newDirection = TradeDirection.Both;
            }

            return newDirection;
        }
 private bool IsSignalComponent(IndComponentType componentType)
 {
     return componentType == IndComponentType.AllowOpenLong ||
     componentType == IndComponentType.AllowOpenShort ||
     componentType == IndComponentType.CloseLongPrice ||
     componentType == IndComponentType.ClosePrice ||
     componentType == IndComponentType.CloseShortPrice ||
     componentType == IndComponentType.ForceClose ||
     componentType == IndComponentType.ForceCloseLong ||
     componentType == IndComponentType.ForceCloseShort ||
     componentType == IndComponentType.OpenClosePrice ||
     componentType == IndComponentType.OpenLongPrice ||
     componentType == IndComponentType.OpenPrice ||
     componentType == IndComponentType.OpenShortPrice;
 }