protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. Plot0.Set(Close[0]); Plot1.Set(Close[0]); Plot3.Set(Close[0]); }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar < 5) { return; } if (MACD(12, 26, 9).Diff[0] >= MACD(12, 26, 9).Diff[1]) { if ((MACD(12, 26, 9).Diff[1] < MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] < MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] < MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] < MACD(12, 26, 9).Diff[5])) { Plot5.Set(MACD(12, 26, 9).Diff[0]); } else { Plot5.Set(0); Plot1.Set(MACD(12, 26, 9).Diff[0]); } } else { Plot1.Set(0); } if (MACD(12, 26, 9).Diff[0] < MACD(12, 26, 9).Diff[1]) { if ((MACD(12, 26, 9).Diff[1] >= MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] >= MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] >= MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] >= MACD(12, 26, 9).Diff[5])) { Plot4.Set(MACD(12, 26, 9).Diff[0]); } else { Plot4.Set(0); Plot0.Set(MACD(12, 26, 9).Diff[0]); } } else { Plot0.Set(0); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 1) { return; } if ((High[0] > High[1]) & (Open[0] > Close[0]) & (Close[0] < Close[1])) { Plot0.Set(1); } if ((Low[0] < Low[1]) & (Close[0] > Open[0]) & (Close[0] > Close[1])) { Plot1.Set(1); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. // Plot0.Set(Close[0]); if (CurrentBar < 1) { return; } starttime = Time[1]; durationtime = Time[0] - starttime; totalseconds = (int)durationtime.TotalSeconds; if (totalseconds > myInput0) { totalseconds = myInput0; secperbar.Set(totalseconds); if (drawSMA) { Plot0.Set(SMA(secperbar, sMAPeriod)[0]); } Plot1.Set(totalseconds); // PlotColors[0][0] = Color.Red; PlotColors[1][0] = Color.Red; } else { secperbar.Set(totalseconds); if (drawSMA) { Plot0.Set(SMA(secperbar, sMAPeriod)[0]); } Plot1.Set(totalseconds); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 1) { return; } if ((EMA(fastEMA)[0] > EMA(slowEMA)[0]) & !(EMA(fastEMA)[1] > EMA(slowEMA)[1])) { Plot0.Set(1); //blue } if ((EMA(slowEMA)[0] > EMA(fastEMA)[0]) & !(EMA(slowEMA)[1] > EMA(fastEMA)[1])) { Plot1.Set(1); //red } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 4) { return; } if ((High[2] >= High[0]) && (High[2] >= High[1]) && (High[2] >= High[3]) && (High[2] >= High[4])) { Plot0.Set(2, 1); return; } if ((Low[2] <= Low[0]) && (Low[2] <= Low[1]) && (Low[2] <= Low[3]) && (Low[2] <= Low[4])) { Plot1.Set(2, 1); return; } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 30) { return; } if ((Low[0] <= DonchianChannel(14)[0]) & (Low[1] > DonchianChannel(14)[1])) { Plot1.Set(1); } if ((High[0] >= DonchianChannel(14)[0]) & (High[1] < DonchianChannel(14)[1])) { Plot0.Set(1); } int up = 0; int down = 0; int y = 0; for (int x = 1; x <= 100; x++) { if ((Low[x] <= DonchianChannel(14)[x]) & (Low[x + 1] > DonchianChannel(14)[x + 1])) { up = 1; y = x; break; } if ((High[x] >= DonchianChannel(14)[x]) & (High[x + 1] < DonchianChannel(14)[x + 1])) { down = 1; y = x; break; } } int firstup = 0; int firstdown = 0; for (int x = 0; x <= 100; x++) { if ((up == 1) & (High[x] > High[x + 1])) { if (x >= y) { break; } if (x != 0) { firstup = 1; break; } /* * if (!(x < y)) * { * break; * }*/ } if ((down == 1) & (Low[x] < Low[x + 1])) { if (x >= y) { break; } if (x != 0) { firstdown = 1; break; } /* * if (!(x < y)) * { * break; * }*/ } } if ((firstup == 0) & (up == 1) & (High[0] > High[1])) { Plot3.Set(1); } if ((firstdown == 0) & (down == 1) & (Low[0] < Low[1])) { Plot2.Set(1); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Try to connect, if we are not yet connected. // We do this here so that we do not connect everytime the indicator is instanciated. // Indicators are often instanciated several times before they are actually used. if (_indicatorState == IndicatorState.Uninitialized) { OpenConnection(); } // Are we in an error state? If so, display and exit. if (_indicatorState == IndicatorState.Error) { DrawError(); return; } // If we are actually connected to a socket, then communicate with it. if (_sock != null) { StringBuilder line = new StringBuilder(); long when = Time[0].Second + Time[0].Minute * 100l + Time[0].Hour * 10000l + Time[0].Day * 1000000l + Time[0].Month * 100000000l + Time[0].Year * 10000000000l; line.Append("\"" + PACKET_BAR + "\","); line.Append(when); line.Append(",\""); line.Append(this.Instrument.FullName); line.Append("\""); foreach (string name in _sourceData) { IDataSeries source; int totalBars = 1; string name2 = name; ParseArraySize(name, ref totalBars, ref name2); if (string.Compare(name2, "HIGH", true) == 0) { source = High; } else if (string.Compare(name2, "LOW", true) == 0) { source = Low; } else if (string.Compare(name2, "OPEN", true) == 0) { source = Open; } else if (string.Compare(name2, "CLOSE", true) == 0) { source = Close; } else if (string.Compare(name2, "VOL", true) == 0) { source = Volume; } else if (string.Compare(name2, "THIS", true) == 0) { source = Values[0]; } else { source = Eval(name2); if (source == null) { return; } } // now copy needed data var cnt = CurrentBar + 1; for (int i = 0; i < totalBars; i++) { line.Append(","); if (i >= cnt) { line.Append("?"); } else { //line.Append(Convert.ToString(source[i])); line.Append(Convert.ToString(source[i], _cultureUSA)); } } } Send(line.ToString()); // if we are expecting data back from the socket, then wait for it. if (_blockingMode) { // we are now waiting for a bar _indicatorState = IndicatorState.SentBar; while (_indicatorState != IndicatorState.Error && _indicatorState != IndicatorState.Ready) { WaitForPacket(); } // we got a bar message, then display it if (_indicatorState == IndicatorState.Ready) { if (!double.IsNaN(_indicatorData[0])) { Plot1.Set(_indicatorData[0]); } if (!double.IsNaN(_indicatorData[1])) { Plot2.Set(_indicatorData[1]); } if (!double.IsNaN(_indicatorData[2])) { Plot3.Set(_indicatorData[2]); } if (!double.IsNaN(_indicatorData[3])) { Bar1.Set(_indicatorData[3]); } if (!double.IsNaN(_indicatorData[4])) { Bar2.Set(_indicatorData[4]); } if (!double.IsNaN(_indicatorData[5])) { Bar3.Set(_indicatorData[5]); } if (!double.IsNaN(_indicatorData[6])) { IndSell.Set(_indicatorData[6]); } if (!double.IsNaN(_indicatorData[7])) { IndBuy.Set(_indicatorData[7]); } } } else { var hold = this.DrawOnPricePanel; DrawOnPricePanel = false; DrawTextFixed("general msg", "This indicator only sends data, so there is no display.", TextPosition.Center); DrawOnPricePanel = hold; } } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 10) { return; } if (High[2] < High[3] && High[1] < High[3]) { // Fractal type 1 if (High[5] < High[3] && High[4] < High[3]) { upFractal = High[3]; } // Fractal type 2 else if (High[6] < High[3] && High[5] < High[3] && High[4] == High[3]) { upFractal = High[3]; } // Fractal type 3, 4 else if (High[7] < High[3] && High[6] < High[3] && High[5] == High[3] && High[4] <= High[3]) { upFractal = High[3]; } // Fractal type 5 else if (High[8] < High[3] && High[7] < High[3] && High[6] == High[3] && High[5] < High[3] && High[4] == High[3]) { upFractal = High[3]; } // Fractal type 6 else if (High[8] < High[3] && High[7] < High[3] && High[6] == High[3] && High[5] == High[3] && High[4] < High[3]) { upFractal = High[3]; } // Fractal type 7 else if (High[9] < High[3] && High[8] < High[3] && High[7] == High[3] && High[6] < High[3] && High[5] == High[3] && High[4] < High[3]) { upFractal = High[3]; } } if (Low[2] > Low[3] && Low[1] > Low[3]) { // Fractal type 1 if (Low[5] > Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } // Fractal type 2 else if (Low[6] > Low[3] && Low[5] > Low[3] && Low[4] == Low[3]) { downFractal = Low[3]; } // Fractal type 3, 4 else if (Low[7] > Low[3] && Low[6] > Low[3] && Low[5] == Low[3] && Low[4] >= Low[3]) { downFractal = Low[3]; } // Fractal type 5 else if (Low[8] > Low[3] && Low[7] > Low[3] && Low[6] == Low[3] && Low[5] > Low[3] && Low[4] == Low[3]) { downFractal = Low[3]; } // Fractal type 6 else if (Low[8] > Low[3] && Low[7] > Low[3] && Low[6] == Low[3] && Low[5] == Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } // Fractal type 7 else if (Low[9] > Low[3] && Low[8] > Low[3] && Low[7] == Low[3] && Low[6] > Low[3] && Low[5] == Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } } if (upFractal != 0) { Plot0.Set(upFractal); } if (downFractal != 0) { Plot1.Set(downFractal); } if (Math.Abs(Math.Abs(upFractalSeries[0]) - Math.Abs(upFractalSeries[1])) <= 0.0001) { upFractalSeries[0] = upFractalSeries[1]; } else { upFractalSeries[0] = upFractal; } if (Math.Abs(Math.Abs(downFractalSeries[0]) - Math.Abs(downFractalSeries[1])) <= 0.0001) { downFractalSeries[0] = downFractalSeries[1]; } else { downFractalSeries[0] = downFractal; } }