override protected void StrategyExecute() { BasicATRRule rule = new BasicATRRule(data.Bars, parameters[0], "atr"); Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[0], "min"); Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[0], "max"); for (int idx = 0; idx < data.Close.Count ; idx++) { if (rule.isValid_forBuy(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = max[idx]; info.Stop_Loss = min[idx]; BuyAtClose(idx, info); } else if (rule.isValid_forSell(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Downward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = min[idx]; info.Stop_Loss = max[idx]; SellAtClose(idx, info); } } }
public HybridTestRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[2]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); adxTrend = new ADXMarketTrend(db, 14); //Kiem tra volume volumeRule = new PriceTwoSMARule(db.Volume, 10, 30); data = db; Volume_Filter = 50000; }
protected override void StrategyExecute() { Rule rule = new BasicATRRule(data.Bars, parameters[0],"atr"); if (rule.isValid()) { int Bar = data.Close.Count - 1; BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Weight = data.Close[Bar]; SelectStock(Bar, info); } }
protected override void StrategyExecute() { Rule rule = new BasicATRRule(data.Bars, parameters[0], "atr"); if (rule.isValid()) { int Bar = data.Close.Count - 1; BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Weight = data.Close[Bar]; SelectStock(Bar, info); } }
public HybridTestRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[3]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); rules[2] = new BasicMACDRule(db.Close, 12, 26, 9); adxTrend = new ADXMarketTrend(db, 14); //Kiem tra volume volumeRule = new PriceTwoSMARule(db.Volume, 10, 30); data = db; Volume_Filter = 50000; }
override protected void StrategyExecute() { BasicATRRule rule = new BasicATRRule(data.Bars, parameters[0], "atr"); TwoEMARule emaRule = new TwoEMARule(data.Close, parameters[1], parameters[2]); int cutlosslevel = (int)parameters[3]; int trailingstoplevel = (int)parameters[4]; int takeprofitlevel = (int)parameters[5]; Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[0], "min"); Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[0], "max"); for (int idx = 0; idx < data.Close.Count - 1; idx++) { if (rule.isValid_forBuy(idx) && emaRule.UpTrend(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = max[idx]; info.Stop_Loss = min[idx]; BuyAtClose(idx, info); } else if (rule.isValid_forSell(idx) || emaRule.isValid_forSell(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Downward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = min[idx]; info.Stop_Loss = max[idx]; SellAtClose(idx, info); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) { SellCutLoss(idx); } if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) { SellTakeProfit(idx); } if (trailingstoplevel > 0) { TrailingStopWithBuyBack(rule, data.Close[idx], trailingstoplevel, idx); } } }
override protected void StrategyExecute() { BasicATRRule rule = new BasicATRRule(data.Bars, parameters[0], "atr"); TwoEMARule emaRule = new TwoEMARule(data.Close, parameters[1], parameters[2]); int cutlosslevel = (int)parameters[3]; int trailingstoplevel = (int)parameters[4]; int takeprofitlevel = (int)parameters[5]; Indicators.MIN min = Indicators.MIN.Series(data.Close, parameters[0], "min"); Indicators.MAX max = Indicators.MAX.Series(data.Close, parameters[0], "max"); for (int idx = 0; idx < data.Close.Count - 1; idx++) { if (rule.isValid_forBuy(idx) && emaRule.UpTrend(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Upward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = max[idx]; info.Stop_Loss = min[idx]; BuyAtClose(idx, info); } else if (rule.isValid_forSell(idx) || emaRule.isValid_forSell(idx)) { BusinessInfo info = new BusinessInfo(); info.SetTrend(AppTypes.MarketTrend.Downward, AppTypes.MarketTrend.Unspecified, AppTypes.MarketTrend.Unspecified); info.Short_Target = min[idx]; info.Stop_Loss = max[idx]; SellAtClose(idx, info); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) SellCutLoss(idx); if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) SellTakeProfit(idx); if (trailingstoplevel > 0) TrailingStopWithBuyBack(rule, data.Close[idx], trailingstoplevel, idx); } }
public MACDHistATRRules(DataBars db, double atrperiod, double fast, double slow, double signal) { rules = new Rule[2]; rules[0] = new MACD_HistogramRule(db.Close, fast, slow, signal); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public SMAATRRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[2]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public MACDHistATRRules(DataBars db, double atrperiod, double fast, double slow,double signal) { rules = new Rule[2]; rules[0] = new MACD_HistogramRule(db.Close, fast, slow,signal); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public SARATRRules(DataBars db, double atrperiod, double optInAcc,double optLnMax) { rules = new Rule[2]; rules[0] = new BasicSARRule(db, optInAcc, optLnMax); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public SARATRRules(DataBars db, double atrperiod, double optInAcc, double optLnMax) { rules = new Rule[2]; rules[0] = new BasicSARRule(db, optInAcc, optLnMax); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public SMAATRRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[2]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }