override protected void StrategyExecute() { MACD_HistogramRule rule = new MACD_HistogramRule(data.Close, parameters[0], parameters[1], parameters[2]); double cutlosslevel = parameters[3]; double takeprofitlevel = parameters[4]; for (int idx = rule.macd.FirstValidValue; idx < data.Close.Count - 1; idx++) { if (rule.isValid_forBuy(idx)) { BuyAtClose(idx); } if (rule.isValid_forSell(idx)) { SellAtClose(idx); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) { SellCutLoss(idx); } if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) { SellTakeProfit(idx); } } }
override protected void StrategyExecute() { int fast_macd = (int)parameters[0]; int slow_macd = (int)parameters[1]; int signal_macd = (int)parameters[2]; int rsi_period = (int)parameters[3]; int RSI_LOWER_LEVEL = (int)parameters[4]; int RSI_UPPER_LEVEL = (int)parameters[5]; int cutlosslevel = (int)parameters[6]; int takeprofitlevel = (int)parameters[7]; //double delta = 0, lastDelta = 0; //DataSeries line1 = Indicators.RSI.Series(data.Close, rsi_period, ""); //Indicators.MACD macd = Indicators.MACD.Series(data.Close, fast_macd, slow_macd, signal_macd, ""); //DataSeries hist = macd.HistSeries; MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd); BasicRSI_Rule rsirule = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL); for (int idx = 1; idx < data.Close.Count; idx++) { if (rsirule.isValid_forBuy(idx) || macdrule.isValid_forBuy(idx)) { BuyAtClose(idx); } if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) { SellAtClose(idx); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) { SellCutLoss(idx); } if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) { SellTakeProfit(idx); } } //for (int idx = 1; idx < line1.Count; idx++) //{ // delta = (hist[idx] - hist[idx - 1]); // if (line1[idx] < RSI_LOWER_LEVEL && delta > 0 && lastDelta < 0) // BuyAtClose(idx); // if (is_bought) // if ((delta < 0 && lastDelta > 0) || line1[idx] > RSI_UPPER_LEVEL) // SellAtClose(idx); // if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) // SellCutLoss(idx); // if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) // SellTakeProfit(idx); // lastDelta = delta; //} }
override protected void StrategyExecute() { int fast_macd = (int)parameters[0]; int slow_macd = (int)parameters[1]; int signal_macd = (int)parameters[2]; int rsi_period = (int)parameters[3]; int RSI_LOWER_LEVEL = (int)parameters[4]; int RSI_UPPER_LEVEL = (int)parameters[5]; int cutlosslevel = (int)parameters[6]; int takeprofitlevel = (int)parameters[7]; //double delta = 0, lastDelta = 0; //DataSeries line1 = Indicators.RSI.Series(data.Close, rsi_period, ""); //Indicators.MACD macd = Indicators.MACD.Series(data.Close, fast_macd, slow_macd, signal_macd, ""); //DataSeries hist = macd.HistSeries; MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd); BasicRSI_Rule rsirule = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL); for (int idx = 1; idx < data.Close.Count; idx++) { if (rsirule.isValid_forBuy(idx)||macdrule.isValid_forBuy(idx)) BuyAtClose(idx); if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) SellAtClose(idx); if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) SellCutLoss(idx); if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) SellTakeProfit(idx); } //for (int idx = 1; idx < line1.Count; idx++) //{ // delta = (hist[idx] - hist[idx - 1]); // if (line1[idx] < RSI_LOWER_LEVEL && delta > 0 && lastDelta < 0) // BuyAtClose(idx); // if (is_bought) // if ((delta < 0 && lastDelta > 0) || line1[idx] > RSI_UPPER_LEVEL) // SellAtClose(idx); // if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) // SellCutLoss(idx); // if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) // SellTakeProfit(idx); // lastDelta = delta; //} }
override protected void StrategyExecute() { MACD_HistogramRule rule = new MACD_HistogramRule(data.Close, parameters[0], parameters[1], parameters[2]); for (int idx = rule.macd.FirstValidValue; idx < data.Close.Count; idx++) { if (rule.isValid_forBuy(idx)) { BuyAtClose(idx); } if (rule.isValid_forSell(idx)) { SellAtClose(idx); } } }
override protected void StrategyExecute() { MACD_HistogramRule rule = new MACD_HistogramRule(data.Close, parameters[0], parameters[1], parameters[2]); double cutlosslevel = parameters[3]; double takeprofitlevel = parameters[4]; for (int idx = rule.macd.FirstValidValue; idx < data.Close.Count - 1; idx++) { if (rule.isValid_forBuy(idx)) BuyAtClose(idx); if (rule.isValid_forSell(idx)) SellAtClose(idx); if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) SellCutLoss(idx); if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) SellTakeProfit(idx); } }
protected override void StrategyExecute() { //DataSeries sma20 = Indicators.SMA.Series(data.Close, parameters[0], ""); MACD_HistogramRule macdRule = new MACD_HistogramRule(data.Close, parameters[1], parameters[2], parameters[3]); StochSlowRule stochRule = new StochSlowRule(data.Bars, parameters[4], parameters[5], parameters[6]); for (int idx = 1; idx < data.Close.Count; idx++) { if (macdRule.isValid_forBuy(idx)&&stochRule.UpTrend(idx)) BuyAtClose(idx); if (macdRule.isValid_forSell(idx)) SellAtClose(idx); } }
override protected void StrategyExecute() { int fast_macd = (int)parameters[0]; int slow_macd = (int)parameters[1]; int signal_macd = (int)parameters[2]; int rsi_period = (int)parameters[3]; int RSI_LOWER_LEVEL = (int)parameters[4]; int RSI_UPPER_LEVEL = (int)parameters[5]; int cutlosslevel = (int)parameters[6]; int takeprofitlevel = (int)parameters[7]; MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd); BasicRSI_Rule rsirule = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL); TwoSMARule rule = new TwoSMARule(rsirule.rsi, 5, 10); for (int idx = 1; idx < data.Close.Count; idx++) { //if (rsirule.isValid_forBuy(idx) && macdrule.isValid_forBuy(idx)) // BuyAtClose(idx); //if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) // SellAtClose(idx); if (rule.isValid_forBuy(idx) && macdrule.isValid_forBuy(idx)) { BuyAtClose(idx); } if (rule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) { SellAtClose(idx); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) { SellCutLoss(idx); } if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) { SellTakeProfit(idx); } } }
protected override void StrategyExecute() { //DataSeries sma20 = Indicators.SMA.Series(data.Close, parameters[0], ""); MACD_HistogramRule macdHistogramRule = new MACD_HistogramRule(data.Close, parameters[1], parameters[2], parameters[3]); StochSlowRule stochSlowRule = new StochSlowRule(data.Bars, parameters[4], parameters[5], parameters[6]); for (int idx = 1; idx < data.Close.Count; idx++) { if (macdHistogramRule.isValid_forBuy(idx) && stochSlowRule.UpTrend(idx)) { BuyAtClose(idx); } if (macdHistogramRule.isValid_forSell(idx)) { SellAtClose(idx); } } }
override protected void StrategyExecute() { int fast_macd = (int)parameters[0]; int slow_macd = (int)parameters[1]; int signal_macd = (int)parameters[2]; int rsi_period = (int)parameters[3]; int RSI_LOWER_LEVEL = (int)parameters[4]; int RSI_UPPER_LEVEL = (int)parameters[5]; int cutlosslevel = (int)parameters[6]; int takeprofitlevel = (int)parameters[7]; MACD_HistogramRule macdrule = new MACD_HistogramRule(data.Close, fast_macd, slow_macd, signal_macd); BasicRSI_Rule rsirule = new BasicRSI_Rule(data.Close, rsi_period, RSI_LOWER_LEVEL, RSI_UPPER_LEVEL); TwoSMARule rule = new TwoSMARule(rsirule.rsi, 5,10); for (int idx = 1; idx < data.Close.Count; idx++) { //if (rsirule.isValid_forBuy(idx) && macdrule.isValid_forBuy(idx)) // BuyAtClose(idx); //if (rsirule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) // SellAtClose(idx); if (rule.isValid_forBuy(idx)&& macdrule.isValid_forBuy(idx)) BuyAtClose(idx); if (rule.isValid_forSell(idx) || macdrule.isValid_forSell(idx)) SellAtClose(idx); if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) SellCutLoss(idx); if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) SellTakeProfit(idx); } }
override protected void StrategyExecute() { MACD_HistogramRule rule = new MACD_HistogramRule(data.Close, parameters[0],parameters[1],parameters[2]); for (int idx = rule.macd.FirstValidValue; idx < data.Close.Count; idx++) { if (rule.isValid_forBuy(idx)) BuyAtClose(idx); if (rule.isValid_forSell(idx)) SellAtClose(idx); } }