protected override void OnCalculate() { int returnvalue = calculate(Bars, ProcessingBarIndex, this.PopGunType); OutSeries.Set(returnvalue); if (ProcessingBarIndex <= this.PopGunTarget) { Outputs[1].Set(0); //Indicates that there is a PopGun Trigger! } }
//Ermittlung ob Trade chancenreich wäre (Short) private bool GapIndicatesTradeShort() { if (dev_mode == true) { OutSeries.Set(-100); return(true); } if (LinReg(Closes[0], Bars.BarsCountForSession)[0] < GapOpen && Math.Abs((decimal)GapSize) > PunkteGapMin && Math.Abs((decimal)GapSize) < PunkteGapMax) { OutSeries.Set(-100); return(true); } else { OutSeries.Set(0); return(false); } }
//Ermittlung ob Trade chancenreich wäre (Long) private bool GapIndicatesTradeLong() { if (dev_mode == true) { OutSeries.Set(100); return(true); } if (LinReg(Closes[0], Bars.BarsCountForSession)[0] > GapOpen && (decimal)GapSize > PunkteGapMin && (decimal)GapSize < PunkteGapMax) { OutSeries.Set(100); return(true); } else { OutSeries.Set(0); return(false); } }
protected override void OnCalculate() { string strReversalTradeLong = "ReversalTradeLong" + ProcessingBarIndex; string strReversalTradeShort = "ReversalTradeShort" + ProcessingBarIndex; string strTradeResultLong; string strTradeResultShort; Color colorTextBox; // 1 umkehr fallend auf steigend //-1 umkehr steigend auf fallend if (IsReversalLongTrade() == true) { ReversalTradeStartTSLong = Bars[0].Time; //TargetBarTime = GetTargetBar(Bars[0].Time); TargetBarTime = GlobalUtilities.GetTargetBar(Bars, Bars[0].Time, TimeFrame, 1); OutSeries.Set(100); Reversal2NextBar.Set(100); } else if (IsReversalShortTrade() == true) { ReversalTradeStartTSShort = Bars[0].Time; //TargetBarTime = GetTargetBar(Bars[0].Time); TargetBarTime = GlobalUtilities.GetTargetBar(Bars, Bars[0].Time, TimeFrame, 1); OutSeries.Set(-100); } else { Reversal2NextBar.Set(0); } //TradingKerze ist fertig, Zeiteinheit ist abgelaufen if (Bars[0].Time == TargetBarTime) { ReversalTradeResult = (decimal)Bars.GetClose(ProcessingBarIndex) - (decimal)Bars.GetOpen(ProcessingBarIndex); TradeCounter += 1; if (ReversalTradeStartTSLong > DateTime.MinValue) { ReversalTradeResultTotalLong = ReversalTradeResultTotalLong + ReversalTradeResult; if (ReversalTradeResult < 0) { strTradeResultLong = "Fail " + ReversalTradeResult.ToString(); colorTextBox = colFail; TradeCounterLongFail += 1; } else { strTradeResultLong = "Win " + ReversalTradeResult.ToString(); colorTextBox = colWin; TradeCounterLongWin += 1; } AddChartText(strReversalTradeLong, true, strTradeResultLong, Time[1], Bars.GetHigh(ProcessingBarIndex) + (100 * TickSize), 9, Color.Black, new Font("Arial", 9), StringAlignment.Center, Color.Black, colorTextBox, 70); } else if (ReversalTradeStartTSShort > DateTime.MinValue) { ReversalTradeResultTotalShort = ReversalTradeResultTotalShort + ReversalTradeResult; if (ReversalTradeResult < 0) { strTradeResultShort = "Win " + ReversalTradeResult.ToString(); colorTextBox = colWin; TradeCounterShortWin += 1; } else { strTradeResultShort = "Fail " + ReversalTradeResult.ToString(); colorTextBox = colFail; TradeCounterShortFail += 1; } AddChartText(strReversalTradeShort, true, strTradeResultShort, Time[1], Bars.GetHigh(ProcessingBarIndex) - (100 * TickSize), 9, Color.Black, new Font("Arial", 9), StringAlignment.Center, Color.Black, colorTextBox, 70); } //Variablen Resetten ReversalTradeStartTSLong = DateTime.MinValue; ReversalTradeStartTSShort = DateTime.MinValue; } if (IsProcessingBarIndexLast) { // Print("LongWin: " + TradeCounterLongWin + " LongFail: " + TradeCounterLongFail + " ShortWin: " + TradeCounterShortWin + " ShortFail: " + TradeCounterShortFail); // Print(Instrument.Name + "Trades: " + TradeCounter + " LongPunkte: " + ReversalTradeResultTotalLong + " ShortPunkte: " + ReversalTradeResultTotalShort); } }
protected override void OnCalculate() { if (this.DatafeedPeriodicityIsValid(Bars)) { //new day session is beginning so we need to calculate the open range breakout //if we are calculation "older" trading days the whole day will be calculated because to enhance performance. if (this.CurrentdayOfUpdate.Date < Bars[0].Time.Date) { ORB_Result resultvalue = calculate(this.Bars, this.Bars[0]); //Draw if the calculate method was processed till the end if (resultvalue.IsCompleted) { //Set Color for open range Color openrangecolorvalidornot = this.Color_ORB; if (!resultvalue.IsORBValid) { openrangecolorvalidornot = this.Color_ORB_invalid; } //Draw the Open Range AddChartRectangle("ORBRect" + resultvalue.StartDate.Ticks, true, resultvalue.Start, this.RangeLow, resultvalue.End, this.RangeHigh, openrangecolorvalidornot, openrangecolorvalidornot, this.Opacity); AddChartText("ORBRangeString" + resultvalue.StartDate.Ticks, true, Math.Round((this.RangeHeight), 2).ToString(), resultvalue.Start, this.RangeHigh, 9, Color.Black, new Font("Arial", 9), StringAlignment.Center, Color.Gray, openrangecolorvalidornot, this.Opacity); //if we are live on the trading day if (this.Bars.Last().Time.Date == resultvalue.StartDate) { AddChartHorizontalLine("LowLine" + resultvalue.StartDate.Ticks, true, this.RangeLow, openrangecolorvalidornot, this.CurrentSessionLineStyle, this.CurrentSessionLineWidth); AddChartHorizontalLine("HighLine" + resultvalue.StartDate.Ticks, true, this.RangeHigh, openrangecolorvalidornot, this.CurrentSessionLineStyle, this.CurrentSessionLineWidth); } //Draw the target areas AddChartRectangle("TargetAreaLong" + resultvalue.StartDate.Ticks, true, this.getOpenRangeEnd(this.getOpenRangeStart(this.Bars, resultvalue.StartDate)), this.RangeHigh, this.getEndOfTradingDay(this.Bars, resultvalue.StartDate), this.TargetLong, this.Color_TargetAreaLong, this.Color_TargetAreaLong, this.Opacity); AddChartRectangle("TargetAreaShort" + resultvalue.StartDate.Ticks, true, this.getOpenRangeEnd(this.getOpenRangeStart(this.Bars, resultvalue.StartDate)), this.RangeLow, this.getEndOfTradingDay(this.Bars, resultvalue.StartDate), this.TargetShort, this.Color_TargetAreaShort, this.Color_TargetAreaShort, this.Opacity); } } //Set the indicator value on each bar update, if the breakout is on the current bar if (this.LongBreakout != null && this.LongBreakout.Time == Bars[0].Time) { BarColor = Color.Turquoise; OutSeries.Set(1); AddChartArrowUp("ArrowLong" + Bars[0].Time.Date.Ticks, true, this.LongBreakout.Time, this.LongBreakout.Low, Color.Green); } else if (this.ShortBreakout != null && this.ShortBreakout.Time == Bars[0].Time) { BarColor = Color.Purple; OutSeries.Set(-1); AddChartArrowDown("ArrowShort" + Bars[0].Time.Date.Ticks, true, this.ShortBreakout.Time, this.ShortBreakout.High, Color.Red); } else { OutSeries.Set(0); } //Draw the Long Target if this is necessary if (this.LongTargetReached != null) { AddChartArrowDown("ArrowTargetLong" + Bars[0].Time.Date.Ticks, true, this.LongTargetReached.Time, this.LongTargetReached.High, Color.Red); } //Draw the Short Target if this is necessary if (this.ShortTargetReached != null) { AddChartArrowUp("ArrowTargetShort" + Bars[0].Time.Date.Ticks, true, this.ShortTargetReached.Time, this.ShortTargetReached.Low, Color.Green); } //Set the color PlotColors[0][0] = this.Plot1Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; //When finished set the last day variable //If we are online during the day session we do not set this variable so we are redrawing and recalculating the current session again and again if (GlobalUtilities.IsCurrentBarLastDayInBars(this.Bars, this.Bars[0])) { //the last session has started (current trading session, last day in Bars object, and so on) } else { this.CurrentdayOfUpdate = this.Bars[0].Time.Date; } } else { //Data feed perodicity is not valid, print info in chart panel if (IsProcessingBarIndexLast) { AddChartTextFixed("AlertText", Const.DefaultStringDatafeedPeriodicity, TextPosition.Center, Color.Red, new Font("Arial", 30), Color.Red, Color.Red, 20); } } }