public static analysis.analysisResult Strategy(analysis.workData data, string strategyCode) { GenericStrategy strategy; curStrategyCode = strategyCode; switch (strategyCode) { //Screening case "SCRPRICE": { Parameters p = null; strategy = new PriceScreening(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "SCRMACD01": { Parameters p = new Parameters(12, 26, 9); strategy = new BasicMACD(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Screening(); } case "SCRMACD02": { Parameters p = new Parameters(12, 26, 9); strategy = new MACD_HistogramChanged(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Screening(); } case "SCRDMI": { Parameters p = new Parameters(14, 14); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Screening(); } case "SCRSupport": { Parameters p = new Parameters(30, 0.01); strategy = new SupportScreening(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Screening(); } case "SCRResist": { Parameters p = new Parameters(30, 0.01); strategy = new ResistanceScreening(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Screening(); } case "BUYANDHOLD": { strategy = new BuyAndHoldStrategy(data, strategyCode, fExportData, curStrategyCode); return strategy.Execute(); } #region SMA Strategy case "SMAONLY": { Parameters p = new Parameters(5, 10); strategy = new TwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "EMAONLY": { Parameters p = new Parameters(5, 10); strategy = new TwoEMA(data, strategyCode, fExportData, curStrategyCode,p); return strategy.Execute(); } case "WMAONLY": { strategy = new BasicWMA_5_10(data, strategyCode, fExportData, curStrategyCode); return strategy.Execute(); } case "SMAPRICE": { //strategy = new Price_SMA_5_10(data, strategyCode, fExportData, curStrategyCode); //return strategy.Execute(); Parameters p = new Parameters(50, 100); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "SMAVFIL": { Parameters p = new Parameters(5, 10, 50000); strategy = new TwoSMA_VolumeFilter(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "3SMAPRICE": { Parameters p = new Parameters(5, 10, 20); strategy = new BasicPrice_3SMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "3SMANEW": { Parameters p = new Parameters(10, 20, 30); strategy = new BasicPrice_3SMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "SMARIRW": { Parameters p = new Parameters(5, 10, 20); strategy = new Price_3SMA_Risk_Reward(data, strategyCode, fExportData, curStrategyCode,p); return strategy.Execute(); } case "SMAMID": { Parameters p = new Parameters(20, 50); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); //strategy = new Price_SMA_20_50(data, strategyCode, fExportData, curStrategyCode); //return strategy.Execute(); } case "SMAM50_100": { Parameters p = new Parameters(50, 100); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } #endregion //Statistic case "AVERAGE": { Parameters p = new Parameters(30, -15, 10); strategy = new AverageStrategy(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } //Statistic case "AVERAGE1": { Parameters p = new Parameters(30, -15, 15); strategy = new AverageStrategy(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "RAND": { Parameters p = null; strategy = new RandomStrategy(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } //Statistic case "MARKOV": { Parameters p = null; strategy = new SimpleMarkov(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } #region MACD strategy //MACD strategy case "MACDBAS": { Parameters p = new Parameters(12, 26, 9); strategy = new BasicMACD(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "MACD1": { strategy = new MACD_Line_Cut(data, strategyCode, fExportData, curStrategyCode); return strategy.Execute(); } case "MACD2": { Parameters p = new Parameters(12, 26, 9); strategy = new MACD_HistogramChanged(data, strategyCode, fExportData, curStrategyCode,p); return strategy.Execute(); } case "MACD_CL": { strategy = new MACD_HistogramChanged_CutLoss(data, strategyCode, fExportData, curStrategyCode); return strategy.Execute(); } #endregion //Strategy with DMI indicator case "DMI": { Parameters p = new Parameters(14, 14); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "DMI_CL": { Parameters p = new Parameters(14, 14, -5); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute_CutLoss(); } //Strategy with Stochastic case "STOCHFAST": { Parameters p = new Parameters(14, 3); strategy = new StochasticFast(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } //Strategy with Stochastic case "STOCHSLOW": { Parameters p = new Parameters(15, 5, 3); strategy = new StochasticSlow(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } //Strategy with pattern case "PATERN32": { const int CONSECUTIVE_UP = 4; const int CONSECUTIVE_DOWN = 3; Parameters p = new Parameters(CONSECUTIVE_DOWN, CONSECUTIVE_UP); strategy = new Pattern_Consecutive_UpAndDown(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } #region Hybrid strategy ////Hybrid strategy case "RSI": { int RSI_LOWER_LEVEL = 30; int RSI_UPPER_LEVEL = 70; double[] d = { 14, 26, 12, 9, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL }; Parameters p = new Parameters(d); strategy = new RSI_MACD_Histogram(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "SMASTOCH": { double[] d = { 5, 10, 15, 5, 3 }; Parameters p = new Parameters(d); ; strategy = new SMA_Stochastic(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "MACDSTOC": { double[] d = { 20, 12, 26, 9, 15, 5, 3 }; Parameters p = new Parameters(d); strategy = new MACD_Stochastic(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "MS_BOTTOM": { Parameters p = null; strategy = new MACD_Stochastic_Bottom(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "MS_BOTv1": { Parameters p = null; strategy = new MACD_Stochastic_Bottom_v1(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } case "TEST": { Parameters p = new Parameters(5, 10, 1.5); strategy = new TestStrategy(data, strategyCode, fExportData, curStrategyCode, p); return strategy.Execute(); } #endregion default: return null; } }
public static analysis.analysisResult Strategy(analysis.workData data, string strategyCode) { GenericStrategy strategy; curStrategyCode = strategyCode; switch (strategyCode) { //Screening case "SCRPRICE": { Parameters p = null; strategy = new PriceScreening(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "SCRMACD01": { Parameters p = new Parameters(12, 26, 9); strategy = new BasicMACD(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Screening()); } case "SCRMACD02": { Parameters p = new Parameters(12, 26, 9); strategy = new MACD_HistogramChanged(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Screening()); } case "SCRDMI": { Parameters p = new Parameters(14, 14); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Screening()); } case "SCRSupport": { Parameters p = new Parameters(30, 0.01); strategy = new SupportScreening(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Screening()); } case "SCRResist": { Parameters p = new Parameters(30, 0.01); strategy = new ResistanceScreening(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Screening()); } case "BUYANDHOLD": { strategy = new BuyAndHoldStrategy(data, strategyCode, fExportData, curStrategyCode); return(strategy.Execute()); } #region SMA Strategy case "SMAONLY": { Parameters p = new Parameters(5, 10); strategy = new TwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "EMAONLY": { Parameters p = new Parameters(5, 10); strategy = new TwoEMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "WMAONLY": { strategy = new BasicWMA_5_10(data, strategyCode, fExportData, curStrategyCode); return(strategy.Execute()); } case "SMAPRICE": { //strategy = new Price_SMA_5_10(data, strategyCode, fExportData, curStrategyCode); //return strategy.Execute(); Parameters p = new Parameters(50, 100); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "SMAVFIL": { Parameters p = new Parameters(5, 10, 50000); strategy = new TwoSMA_VolumeFilter(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "3SMAPRICE": { Parameters p = new Parameters(5, 10, 20); strategy = new BasicPrice_3SMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "3SMANEW": { Parameters p = new Parameters(10, 20, 30); strategy = new BasicPrice_3SMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "SMARIRW": { Parameters p = new Parameters(5, 10, 20); strategy = new Price_3SMA_Risk_Reward(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "SMAMID": { Parameters p = new Parameters(20, 50); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); //strategy = new Price_SMA_20_50(data, strategyCode, fExportData, curStrategyCode); //return strategy.Execute(); } case "SMAM50_100": { Parameters p = new Parameters(50, 100); strategy = new PriceTwoSMA(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } #endregion //Statistic case "AVERAGE": { Parameters p = new Parameters(30, -15, 10); strategy = new AverageStrategy(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } //Statistic case "AVERAGE1": { Parameters p = new Parameters(30, -15, 15); strategy = new AverageStrategy(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "RAND": { Parameters p = null; strategy = new RandomStrategy(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } //Statistic case "MARKOV": { Parameters p = null; strategy = new SimpleMarkov(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } #region MACD strategy //MACD strategy case "MACDBAS": { Parameters p = new Parameters(12, 26, 9); strategy = new BasicMACD(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "MACD1": { strategy = new MACD_Line_Cut(data, strategyCode, fExportData, curStrategyCode); return(strategy.Execute()); } case "MACD2": { Parameters p = new Parameters(12, 26, 9); strategy = new MACD_HistogramChanged(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "MACD_CL": { strategy = new MACD_HistogramChanged_CutLoss(data, strategyCode, fExportData, curStrategyCode); return(strategy.Execute()); } #endregion //Strategy with DMI indicator case "DMI": { Parameters p = new Parameters(14, 14); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "DMI_CL": { Parameters p = new Parameters(14, 14, -5); strategy = new BasicDMI(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute_CutLoss()); } //Strategy with Stochastic case "STOCHFAST": { Parameters p = new Parameters(14, 3); strategy = new StochasticFast(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } //Strategy with Stochastic case "STOCHSLOW": { Parameters p = new Parameters(15, 5, 3); strategy = new StochasticSlow(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } //Strategy with pattern case "PATERN32": { const int CONSECUTIVE_UP = 4; const int CONSECUTIVE_DOWN = 3; Parameters p = new Parameters(CONSECUTIVE_DOWN, CONSECUTIVE_UP); strategy = new Pattern_Consecutive_UpAndDown(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } #region Hybrid strategy ////Hybrid strategy case "RSI": { int RSI_LOWER_LEVEL = 30; int RSI_UPPER_LEVEL = 70; double[] d = { 14, 26, 12, 9, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL }; Parameters p = new Parameters(d); strategy = new RSI_MACD_Histogram(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "SMASTOCH": { double[] d = { 5, 10, 15, 5, 3 }; Parameters p = new Parameters(d);; strategy = new SMA_Stochastic(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "MACDSTOC": { double[] d = { 20, 12, 26, 9, 15, 5, 3 }; Parameters p = new Parameters(d); strategy = new MACD_Stochastic(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "MS_BOTTOM": { Parameters p = null; strategy = new MACD_Stochastic_Bottom(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "MS_BOTv1": { Parameters p = null; strategy = new MACD_Stochastic_Bottom_v1(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } case "TEST": { Parameters p = new Parameters(5, 10, 1.5); strategy = new TestStrategy(data, strategyCode, fExportData, curStrategyCode, p); return(strategy.Execute()); } #endregion default: return(null); } }