/// <inheritdoc/> public override void NotifyPacket(IndicatorPacket packet) { if (string.Compare(packet.Command, IndicatorLink.PacketBar, true) == 0) { String security = packet.Args[1]; long when = long.Parse(packet.Args[0]); String key = security.ToLower(); InstrumentHolder holder; if (_data.ContainsKey(key)) { holder = _data[key]; } else { holder = new InstrumentHolder(); _data[key] = holder; } if (holder.Record(when, 2, packet.Args)) { _rowsDownloaded++; } } }
public override void NotifyPacket(IndicatorPacket packet) { if (string.Compare(packet.Command, IndicatorLink.PacketBar, true) == 0) { double dataClose = CSVFormat.EgFormat.Parse(packet.Args[2]); double lastValue = CSVFormat.EgFormat.Parse(packet.Args[4]); const double period = 14; double result; if (double.IsNaN(lastValue)) { result = dataClose; } else { result = dataClose * (2.0 / (1 + period)) + (1 - (2.0 / (1 + period))) * lastValue; } String[] args = { CSVFormat.EgFormat.Format(result, EncogFramework.DefaultPrecision), "?", "?", "?", "?", "?", "?", "?" }; Link.WritePacket(IndicatorLink.PacketInd, args); } }
/// <summary> /// Called to notify the indicator that a bar has been received. /// </summary> /// <param name="packet">The packet received.</param> public override void NotifyPacket(IndicatorPacket packet) { long when = long.Parse(packet.Args[0]); if (_method == null) { if (_holder.Record(when, 2, packet.Args)) { _rowsDownloaded++; } } else { var input = new BasicMLData(Config.PredictWindow); const int fastIndex = 2; const int slowIndex = fastIndex + Config.InputWindow; for (int i = 0; i < 3; i++) { double fast = CSVFormat.EgFormat.Parse(packet.Args[fastIndex + i]); double slow = CSVFormat.EgFormat.Parse(packet.Args[slowIndex + i]); double diff = _fieldDifference.Normalize((fast - slow) / Config.PipSize); input[i] = _fieldDifference.Normalize(diff); } IMLData result = _method.Compute(input); double d = result[0]; d = _fieldOutcome.DeNormalize(d); String[] args = { "?", // line 1 "?", // line 2 CSVFormat.EgFormat.Format(d, EncogFramework.DefaultPrecision), // bar 1 }; // arrow 2 Link.WritePacket(IndicatorLink.PacketInd, args); } }
public abstract void NotifyPacket(IndicatorPacket packet);