public DIFStrategy(Indicator Price, int DecyclePeriod = 20, int InvFisherPeriod = 40, decimal Threshold = 0.9m, decimal Tolerance = 0.001m) { // Initialize the fields. _decyclePeriod = DecyclePeriod; _invFisherPeriod = InvFisherPeriod; _threshold = Threshold; _tolerance = Tolerance; // Initialize the indicators used by the Strategy. _price = Price; DecycleTrend = new Decycle(_decyclePeriod).Of(Price); InverseFisher = new InverseFisherTransform(_invFisherPeriod).Of(DecycleTrend); InvFisherRW = new RollingWindow<decimal>(2); LightSmoothPrice = new Decycle(10).Of(Price); Momersion = new MomersionIndicator(10, 30).Of(LightSmoothPrice, false); // Fill the Inverse Fisher rolling windows at every new InverseFisher observation. // Once the Inverse Fisher rolling windows is ready, at every InverseFisher update, the Check signal method will be called. InverseFisher.Updated += (object sender, IndicatorDataPoint updated) => { if (InverseFisher.IsReady) InvFisherRW.Add(updated); if (InvFisherRW.IsReady) CheckSignal(); }; Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; }
public void Poll_PushedButtonAndNonEmptyBoiler_TurnsOffLight( [Frozen]Mock<ICoffeeMaker> coffeeMaker, Indicator sut) { sut.Poll(BoilerStatus.NOT_EMPTY, BrewButtonStatus.PUSHED); coffeeMaker.Verify(cm => cm.SetIndicatorState(IndicatorState.OFF)); }
public override string Valid(Indicator indicator, List<IndicatorValue> values) { //IndicatorValue currentValue = values.FirstOrDefault(v => v.Indicator.DisplayName == indicator.DisplayName); //if (currentValue == null) // return ""; //switch (indicator.DisplayName) //{ // case "DDLFPopulationAtRisk": // IndicatorValue related1 = values.FirstOrDefault(v => v.Indicator.DisplayName == "DDLFPopulationRequiringPc"); // if (related1 != null) // { // double currentPop, relatedPop; // if (Double.TryParse(currentValue.DynamicValue, out currentPop) && Double.TryParse(related1.DynamicValue, out relatedPop)) // { // if (currentPop < relatedPop) // return Translations.BrettTestErrorMessage; // } // } // break; // default: // break; //} return ""; }
public void Poll_PushedButtonAndEmptyBoilerAndPot_TurnsOnLightAndShutsDownButton( [Frozen]Mock<ICoffeeMaker> coffeeMaker, Indicator sut) { sut.Poll(BoilerStatus.EMPTY, WarmerPlateStatus.WARMER_EMPTY, BrewButtonStatus.PUSHED); coffeeMaker.Verify(cm => cm.SetIndicatorState(IndicatorState.ON)); coffeeMaker.Verify(cm => cm.GetBrewButtonStatus()); }
public Continent(string Name, Indicator pop, Indicator foodNeed,Indicator foodProd, Indicator airQuality, Indicator earthQuality, Indicator seaQuality, Indicator biodiversity) { indicators.Add("pop", pop); indicators.Add("foodNeed", foodNeed); indicators.Add("foodProd", foodProd); indicators.Add("airQuality", airQuality); indicators.Add("earthQuality", earthQuality); indicators.Add("seaQuality", seaQuality); indicators.Add("biodiversity", biodiversity); _Name = Name; }
public Portfolio.Portfolio BackTest(Indicator.GenericIndicator indicator, HistoricalDataSet dataSet, Portfolio.Portfolio portfolio) { Ranking[][] rankingTable = dataSet.GetRankingTable(indicator); SetUpPortFolio(portfolio, rankingTable[0]); for(int i = 1; i < rankingTable.Length; i += 1) { UpdatePortfolio(portfolio, rankingTable[i-1], rankingTable[i]); } return portfolio; }
public TripleMovingAverageStrategy(Symbol sym, Indicator priceIdentity, MeanReversionAlgorithm algorithm, decimal minBarSize, decimal barDifferenceTolerance) { Algorithm = algorithm; symbol = sym; trend = new InstantaneousTrend(10).Of(_price); ema10 = new ExponentialMovingAverage(10).Of(_price); sma10 = new SimpleMovingAverage(10).Of(_price); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; }
protected void ParseNotes(IHaveDynamicIndicatorValues form, Indicator notesIndicator) { var notesInd = form.IndicatorValues.FirstOrDefault(i => i.Indicator.DisplayName == "Notes"); if (notesInd != null) { if (IsRedistricted) notesInd.CalcByRedistrict = true; else if (notesInd.CalcByRedistrict && notesInd.DynamicValue != Notes) notesInd.CalcByRedistrict = false; notesInd.DynamicValue = Notes; } else form.IndicatorValues.Add(new IndicatorValue { DynamicValue = Notes, Indicator = notesIndicator, IndicatorId = notesIndicator.Id, CalcByRedistrict = IsRedistricted }); }
private void AsiaInitilization() { string name = "Asie"; Debug.Log("Initialization of Asia continent start"); Indicator pop = new Indicator("Population", 100.0, 0.99, 50.0, 1.0); Indicator foodNeed = new Indicator("Hunger", 100.0, 0.99, 50.0, 1.0); Indicator foodProd = new Indicator("Food", 100.0, 0.99, 50.0, 1.0); Indicator airQuality = new Indicator("Air", 100.0, 0.99, 50.0, 1.0); Indicator earthQuality = new Indicator("Earth", 100.0, 0.99, 50.0, 1.0); Indicator seaQuality = new Indicator("Sea", 100.0, 0.99, 50.0, 1.0); Indicator biodiversity = new Indicator("Biodiversity", 10000000, 0.99, 10000000, 1.0); Continent continentAsia = new Continent(name, pop, foodNeed, foodProd, airQuality, earthQuality, seaQuality, biodiversity); Global.instance.continents.Add(name, continentAsia); Debug.Log("Initialization of Asia continent end"); }
public NoStrategy(string Symbol, Indicator Price, Indicator Trend) { _symbol = Symbol; _price = Price; _trend = Trend; _trend.Updated += (object sender, IndicatorDataPoint updated) => { if (!_trend.IsReady) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("From TREND EVENT HANDLER, Trend is NOT ready"); Console.ResetColor(); } CheckSignal(); }; }
/// <summary> /// Initializes a new instance of the <see cref="CrossEMAStrategy"/> class. /// </summary> /// <param name="Price">The injected price indicator.</param> /// <param name="SlowEMAPeriod">The slow EMA period.</param> /// <param name="FastEMAPeriod">The fast EMA period.</param> public CrossEMAStrategy(Indicator Price, int SlowEMAPeriod = 10, int FastEMAPeriod = 50) { // Initialize fields. _price = Price; fastEMA = new ExponentialMovingAverage(FastEMAPeriod).Of(_price); slowEMA = new ExponentialMovingAverage(SlowEMAPeriod).Of(_price); ActualSignal = OrderSignal.doNothing; Position = StockState.noInvested; EntryPrice = null; // Fill the EMA difference rolling windows at every new slowEMA observation. Once the // rolling windows is ready, at every indicator update the CheckSignal method will be called. slowEMA.Updated += (object sender, IndicatorDataPoint updated) => { if (slowEMA.IsReady) EMADiffRW.Add(fastEMA - slowEMA); if (EMADiffRW.IsReady) CheckSignal(); }; }
/// <summary> /// Initializes a new instance of the <see cref="CrossEMAStrategy"/> class. /// </summary> /// <param name="Price">The injected price indicator.</param> /// <param name="SlowEMAPeriod">The slow EMA period.</param> /// <param name="FastEMAPeriod">The fast EMA period.</param> public RSIStrategy(Indicator Price, int RSIPeriod = 40, decimal Threshold = 20) { // Initialize fields. _threshold = Threshold; _price = Price; ActualSignal = OrderSignal.doNothing; Position = StockState.noInvested; EntryPrice = null; rsi = new RelativeStrengthIndex(RSIPeriod).Of(_price); // Fill the RSI rolling windows at every new RSI update. Once the // rolling windows is ready, at every indicator update the CheckSignal method will be called. rsi.Updated += (object sender, IndicatorDataPoint updated) => { if (rsi.IsReady) rsiRW.Add(rsi); if (rsiRW.IsReady) CheckSignal(); }; }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public ITrendStrategyJJ(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; ITrend = new InstantaneousTrend(period).Of(price); ITrendMomentum = new Momentum(2).Of(ITrend); MomentumWindow = new RollingWindow<decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; ITrendMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (ITrendMomentum.IsReady) MomentumWindow.Add(ITrendMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public MultiSymbolStrategy(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; sma = new SimpleMovingAverage(period).Of(price); SMAMomentum = new Momentum(2).Of(sma); MomentumWindow = new RollingWindow<decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; SMAMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (SMAMomentum.IsReady) MomentumWindow.Add(SMAMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }
public VROC(Indicator indicator, int length, Color color) { this.indicator = new FreeQuant.Indicators.VROC(indicator.indicator, length, color); }
public void BadLookback() { Indicator.GetDoubleEma(history, 0); }
public DX(Indicator indicator, int length) { this.indicator = new FreeQuant.Indicators.DX(indicator.indicator, length); }
public void MakeColAble(Indicator ind, int b) { ind.Activate (b == 1); }
public void InsufficientHistoryA() { Indicator.GetDoubleEma(history.Where(x => x.Index < 160), 30); }
public VHF(Indicator indicator, int length, BarData option, Color color) { this.indicator = new FreeQuant.Indicators.VHF(indicator.indicator, length, EnumConverter.Convert(option), color); }
public MACD(Indicator indicator, int length1, int length2, BarData option, Color color) { this.indicator = new FreeQuant.Indicators.MACD(indicator.indicator, length1, length2, EnumConverter.Convert(option), color); }
public void CalculateMath() { MathExp = Indicator.CalculateMath(); }
public void CalculateDev() { Deviation = Indicator.CalculateDev(); }
public void CalcHistogramm(int count) { Histogramm = Indicator.CalcHistogramm(count); HistogrammDouble = Histogramm.Select(v => v.Y).ToArray(); }
public void BadData() { IEnumerable <StdDevChannelsResult> r = Indicator.GetStdDevChannels(historyBad); Assert.AreEqual(502, r.Count()); }
public SparkleStatusIcon() { #if HAVE_APP_INDICATOR this.indicator = new Indicator("sparkleshare", "sparkleshare", (int)IndicatorCategory.ApplicationStatus); this.indicator.IconName = "process-syncing-idle"; this.indicator.Status = (int)IndicatorStatus.Active; #else this.status_icon = new StatusIcon(); this.status_icon.IconName = "sparkleshare"; this.status_icon.Activate += ShowMenu; // Primary mouse button click this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click #endif CreateMenu(); Controller.UpdateIconEvent += delegate(IconState state) { Application.Invoke(delegate { #if HAVE_APP_INDICATOR string icon_name = "process-syncing-idle"; #else string icon_name = "sparkleshare"; #endif if (state == IconState.SyncingUp) { icon_name = "process-syncing-up"; } else if (state == IconState.SyncingDown) { icon_name = "process-syncing-down"; } else if (state == IconState.Syncing) { icon_name = "process-syncing"; } else if (state == IconState.Error) { icon_name = "process-syncing-error"; } #if HAVE_APP_INDICATOR this.indicator.IconName = icon_name; // Force update of the status icon this.indicator.Status = (int)IndicatorStatus.Attention; this.indicator.Status = (int)IndicatorStatus.Active; #else this.status_icon.IconName = icon_name; #endif }); }; Controller.UpdateStatusItemEvent += delegate(string state_text) { Application.Invoke(delegate { (this.state_item.Child as Label).Text = state_text; this.state_item.ShowAll(); }); }; Controller.UpdateQuitItemEvent += delegate(bool item_enabled) { Application.Invoke(delegate { this.quit_item.Sensitive = item_enabled; this.quit_item.ShowAll(); }); }; Controller.UpdateMenuEvent += delegate(IconState state) { Application.Invoke(delegate { CreateMenu(); }); }; }
public void Update() { isInvincible = false; if (player != null) { //find position after animation? will it use the position from before the animation starts? be ready to change findPos(); if (!supercharged && currentHp() <= health.startingHealth / 2) { supercharged = true; cd_Reduction = 3; overload_Range *= 1.5; bolt_Stun += 0.5f; hook_Speed *= 1.5f; knockback += 1.5f; speedBoost++; storm_CD = 0.6f; } rnd = new System.Random(); //if stunned = true, wait 0.5s, then gain a speedBoost for 3s //else distance = player.transform.position - transform.position; if (distance.magnitude <= AgroRange) { isAgro = true; } if (distance.magnitude > AgroRange) { isAgro = false; } if (isAgro) { //targetPos *= 0.8f; if (cooldown_CD > 1) { cooldown_CD = 0; //faster the closer you are from him, probably better ways to do this but I don't want to look it up float xSp = 2 * (AgroRange - (player.transform.position.x - transform.position.x)); float ySp = 2 * (AgroRange - (player.transform.position.y - transform.position.y)); //targetPos = new Vector2(0, 0); moveController.Move(0, 0); //basic aggression range formula if (distance.magnitude < overload_Range && overload_CD > 12 - cd_Reduction) { overloadAttack(); } else if (distance.magnitude < 0.3 && norm_CD > 1.5) { normAttack(); } else if (lightning_CD > 10) { //animation //lightning storm, player parameter or getObject(player) //take in either bool supercharged or cooldown //field = new LightningField(); field = Instantiate(fieldObj, player.transform.position, transform.rotation) as LightningField; field.set(0.7f, storm_CD); lightning_CD = 0; //dark shadow below player? } else if (bolt_CD > 10 - cd_Reduction) { boltAttack(); } //overload -> normal attack if in range -> lightning storm (effect) -> lightning bolt projectile(to set up other moves) //-> thunder (put bolt here instead? depends on thunder activation speed)-> shot -> field -> speed -> charge else if (supercharged && thunder_CD > 20) { //animation //thunder, parameter player or getobject //in thunder class, create black white black screen around player //indic = new Indicator(); //indic.set or indicObj.set? indic = Instantiate(indicObj, player.transform.position, transform.rotation) as Indicator; indic.set(2); thunder_CD = 0; } else if (shot_CD > 10 - cd_Reduction) { shotAttack(); } else { //if wall within 0.2 units of one corner, move to another corner clockwise //else //if wall(not pole) to the left or right, disregard x velocity and increase y velocity //if wall(not pole) above or below, disregard y velocity and increase x velocity //else move away from player cooldown_CD = 0.8f; } if (spark_CD > 2 + currentHp() / 5.0) { sparkAttack(); } } //moveController.Move(targetPos); // float xSp = player.transform.position.x - transform.position.x; // float ySp = player.transform.position.y - transform.position.y; overload_CD += Time.deltaTime; norm_CD += Time.deltaTime; lightning_CD += Time.deltaTime; bolt_CD += Time.deltaTime; shot_CD += Time.deltaTime; thunder_CD += Time.deltaTime; cooldown_CD += Time.deltaTime; spark_CD += Time.deltaTime; } } //Debug.Log("My pos is " + posArr[9 - currentHp()]); findPos(); transform.position = posArr[9 - currentHp()]; if (currentHp() > 5) { transform.rotation = Quaternion.Euler(0, 0, 90 * (9 - currentHp())); } else if (currentHp() > 1) { transform.rotation = Quaternion.Euler(0, 0, 45 + 90 * (5 - currentHp())); } else { transform.rotation = Quaternion.Euler(0, 0, 0); } }
public void BadData() { IEnumerable <VolSmaResult> r = Indicator.GetVolSma(historyBad, 15); Assert.AreEqual(502, r.Count()); }
public void InsufficientHistory() { Indicator.GetAroon(history.Where(x => x.Index < 30), 30); }
public CCI(Indicator indicator, int length) { this.indicator = new FreeQuant.Indicators.CCI(indicator.indicator, length); }
public void BadParameter() { Indicator.GetAroon(history, 0); }
public override string Valid(Indicator indicator, List<IndicatorValue> values) { return ""; }
public void BadLookback() { Indicator.GetAroon(history, 0); }
/// <summary> /// Calculates an indicator and returns OK status. /// </summary> private bool CalculateIndicator(SlotTypes slotType, Indicator indicator) { #if !DEBUG try { #endif indicator.Calculate(slotType); return true; #if !DEBUG } catch (Exception exception) { string message = "Please report this error in the support forum!"; if (indicator.CustomIndicator) message = "Please report this error to the author of the indicator!<br />" + "You may remove this indicator from the Custom Indicators folder."; string text = "<h1>Error: " + exception.Message + "</h1>" + "<p>" + "Slot type: <strong>" + slotType + "</strong><br />" + "Indicator: <strong>" + indicator + "</strong>" + "</p>" + "<p>" + message + "</p>"; const string caption = "Indicator Calculation Error"; ReportIndicatorError(text, caption); _indicatorBlackList.Add(indicator.IndicatorName); return false; } #endif }
public void InsufficientHistoryB() { Indicator.GetDoubleEma(history.Where(x => x.Index < 750), 250); }
public K_Slow(Indicator indicator, int length, int order, Color color) { this.indicator = new FreeQuant.Indicators.K_Slow(indicator.indicator, length, order, color); }
public MOM(Indicator indicator, int length, BarData option) { this.indicator = new FreeQuant.Indicators.MOM(indicator.indicator, length, EnumConverter.Convert(option)); }
public MDM(Indicator indicator, Color color) { this.indicator = new FreeQuant.Indicators.MDM(indicator.indicator, color); }
void OnChatViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e, ChatView chatView) { Trace.Call(sender, e, chatView); if (MainWindow.HasToplevelFocus || !IsEnabled) { return; } Indicator indicator; if (Indicators.TryGetValue(chatView, out indicator)) { // update time of existing indicator indicator.SetProperty( "time", e.Message.TimeStamp.ToLocalTime().ToString("s") ); return; } indicator = new Indicator(); indicator.SetProperty("subtype", "im"); if (chatView is PersonChatView) { indicator.SetProperty("icon", PersonChatIconBase64); indicator.SetProperty("sender", chatView.Name); } if (chatView is GroupChatView) { indicator.SetProperty("icon", GroupChatIconBase64); var nick = GetNick(e.Message); if (nick == null) { indicator.SetProperty("sender", chatView.Name); } else { indicator.SetProperty("sender", String.Format( "{0} ({1})", chatView.Name, nick ) ); } } indicator.SetProperty( "time", e.Message.TimeStamp.ToLocalTime().ToString("s") ); indicator.SetPropertyBool("draw-attention", true); indicator.UserDisplay += delegate { try { MainWindow.PresentWithTime( (uint) (DateTime.UtcNow - UnixEpoch).TotalSeconds ); MainWindow.Notebook.CurrentChatView = chatView; DisposeIndicator(chatView); } catch (Exception ex) { #if LOG4NET Logger.Error("OnChatViewMessageHighlighted() " + "indicator.UserDisplay threw exception", ex); #endif } }; try { indicator.Show(); } catch (Exception ex) { #if LOG4NET Logger.Error("OnChatViewMessageHighlighted() " + "indicator.Show() thew exception", ex); #endif } Indicators.Add(chatView, indicator); }
public VROC(Indicator indicator, int length) { this.indicator = new FreeQuant.Indicators.VROC(indicator.indicator, length); }
public Sig10Strategy(SecurityHolding sym, Indicator priceIdentity, int trendPeriod, decimal lossThreshhold, decimal tolerance, decimal revertPct) { trendArray = new decimal[trendPeriod + 1]; // initialized to 0. Add a period for Deserialize to make IsReady true symbol = sym.Symbol; _holding = sym; _price = priceIdentity; _period = trendPeriod; _lossThreshhold = lossThreshhold; _tolerance = tolerance; RevPct = revertPct; Trend = new InstantaneousTrend(sym.Symbol.Value, 7, .24m).Of(priceIdentity); TrendMomentum = new Momentum(2).Of(Trend); MomentumWindow = new RollingWindow<decimal>(2); ActualSignal = OrderSignal.doNothing; Trend.Updated += (object sender, IndicatorDataPoint updated) => { Barcount++; UpdateTrendArray(Trend.Current.Value); nTrig = Trend.Current.Value; if (Trend.IsReady) { TrendMomentum.Update(Trend.Current); } if (TrendMomentum.IsReady) MomentumWindow.Add(TrendMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }
public void BadData() { IEnumerable <IchimokuResult> r = Indicator.GetIchimoku(historyBad, 8, 20, 35); Assert.AreEqual(502, r.Count()); }
public MACD(Indicator indicator, int length1, int length2, Color color) { this.indicator = new FreeQuant.Indicators.MACD(indicator.indicator, length1, length2, color); }
public void BadLookback() { Indicator.GetRsi(history, 1); }
public void BadData() { IEnumerable <ElderRayResult> r = Indicator.GetElderRay(historyBad); Assert.AreEqual(502, r.Count()); }