protected override void OnCalculate() { //calculate data OrderDirection_Enum?resultdata = this._RunningWithTheWolves_Indicator.calculate(InSeries, this.MA_Selected, this.MA_Fast, this.MA_Medium, this.MA_Slow); if (resultdata.HasValue) { switch (resultdata) { case OrderDirection_Enum.OpenLong: Occurred.Set(1); //Entry.Set(InSeries[0]); break; case OrderDirection_Enum.OpenShort: Occurred.Set(-1); //Entry.Set(InSeries[0]); break; //case OrderDirection.Buy: // break; //case OrderDirection.Sell: // break; default: //nothing to do Occurred.Set(0); //Entry.Set(InSeries[0]); break; } } else { Occurred.Set(0); } }
protected override void OnCalculate() { //calculate data ResultValue returnvalue = this._TrendTemplate_MarkMinervini_Indicator.calculate(this.InSeries); //If the calculate method was not finished we need to stop and show an alert message to the user. if (returnvalue.ErrorOccured) { //Display error just one time if (!this.ErrorOccured) { Log(this.DisplayName + ": " + Const.DefaultStringErrorDuringCalculation, InfoLogLevel.AlertLog); this.ErrorOccured = true; } return; } //Entry if (returnvalue.Entry.HasValue) { switch (returnvalue.Entry) { case OrderDirection.Buy: Occurred.Set(1); break; } } else { Occurred.Set(0); } }
protected override void OnCalculate() { _orb_indicator.calculate(this.Bars, this.Bars[0]); //Occurred.Set(returnvalue); //Entry.Set(Bars[0].Close); //If there was a breakout and the current bar is the same bar as the long/short breakout, then trigger signal. if (_orb_indicator.LongBreakout != null && _orb_indicator.LongBreakout.Time == Bars[0].Time) { //Long Signal Occurred.Set(1); //Entry.Set(Close[0]); } else if (_orb_indicator.ShortBreakout != null && _orb_indicator.ShortBreakout.Time == Bars[0].Time) { //Short Signal Occurred.Set(-1); //Entry.Set(Close[0]); } else { //No Signal Occurred.Set(0); //Entry.Set(Close[0]); } }
protected override void OnBarUpdate() { if (Bars != null && Bars.Count > 0 && TimeFrame.Periodicity == DatafeedHistoryPeriodicity.Minute && TimeFrame.PeriodicityValue == 1) { } else { return; } if (DummyOneMinuteEven_Indicator()[0] == 100) { Occurred.Set(-1); } else { Occurred.Set(1); } //Entry.Set(iv_Bars.GetOpen(iv_CurrentBar)); //Entry.Set(10390); //Entry.Set(GetCurrentBid()); }
protected override void OnBarUpdate() { //calculate data OrderAction?resultdata = this._Mean_Reversion_Indicator.calculate(Input, Open, High, null, null, this.Bollinger_Period, this.Bollinger_Standard_Deviation, this.Momentum_Period, this.RSI_Period, this.RSI_Smooth, this.RSI_Level_Low, this.RSI_Level_High, this.Momentum_Level_Low, this.Momentum_Level_High); if (resultdata.HasValue) { switch (resultdata) { case OrderAction.Buy: Occurred.Set(1); //Entry.Set(Input[0]); break; case OrderAction.SellShort: Occurred.Set(-1); //Entry.Set(Input[0]); break; //case OrderAction.BuyToCover: // break; //case OrderAction.Sell: // break; default: //nothing to do Occurred.Set(0); //Entry.Set(Input[0]); break; } } else { Occurred.Set(0); } }
protected override void OnCalculate() { EMA ema = EMA(this.Period); double bull_power = High[0] - ema[0]; double bear_power = Low[0] - ema[0]; ds_bull_power.Set(bull_power); ds_bear_power.Set(bear_power); int resultsignal = 0; if (ema[0] > ema[1] && bear_power < 0 && bear_power > ds_bear_power.Get(1)) { resultsignal = 1; } if (ema[0] < ema[1] && bull_power > 0 && bull_power < ds_bull_power.Get(1)) { resultsignal = -1; } Occurred.Set(resultsignal); PlotColors[0][0] = this.Plot0Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; PlotColors[1][0] = this.Plot1Color; OutputDescriptors[1].PenStyle = this.Dash1Style; OutputDescriptors[1].Pen.Width = this.Plot1Width; }
protected override void OnBarUpdate() { //calculate data OrderAction?resultdata = this._RunningWithTheWolves_Indicator.calculate(Input); if (resultdata.HasValue) { switch (resultdata) { case OrderAction.Buy: Occurred.Set(1); //Entry.Set(Input[0]); break; case OrderAction.SellShort: Occurred.Set(-1); //Entry.Set(Input[0]); break; //case OrderAction.BuyToCover: // break; //case OrderAction.Sell: // break; default: //nothing to do Occurred.Set(0); //Entry.Set(Input[0]); break; } } else { Occurred.Set(0); } }
protected override void OnCalculate() { Occurred.Set(LeadIndicator.Lonely_Warrior_Indicator()[0]); PlotColors[0][0] = this.Plot0Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; PlotColors[1][0] = this.Plot1Color; OutputDescriptors[1].PenStyle = this.Dash1Style; OutputDescriptors[1].Pen.Width = this.Plot1Width; }
protected override void OnCalculate() { //Reset color _signalcolor = Color.Transparent; if (ProcessingBarIndex == 0) { lastsignals = new Stack <DateTime>(); } bool therewasasignal = false; //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && SMA(100)[0] >= SMA(200)[0] && Close[0] > SuperTrend(SuperTrendMAType.HMA, SuperTrendMode.ATR, 14, 2.618, 14).UpTrend[0]) //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && Close[0] > SuperTrend(SuperTrendMAType.HMA, SuperTrendMode.ATR, 14, 2.618, 14).UpTrend[0]) //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && Close[0] > SuperTrend(SuperTrendMAType.SMA, SuperTrendMode.ATR, 50, 2.618, 50).UpTrend[0]) if (Low[0] < SMA(this.MA_Long)[0] && SMA(this.MA_Short)[0] >= SMA(this.MA_Medium)[0] && Close[0] > SuperTrend(SuperTrendMAType.SMA, SuperTrendMode.ATR, 200, 2.618, 200).UpTrend[0]) { therewasasignal = true; } double thevalue = 0; if (therewasasignal) { thevalue = 1; _signalcolor = Color.LightGreen; AddChartArrowUp("ArrowLong_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.Green); lastsignals.Push(Time[0]); } else { if (lastsignals != null && lastsignals.Count > 0 && lastsignals.Peek() >= Time[this.Candles - 1]) { AddChartArrowUp("ArrowLong_Echo_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.LightGreen); thevalue = 0.5; _signalcolor = Color.Green; } } Occurred.Set(thevalue); PlotColors[0][0] = this.Plot0Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; PlotColors[1][0] = this.Plot1Color; OutputDescriptors[1].PenStyle = this.Dash1Style; OutputDescriptors[1].Pen.Width = this.Plot1Width; }
protected override void OnCalculate() { //get the indicator Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic = LeadIndicator.Example_Indicator_SMA_CrossOver_Basic(); //get the value double returnvalue = Example_Indicator_SMA_CrossOver_Basic[0]; //Condition should be drawn on a seperate panel this.IsOverlay = false; //set the value Occurred.Set(returnvalue); }
protected override void OnCalculate() { //Check if peridocity is valid for this script if (!this._Example_Indicator_SMA_CrossOver_Advanced.DatafeedPeriodicityIsValid(Bars.TimeFrame)) { Log(this.DisplayName + ": Periodicity of your data feed is suboptimal for this indicator!", InfoLogLevel.AlertLog); return; } //Lets call the calculate method and save the result with the trade action ResultValue_Example_Indicator_SMA_CrossOver_Advanced returnvalue = this._Example_Indicator_SMA_CrossOver_Advanced.calculate(this.InSeries, this.FastSma, this.SlowSma, this.IsLongEnabled, this.IsShortEnabled); //If the calculate method was not finished we need to stop and show an alert message to the user. if (returnvalue.ErrorOccured) { Log(this.DisplayName + ": A problem has occured during the calculation method!", InfoLogLevel.AlertLog); return; } //Entry if (returnvalue.Entry.HasValue) { switch (returnvalue.Entry) { case OrderAction.Buy: //Long Signal Occurred.Set(1); Entry.Set(1); break; case OrderAction.SellShort: //Short Signal Occurred.Set(-1); Entry.Set(-1); break; } } else { //No Signal Occurred.Set(0); Entry.Set(0); } //Set the drawing style, if the user has changed it. PlotColors[0][0] = this.Plot0Color; Plots[0].PenStyle = this.Dash0Style; Plots[0].Pen.Width = this.Plot0Width; }
protected override void OnCalculate() { //Print(Time[0]); TimeSpan now = Time[0].TimeOfDay; if ((now >= TimeSpan.Parse(this.Start)) && (now <= TimeSpan.Parse(this.End))) { Occurred.Set(0); } else { Occurred.Set(1); } }
protected override void OnCalculate() { double rv = 0; if (LeadIndicator.Holy_Grail_Indicator(this.InSeries)[0] > 0 && LeadIndicator.Holy_Grail_Indicator(this.InSeries)[1] > 0 && LeadIndicator.Holy_Grail_Indicator(this.InSeries)[3] > 0) { rv = 1; } Occurred.Set(rv); PlotColors[0][0] = this.Plot0Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; }
protected override void OnCalculate() { //calculate data ResultValue returnvalue = this._Mean_Reversion_Indicator.calculate(InSeries, Open, High, null, null, this.Bollinger_Period, this.Bollinger_Standard_Deviation, this.Momentum_Period, this.RSI_Period, this.RSI_Smooth, this.RSI_Level_Low, this.RSI_Level_High, this.Momentum_Level_Low, this.Momentum_Level_High); //If the calculate method was not finished we need to stop and show an alert message to the user. if (returnvalue.ErrorOccured) { //Display error just one time if (!this.ErrorOccured) { Log(this.DisplayName + ": " + Const.DefaultStringErrorDuringCalculation, InfoLogLevel.AlertLog); this.ErrorOccured = true; } return; } //Entry if (returnvalue.Entry.HasValue) { switch (returnvalue.Entry) { case OrderDirection.Buy: Occurred.Set(1); break; case OrderDirection.Sell: Occurred.Set(-1); break; } } ////Exit //if (returnvalue.Exit.HasValue) //{ // switch (returnvalue.Exit) // { // case OrderDirection.Buy: // this.DoExitShort(); // break; // case OrderDirection.Sell: // this.DoExitLong(); // break; // } //} }
protected override void OnCalculate() { //ShowGap Indikator aufrufen. Dieser liefert 100 für Long Einstieg und -100 für Short Einstieg. Liefert 0 für kein Einstiegssignal ShowGap_Indicator_Value = ShowGap_Indicator(PunkteGapMin, PunkteGapMax)[0]; if (ShowGap_Indicator_Value == 100) { Occurred.Set(1); } else if (ShowGap_Indicator_Value == -100) { Occurred.Set(-1); } else { Occurred.Set(0); } }
protected override void OnBarUpdate() { if (this.Bars != null && this.Bars.Count > 0) { //ShowGap Indikator aufrufen. Dieser liefert 100 für Long Einstieg und -100 für Short Einstieg. Liefert 0 für kein Einstiegssignal double PopGun_Indicator_Value = this._popgun_indicator.calculate(this.Bars, this.CurrentBar); if (PopGun_Indicator_Value == 100) { Occurred.Set(1); Entry.Set(GetCurrentBid()); } else if (PopGun_Indicator_Value == -100) { Occurred.Set(-1); Entry.Set(GetCurrentBid()); } else { Occurred.Set(0); Entry.Set(GetCurrentBid()); } } }
//protected override void OnBarUpdate() //{ // //TODO: Write your owner OnBarUpdate handling // //DrawArrowUp("Arrowup" + CurrentBar, true, Bars.GetTime(Count - 1), Bars.GetLow(CurrentBar) - 300 * TickSize, Color.Red); // //DrawArrowDown("Arrowdown" + CurrentBar, true, Bars.GetTime(Count - 1), Bars.GetHigh(CurrentBar) + 300 * TickSize, Color.Green); // //Occurred.Set(-1); // //Entry.Set(Close[0]); //} protected override void OnBarUpdate() { //MyGap.Set(Input[0]); if (Bars != null && Bars.Count > 0) // && TimeFrame.Periodicity == DatafeedHistoryPeriodicity.Minute // && TimeFrame.PeriodicityValue == 15) { } else { return; } if (Bars.BarsSinceSession == 0) { sessionprocessed = false; } //08.00, 08.15, 08.30, 08.45, 09.00 sind abgeschlossen -> es ist 09.15) // if(Bars.BarsSinceSession == 5) if (ToTime(Bars.GetTime(CurrentBar)) > 90000 && //größer 09.00 geht für 15M und 1Std (und 1Tag?) sessionprocessed == false) //Tag noch nicht verarbeitet { sessionprocessed = true; GapTradeLong = GapTradeShort = false; IBar GapOpenBar = Bars.Where(x => x.Time.Date == Bars[0].Time.Date).FirstOrDefault(); //liefert erster kerze des tages double GapOpen = GapOpenBar.Open; double LastDayClose = PriorDayOHLC().PriorClose[0]; double GapSize = GapOpen - LastDayClose; DateTime LastDayCloseDate = Bars.GetTime(Count - 7); DateTime LastPeriod = Time[1]; if (LastDayClose != null && Math.Abs(LastDayClose - GapOpen) > _PunkteGapMin && Math.Abs(LastDayClose - GapOpen) < _PunkteGapMax) { //Wenn Gap größer 50 und kleiner 100 existgap = true; //Gap markieren (08.00 - 09.15) string strMyRect = "MyRect" + Count; string strMyGapSize = "MyGapSize" + Count; if (LastDayClose - GapOpen < 0) //Long { //Long //DrawRectangle(strMyRect, true, LastDayCloseDate, LastDayClose, LastPeriod, HighestHighPrice(5)[0], _col_gap, _col_gap, 70); DrawText(strMyGapSize, true, Math.Round(GapSize, 1).ToString(), LastDayCloseDate, LastDayClose + 25, 9, Color.Black, new Font("Areal", 9), StringAlignment.Center, Color.Black, Color.Azure, 1); // if (LinReg(5)[0] > GapOpen) if (LinReg(Closes[0], 5)[0] > GapOpen) { //Chancenreicher SuccessTrade string strArrowUp = "ArrowUp" + Bars.GetTime(CurrentBar); DrawArrowUp(strArrowUp, true, Bars.GetTime(Count - 1), Bars.GetOpen(CurrentBar) - 300 * TickSize, Color.Green); GapTradeLong = true; Occurred.Set(1); Entry.Set(Bars.GetOpen(CurrentBar)); } } else { //Short //DrawRectangle(strMyRect, true, LastDayCloseDate, LastDayClose, LastPeriod, LowestLowPrice(5)[0], Color.Pink, Color.Pink, 70); DrawText(strMyGapSize, true, Math.Round(GapSize, 1).ToString(), LastDayCloseDate, LastDayClose - 25, 9, Color.Black, new Font("Areal", 9), StringAlignment.Center, Color.Black, Color.Azure, 1); if (LinReg(Closes[0], 5)[0] < GapOpen) { ////Chancenreicher SuccessTrade string strArrowDown = "ArrowDown" + Bars.GetTime(CurrentBar); DrawArrowDown(strArrowDown, true, Bars.GetTime(Count - 1), Bars.GetOpen(CurrentBar) + 300 * TickSize, Color.Red); GapTradeShort = true; Occurred.Set(-1); Entry.Set(Bars.GetOpen(CurrentBar)); } } if (GapTradeShort == true || GapTradeLong == true) { Print("------------------" + Time[5] + "------------------"); Print("LineReg: " + Math.Round(LinReg(5)[0]), 1); Print("Gap Open: " + GapOpen); } } else { existgap = false; } } //09.15. - 09.30 Kerze else if (Bars.BarsSinceSession == 6 && existgap == true) { //Auswertung decimal GapTradeResult; Color colorTextBox; GapTradeResult = (decimal)Bars.GetClose(CurrentBar - 1) - (decimal)Bars.GetOpen(CurrentBar - 1); if (GapTradeLong == true) { //Long GapTradeCounterLong += 1; GapTradeResultTotalLong = GapTradeResultTotalLong + GapTradeResult; string strGapeTradeLong = "GapTradeLong" + CurrentBar; string strTradeResultLong; if (GapTradeResult < 0) { Print("FAAAAAAAAAAAAAAAIIIIIIIIIIIIIILLLLLLLLLL"); GapTradeFailCounterLong += 1; strTradeResultLong = "Fail " + GapTradeResult.ToString(); colorTextBox = colFail; } else { GapTradeWinCounterLong += 1; strTradeResultLong = "Win " + GapTradeResult.ToString(); colorTextBox = colWin; } DrawText(strGapeTradeLong, true, strTradeResultLong, Time[1], Bars.GetHigh(CurrentBar - 1) + 10, 9, Color.Black, new Font("Areal", 9), StringAlignment.Center, Color.Black, colorTextBox, 70); } else if (GapTradeShort == true) { //Short GapTradeCounterShort += 1; GapTradeResultTotalShort = GapTradeResultTotalShort - GapTradeResult; string strGapeTradeShort = "GapTradeLong" + CurrentBar; string strTradeResultShort; if (GapTradeResult > 0) { Print("FAAAAAAAAAAAAAAAIIIIIIIIIIIIIILLLLLLLLLL"); GapTradeFailCounterShort += 1; strTradeResultShort = "Fail " + GapTradeResult.ToString(); colorTextBox = colFail; } else { GapTradeWinCounterShort += 1; strTradeResultShort = "Win " + GapTradeResult.ToString(); colorTextBox = colWin; } DrawText(strGapeTradeShort, true, strTradeResultShort, Time[1], Bars.GetLow(CurrentBar - 1) - 10, 9, Color.Black, new Font("Areal", 9), StringAlignment.Center, Color.Black, colorTextBox, 70); } Print("Gap Trade Result: " + GapTradeResult); } if (Count == Bars.Count - 1) { Print("Total Trades Long: " + GapTradeCounterLong); Print("Wins Long: " + GapTradeWinCounterLong); Print("Fails Long: " + GapTradeFailCounterLong); Print("Total Trades Short: " + GapTradeCounterShort); Print("Wins Short: " + GapTradeWinCounterShort); Print("Fails Short: " + GapTradeFailCounterShort); if (GapTradeCounterLong > 0) { Print("Avg Long: " + (GapTradeResultTotalLong / GapTradeCounterLong)); } if (GapTradeCounterShort > 0) { Print("Avg Short: " + (GapTradeResultTotalShort / GapTradeCounterShort)); } } }
protected override void OnCalculate() { Occurred.Set(1); Stop.Set(Close[0] * (1 - this.PercentageTrailing / 100.0)); }