コード例 #1
0
ファイル: KNN_Generator6.cs プロジェクト: grc-stk/NT
        //public event PropertyChangedEventHandler PropertyChanged;

        protected void OnIndicatorChanged(IndicatorEnum my_enum)
        {
            switch (my_enum)
            {
            case IndicatorEnum.indicator_MACD:
                Param1 = 12;
                Param2 = 26;
                Param3 = 9;
                break;

            case IndicatorEnum.indicator_RSI:
                Param1 = 14;
                Param2 = 3;
                Param3 = -1;
                break;

            case IndicatorEnum.indicator_GREG:
                Param1 = 1;
                Param2 = -1;
                Param3 = -1;
                break;

            default:
                Param1 = -1;
                Param2 = -1;
                Param3 = -1;
                break;
            }
        }
コード例 #2
0
ファイル: Strategy_Common.cs プロジェクト: grc-stk/NT
        // map the MyEnum type to "Friendly" string
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            IndicatorEnum enumVal = (IndicatorEnum)Enum.Parse(typeof(IndicatorEnum), value.ToString());

            switch (enumVal)
            {
            case IndicatorEnum.indicator_MACD:
                return("MACD");

            case IndicatorEnum.indicator_RSI:
                return("RSI");

            case IndicatorEnum.indicator_BOLLINGER:
                return("BOLLINGER");

            case IndicatorEnum.indicator_STOCHASTIC:
                return("STOCHASTIC");

            case IndicatorEnum.indicator_STOCHASTIC_RSI:
                return("STOCH_RSI");

            case IndicatorEnum.indicator_GREG:
                return("GREG");
            }
            return(string.Empty);
        }
コード例 #3
0
        public void PopulateParamatersForIndicator(IndicatorEnum this_ind)
        {
            String param_string = "-1;-1;-1";

            switch (this_ind)
            {
            case IndicatorEnum.indicator_MACD:
                param_string = MACD_param_string;
                break;

            case IndicatorEnum.indicator_RSI:
                param_string = RSI_param_string;
                break;

            case IndicatorEnum.indicator_BOLLINGER:
                param_string = BOLL_param_string;
                break;

            case IndicatorEnum.indicator_STOCHASTIC:
                param_string = STOCH_param_string;
                break;

            case IndicatorEnum.indicator_STOCHASTIC_RSI:
                param_string = STOCH_RSI_param_string;
                break;

            default:
                break;
            }

            List <int> param_list = ParseParamString(param_string);

            if (param_list.Count == 3)
            {
                Param1 = param_list[0];
                Param2 = param_list[1];
                Param3 = param_list[2];
            }
        }
