UNPKG

@sunrise1002/tats

Version:

Techincal Indicators written in javascript

24 lines (23 loc) 863 B
import CandlestickFinder from './CandlestickFinder'; import { averageloss } from '../Utils/AverageLoss'; import { averagegain } from '../Utils/AverageGain'; export default class TweezerTop extends CandlestickFinder { constructor() { super(); this.name = 'TweezerTop'; this.requiredCount = 5; } logic(data) { return this.upwardTrend(data) && data.high[3] == data.high[4]; } upwardTrend(data) { // Analyze trends in closing prices of the first three or four candlesticks let gains = averagegain({ values: data.close.slice(0, 3), period: 2 }); let losses = averageloss({ values: data.close.slice(0, 3), period: 2 }); // Upward trend, so more gains than losses return gains > losses; } } export function tweezertop(data) { return new TweezerTop().hasPattern(data); }