From 1bfc763bde40db1a15ed773a1470610e0444d7bb Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 20 May 2025 12:34:26 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndicatorProcess.cs | 27 ++++++++++--------- .../TradingViewConditionSetup.cs | 21 +++++++++++++-- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs index 04d1a62..923e97e 100644 --- a/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs +++ b/BitgetApi/IndicatorConditionSetup/IndicatorProcess.cs @@ -712,11 +712,11 @@ namespace BitgetAPI.IndicatorConditionSetup if (tradingViewConditionSetup.IsLongSignal()) { BuyLongStep[market] = 1; - BuyLongStepStampData[market] = 저고점_30["tempLowVal"]; + //BuyLongStepStampData[market] = 저고점_30["tempLowVal"]; } } - if(BuyLongStep[market] == 1 && BuyLongStepStampData[market] < 저고점_30["tempLowVal"]) + if(BuyLongStep[market] == 1 )//&& BuyLongStepStampData[market] < 저고점_30["tempLowVal"]) { buyFlag = ((저고점_30["Type"] == 0 && 저고점_30["전전전저가"] > 저고점_30["전전저가"] && 저고점_30["전전저가"] < 저고점_30["전저가"] && candleData_30_전봉.Close < 저고점_30["전고가"] && candleData_30.Close > 저고점_30["전고가"]) @@ -729,7 +729,8 @@ namespace BitgetAPI.IndicatorConditionSetup //초기화 처리 필요 if (저고점_30["전고가"] < 저고점_30["전전고가"] || - 저고점_30["전저가"] < 저고점_30["전전저가"]) + 저고점_30["전저가"] < 저고점_30["전전저가"] || + tradingViewConditionSetup.IsShortSignal()) { BuyLongStep[market] = 0; buyFlag = false; @@ -824,9 +825,9 @@ namespace BitgetAPI.IndicatorConditionSetup var sellFlag = false; - if(tradingViewConditionSetup.IsSmaMiddle(4, 12, true) || - 저고점_30["전고가"] < 저고점_30["전전고가"] || - 저고점_30["전저가"] > candleData_30_전봉.Close) + if( 저고점_30["전고가"] < 저고점_30["전전고가"] || + 저고점_30["전저가"] > candleData_30_전봉.Close || + tradingViewConditionSetup.IsShortSignal()) { sellFlag = true; } @@ -932,11 +933,11 @@ namespace BitgetAPI.IndicatorConditionSetup if (tradingViewConditionSetup.IsShortSignal()) { BuyShortStep[market] = 1; - BuyShortStepStampData[market] = 저고점_30["tempHighVal"]; + //BuyShortStepStampData[market] = 저고점_30["tempHighVal"]; } } - if (BuyShortStep[market] == 1 && BuyShortStepStampData[market] < 저고점_30["tempHighVal"]) + if (BuyShortStep[market] == 1)// && BuyShortStepStampData[market] < 저고점_30["tempHighVal"]) { buyFlag = ((저고점_30["Type"] == 1 && 저고점_30["전전전고가"] < 저고점_30["전전고가"] && 저고점_30["전전고가"] > 저고점_30["전고가"] && candleData_30.Close < 저고점_30["전저가"] && candleData_30_전봉.Close > 저고점_30["전저가"]) @@ -948,7 +949,8 @@ namespace BitgetAPI.IndicatorConditionSetup //초기화 처리 필요 if (저고점_30["전고가"] > 저고점_30["전전고가"] || - 저고점_30["전저가"] > 저고점_30["전전저가"]) + 저고점_30["전저가"] > 저고점_30["전전저가"] || + tradingViewConditionSetup.IsLongSignal()) { BuyShortStep[market] = 0; buyFlag = false; @@ -1041,9 +1043,10 @@ namespace BitgetAPI.IndicatorConditionSetup } var sellFlag = false; - if (tradingViewConditionSetup.IsSmaMiddle(4, 12, false) || - 저고점_30["전저가"] > 저고점_30["전전저가"] || - 저고점_30["전고가"] < candleData_30_전봉.Close) + if (저고점_30["전저가"] > 저고점_30["전전저가"] || + 저고점_30["전고가"] < candleData_30_전봉.Close || + tradingViewConditionSetup.IsLongSignal()) + { sellFlag = true; } diff --git a/BitgetApi/IndicatorConditionSetup/TradingViewConditionSetup.cs b/BitgetApi/IndicatorConditionSetup/TradingViewConditionSetup.cs index a91def1..c645371 100644 --- a/BitgetApi/IndicatorConditionSetup/TradingViewConditionSetup.cs +++ b/BitgetApi/IndicatorConditionSetup/TradingViewConditionSetup.cs @@ -135,6 +135,19 @@ namespace BitgetApi.IndicatorConditionSetup return (macdLine, signalLine); } + // 7. MACD, SignalLine 계산(이전꺼) + public (double macdLine, double signalLine) PrevComputeMacd() + { + var temp = new List(); + foreach (var item in Close) + temp.Add(item); + temp.RemoveAt(temp.Count - 1); + + double macdLine = Ema(temp, 34) - Ema(temp, 12); + double signalLine = Ema(Enumerable.Repeat(macdLine, temp.Count).ToList(), 12); + return (macdLine, signalLine); + } + // 8. RangeBound 필터 public bool IsRangeBound() { @@ -164,10 +177,12 @@ namespace BitgetApi.IndicatorConditionSetup double md = ComputeMd(); double prevMd = ComputeMd(false); var (macd, signal) = ComputeMacd(); + var (prevMacd, prevSignal) = PrevComputeMacd(); + bool isUptrend = Close.Last() > Sma4.Last(); return isUptrend && - ((prevMd == 0 && md > 0) || (macd < 0 && macd > signal)) && + ((prevMd == 0 && md > 0) || (macd > prevMacd && signal > prevSignal && md > 0 && macd > signal)) && IsTrending() && !IsRangeBound(); } @@ -177,10 +192,12 @@ namespace BitgetApi.IndicatorConditionSetup double md = ComputeMd(); double prevMd = ComputeMd(false); var (macd, signal) = ComputeMacd(); + var (prevMacd, prevSignal) = PrevComputeMacd(); + bool isDowntrend = Close.Last() < Sma4.Last(); return isDowntrend && - ((prevMd == 0 && md < 0) || (macd > 0 && macd < signal)) && + ((prevMd == 0 && md < 0) || (macd < prevMacd && signal < prevSignal && md < 0 && macd < signal)) && IsTrending() && !IsRangeBoundSell(); }