public MacdStrategy(ref ContextValues inputContextValues, IntervalValues intervalValues) : base(ref inputContextValues) { //myMacdStrategy_Large = new Macd(ref inputContextValues, "macd_large"); myMacdStrategy_Small = new Macd(ref inputContextValues, "macd_small"); var genSettings = AppSettings.GetGeneralSettings(); percent_for_using_smallmacd = genSettings.price_inc_percent_for_using_smallmacd; }
private void TradeUsing(Macd strategy) { if (!CurrentValues.BuyOrderFilled) // not bought yet { if (strategy.Buy) { bool alreadyBought = AppSettings.GetGeneralSettings().already_bought; if (alreadyBought) { Logger.WriteLog("Already bought detected in settings, setting next actino to Sell"); SetNextActionTo_Sell(); //simulate buy complete CurrentValues.WaitingBuyFill = false; CurrentValues.WaitingBuyOrSell = false; AppSettings.SaveUpdateGeneralSetting("already_bought", false.ToString()); } else { Buy(); } } } if (!CurrentValues.SellOrderFilled) // not sold yet { if (strategy.Sell) { bool alreadySold = AppSettings.GetGeneralSettings().already_sold; if (alreadySold) { Logger.WriteLog("Already sold detected in settings, setting next actino to Buy"); SetNextActionTo_Buy(); //simulate buy complete CurrentValues.WaitingSellFill = false; CurrentValues.WaitingBuyOrSell = false; AppSettings.SaveUpdateGeneralSetting("already_sold", false.ToString()); } else { Sell(); } } } }