private void Falling() { double limit; while (closePrice < (limit = Asset.Round(openPrice - wickoSize))) { var wicko = GetNewWicko( openPrice, highPrice, limit, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openPrice = limit; highPrice = limit; } }
private void Falling() { double limit; while (closeRate < (limit = (openRate - wickoSize) .ToRoundedRate(Symbol))) { var wicko = GetNewWicko( openRate, highRate, limit, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openRate = limit; highRate = limit; } }
public void HandleTick(BidAsk bidAsk) { if (firstTick) { firstTick = false; openOn = bidAsk.TickOnEst; closeOn = bidAsk.TickOnEst; openPrice = bidAsk.MidPrice; highPrice = bidAsk.MidPrice; lowPrice = bidAsk.MidPrice; closePrice = bidAsk.MidPrice; } else { closeOn = bidAsk.TickOnEst; if (bidAsk.MidPrice > highPrice) { highPrice = bidAsk.MidPrice; } if (bidAsk.MidPrice < lowPrice) { lowPrice = bidAsk.MidPrice; } closePrice = bidAsk.MidPrice; if (closePrice > openPrice) { if (lastWicko == null || (lastWicko.Trend == Trend.Rising)) { Rising(); return; } var limit = Asset.Round(lastWicko.OpenPrice + wickoSize); if (closePrice > limit) { var wicko = GetNewWicko( lastWicko.OpenPrice, limit, lowPrice, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openPrice = limit; lowPrice = limit; Rising(); } } else if (closePrice < openPrice) { if (lastWicko == null || (lastWicko.Trend == Trend.Falling)) { Falling(); return; } var limit = Asset.Round(lastWicko.OpenPrice - wickoSize); if (closePrice < limit) { var wicko = GetNewWicko( lastWicko.OpenPrice, highPrice, limit, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openPrice = limit; highPrice = limit; Falling(); } } } }
public void HandleTick(Tick tick) { var rate = tick.ToRate(rateToUse); if (firstTick) { firstTick = false; openOn = tick.TickOn; closeOn = tick.TickOn; openRate = rate; highRate = rate; lowRate = rate; closeRate = rate; } else { closeOn = tick.TickOn; if (rate > highRate) { highRate = rate; } if (rate < lowRate) { lowRate = rate; } closeRate = rate; if (closeRate > openRate) { if (lastWicko == null || (lastWicko.Trend == Trend.Rising)) { Rising(); return; } var limit = (lastWicko.OpenRate + wickoSize) .ToRoundedRate(Symbol); if (closeRate > limit) { var wicko = GetNewWicko( lastWicko.OpenRate, limit, lowRate, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openRate = limit; lowRate = limit; Rising(); } } else if (closeRate < openRate) { if (lastWicko == null || (lastWicko.Trend == Trend.Falling)) { Falling(); return; } var limit = (lastWicko.OpenRate - wickoSize) .ToRoundedRate(Symbol); if (closeRate < limit) { var wicko = GetNewWicko( lastWicko.OpenRate, highRate, limit, limit); lastWicko = wicko; OnWicko?.Invoke(this, new WickoArgs(wicko)); openOn = closeOn; openRate = limit; highRate = limit; Falling(); } } } }