update
This commit is contained in:
parent
9cde60bb9c
commit
c35d84cf07
11 changed files with 2109 additions and 68 deletions
|
|
@ -11,10 +11,12 @@ import { Order } from "../dao/order";
|
|||
import { supabase } from "./supabaseService";
|
||||
import { Wave } from "../dao/wave";
|
||||
|
||||
export type EventType = "HighVolatility" | "PinBar" | "EmaCross" | "MacdCross" | "MacdCrossUp" | "MacdCrossDown" | "Touch200" | "Reverse200";
|
||||
|
||||
export interface EventHandler {
|
||||
onBuy: (candle: Order, reason: string) => void;
|
||||
onSell: (candle: Order, reason: string) => void;
|
||||
onEvent: (data: any, eventType: string) => void;
|
||||
onEvent: (eventType: EventType, analysis: Analysis) => void;
|
||||
}
|
||||
|
||||
export class IndicatorService {
|
||||
|
|
@ -77,6 +79,8 @@ export class IndicatorService {
|
|||
isSell: false,
|
||||
isTouch200: false,
|
||||
isReverse200: false,
|
||||
isOverBbUpper: false,
|
||||
isUnderBbLower: false,
|
||||
lowHight: wave.lowOrHighPrice,
|
||||
numberTouch200: wave.numberTouchEma,
|
||||
numberMacdCrossUp: wave.numberMacdCrossUp,
|
||||
|
|
@ -94,6 +98,14 @@ export class IndicatorService {
|
|||
analysis.currentBB.middle = bb[0].middle;
|
||||
analysis.currentBB.lower = bb[0].lower;
|
||||
|
||||
if (candles[0].high > analysis.currentBB.upper) {
|
||||
analysis.isOverBbUpper = true;
|
||||
}
|
||||
|
||||
if (candles[0].low < analysis.currentBB.lower) {
|
||||
analysis.isUnderBbLower = true;
|
||||
}
|
||||
|
||||
if (ema34[0] > ema200[0]) {
|
||||
if (wave.trend === "Bearish") {
|
||||
analysis.numberTouch200 = 0;
|
||||
|
|
@ -241,6 +253,7 @@ export class IndicatorService {
|
|||
|
||||
const order: Order = {
|
||||
symbol: analysis.symbol,
|
||||
interval: analysis.interval,
|
||||
side,
|
||||
entry,
|
||||
stopLoss: side === "buy" ? lowestPrice : highestPrice,
|
||||
|
|
@ -287,6 +300,10 @@ export class IndicatorService {
|
|||
const order = this.makeOrder(analysis, candles, "sell");
|
||||
eventHandler.onSell(order, "Counter trend rủi ro cao MACD Cross Down");
|
||||
}
|
||||
|
||||
if (analysis.isHighVolatility) {
|
||||
eventHandler.onEvent("HighVolatility", analysis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue