SignalOnCalculate Method (MarketDataEventArgs, Int32, SignalDirection) |
Namespace: MZpack.NT8.Algo
public override void OnCalculate( MarketDataEventArgs e, int barIdx, SignalDirection allowed )
public override void OnCalculate(MarketDataEventArgs e, int barIdx, SignalDirection allowed) { IFootprintBar _bar; if (indicator.FootprintBars.TryGetValue(barIdx, out _bar)) { int buyAbsCnt = _bar.AbsorptionSRZones.Zones[(int)TradeSide.Ask].Count; int sellAbsCnt = _bar.AbsorptionSRZones.Zones[(int)TradeSide.Bid].Count; SignalDirection dir; if (buyAbsCnt > 0 && sellAbsCnt == 0) dir = SignalDirection.Short; else if (sellAbsCnt > 0 && buyAbsCnt == 0) dir = SignalDirection.Long; else dir = SignalDirection.None; dir = Signal.ResolveDirection(dir, allowed); // Resolve calculated direction using allowed one. if (Signal.IsDetermined(dir)) // This signal must be LONG or SHORT only. { Direction = dir; Time = e.Time; EntryPrice = e.Price; ChartRange = new ChartRange() { MinBarIdx = barIdx, MaxBarIdx = barIdx, Low = e.Price, High = e.Price }; Description = $"{GetType().Name}: Buy absoprtion zone(s) {buyAbsCnt}, Sell absoprtion zone(s) {sellAbsCnt}"; bar = _bar; // Show plots of the signal in partially visible mode during pattern validation process bar.PartiallyVisible = true; } } }