コード例 #4
0
ファイル: Trade_Scanner2.cs プロジェクト: grc-stk/NT
        private Indicator_FutureValueChange_Pair GetIndicatorValue(IndicatorEnum indicator, int bar_index, int day_index, DateTime date_to_process)
        {
            double indicator_value = 0.0;

            switch (indicator)
            {
            case IndicatorEnum.indicator_MACD:
                indicator_value = MACD(BarsArray[bar_index], Param1, Param2, Param3)[day_index];      //get the indicator val from n days ago
                break;

            case IndicatorEnum.indicator_RSI:
                indicator_value = RSI(BarsArray[bar_index], Param1, Param2)[day_index];      //get the indicator val from n days ago
                break;

            case IndicatorEnum.indicator_BOLLINGER:
                double upper_band    = Bollinger(BarsArray[bar_index], (double)Param1, Param2).Upper[day_index];   //get the indicator val from n days ago
                double middle_band   = Bollinger(BarsArray[bar_index], (double)Param1, Param2).Middle[day_index];  //get the indicator val from n days ago
                double lower_band    = Bollinger(BarsArray[bar_index], (double)Param1, Param2).Lower[day_index];   //get the indicator val from n days ago
                double current_price = Closes[bar_index][day_index];
                double diff          = current_price - middle_band;
                double band_range    = upper_band - middle_band;
                indicator_value = diff / band_range;     //how far current price is from the middle band (-1.0 means we're at the lower band, +1 means we're at the upper band)
                break;

            case IndicatorEnum.indicator_STOCHASTIC:
                //use the "D" value
                indicator_value = Stochastics(BarsArray[bar_index], Param1, Param2, Param3).D[day_index];      //get the indicator val from n days ago
                break;

            case IndicatorEnum.indicator_STOCHASTIC_RSI:
                indicator_value = StochRSI(BarsArray[bar_index], Param1)[day_index];      //get the indicator val from n days ago
                break;

            case IndicatorEnum.indicator_GREG:
                indicator_value = -999.999;     // GregIndicator1(BarsArray[BarIndex], (float)Param1)[FutureValueDaysToLookAhead];  //get the indicator val from n days ago
                break;

            default:
                indicator_value = -999.99;
                break;
            }

            if (double.IsNaN(indicator_value))
            {
                indicator_value = 0.0;
            }

            //S&P500 is always BarIndex 1
            int    SP500_Bar_Index           = 1;
            double SP500_future_price        = Closes[SP500_Bar_Index][0];
            double SP500_start_price         = Closes[SP500_Bar_Index][day_index];
            double SP500_future_price_change = ((SP500_future_price / SP500_start_price) - 1.0) * 100.0;

            double future_price        = Closes[bar_index][0];
            double start_price         = Closes[bar_index][day_index];
            double future_price_change = ((future_price / start_price) - 1.0) * 100.0;

            double price_change_compared_to_SP500 = future_price_change - SP500_future_price_change;

            Indicator_FutureValueChange_Pair indicator_pair = new Indicator_FutureValueChange_Pair();

            indicator_pair.Date              = date_to_process;
            indicator_pair.Price             = Convert.ToSingle(start_price);
            indicator_pair.Indicator         = Convert.ToSingle(indicator_value);
            indicator_pair.FutureValueChange = Convert.ToSingle(price_change_compared_to_SP500); // future_price_change;
            indicator_pair.SP500_Price       = Convert.ToSingle(SP500_start_price);

            return(indicator_pair);
        }
コード例 #5
0
        public void BuildIndicatorAndDescriptionStrings(IndicatorEnum this_ind) //, int Param1, int Param2, int Param3)
        {
            switch (this_ind)
            {
            case IndicatorEnum.indicator_MACD:
                if (Sanitize == false)
                {
                    description = "MACD";
                }
                else
                {
                    description = "M";
                }
                indicator   = description;
                description = description + "(" + Param1.ToString() + "-" + Param2.ToString() + "-" + Param3.ToString() + ")";
                break;

            case IndicatorEnum.indicator_RSI:
                if (Sanitize == false)
                {
                    description = "RSI";
                }
                else
                {
                    description = "R";
                }
                indicator   = description;
                description = description + "(" + Param1.ToString() + "-" + Param2.ToString() + ")";
                break;

            case IndicatorEnum.indicator_BOLLINGER:
                if (Sanitize == false)
                {
                    description = "BOLL";
                }
                else
                {
                    description = "B";
                }
                indicator   = description;
                description = description + "(" + Param1.ToString() + "-" + Param2.ToString() + ")";
                break;

            case IndicatorEnum.indicator_STOCHASTIC:
                if (Sanitize == false)
                {
                    description = "STOCH";
                }
                else
                {
                    description = "S";
                }
                indicator   = description;
                description = description + "(" + Param1.ToString() + "-" + Param2.ToString() + "-" + Param3.ToString() + ")";
                break;

            case IndicatorEnum.indicator_STOCHASTIC_RSI:
                if (Sanitize == false)
                {
                    description = "STOCH_RSI";
                }
                else
                {
                    description = "SR";
                }
                indicator   = description;
                description = description + "(" + Param1.ToString() + ")";
                break;

            default:
                description = "Unknown";
                indicator   = description;
                break;
            }

            description = description + " - " + FutureValueDaysToLookAhead.ToString();

            if (Sanitize == false)
            {
                description = description + " days";
            }

            description = description + " - " + uid;
        }