커뮤니티

오류 수정 좀 부탁드립니다.

프로필 이미지
플로스트
2025-07-03 15:03:27
215
글번호 192278
답변완료
제가 나름 gpt로 코드를 수정해보려 했는데 초보라서 계속 오류만 발생하네요.ㅠㅠ 아래 코드가 무엇이 문제인지 수정 좀 부탁드립니다. input : atrLen(20), mode(1); # 1: Trending, 2: Scalping input : smoothingLen(10); input : showMA(true); var : priorATR(0), currentATR(0), factor(0); var : supertrend(0), direction(0), stopPrice(0); var : hl2(0), atrVal(0); hl2 = (h + l) / 2; # 현재 ATR 계산 currentATR = atr(atrLen); # 전일 ATR 계산 priorATR = atr(atrLen)[1]; # 적응형 배수 설정 if currentATR <= priorATR * 0.25 then factor = iff(mode = 2, 5.0, 1.0); else if currentATR <= priorATR * 0.5 then factor = iff(mode = 2, 3.0, 3.0); else if currentATR <= priorATR * 0.75 then factor = iff(mode = 2, 1.5, 4.0); else factor = iff(mode = 2, 1.0, 5.0); # Supertrend 계산 (기초선) supertrend = hl2 - factor * currentATR; direction = iff(close > supertrend, 1, -1); # Stop라인 조정: 슈퍼트렌드와 종가의 중간값을 이동 평균으로 부드럽게 처리 stopPrice = ma((close + supertrend)/2, smoothingLen); # 최종 슈퍼트렌드 라인 출력 plot1(stopPrice, "Adaptive SuperTrend", iff(direction > 0, red, blue)); # 사용자가 원하는 경우 MA 출력 if showMA then begin plot2(ma(close, atrLen), "Base MA", gray); end else begin NoPlot(2); end # Fill Zone 라인 (위/아래 경계선) var : uptrendStop(0), downtrendStop(0); uptrendStop = ma((high + supertrend) / 2, atrLen/ 2); downtrendStop = ma((low + supertrend) / 2, atrLen/ 2); plot3(iff(direction= 1, uptrendStop, na), "Buy Stop Line", darkgreen); plot4(iff(direction= -1, downtrendStop, na), "Sell Stop Line", darkred);
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-07-04 12:36:00

안녕하세요 예스스탁입니다. 예스랭귀지에서 같다라는 표현은 == 입니다. input : atrLen(20), mode(1); # 1: Trending, 2: Scalping input : smoothingLen(10); input : showMA(true); var : priorATR(0), currentATR(0), factor(0); var : supertrend(0), direction(0), stopPrice(0); var : hl2(0), atrVal(0); hl2 = (h + l) / 2; # 현재 ATR 계산 currentATR = atr(atrLen); # 전일 ATR 계산 priorATR = atr(atrLen)[1]; # 적응형 배수 설정 if currentATR <= priorATR * 0.25 then factor = iff(mode == 2, 5.0, 1.0); else if currentATR <= priorATR * 0.5 then factor = iff(mode == 2, 3.0, 3.0); else if currentATR <= priorATR * 0.75 then factor = iff(mode == 2, 1.5, 4.0); else factor = iff(mode == 2, 1.0, 5.0); # Supertrend 계산 (기초선) supertrend = hl2 - factor * currentATR; direction = iff(close > supertrend, 1, -1); # Stop라인 조정: 슈퍼트렌드와 종가의 중간값을 이동 평균으로 부드럽게 처리 stopPrice = ma((close + supertrend)/2, smoothingLen); # 최종 슈퍼트렌드 라인 출력 plot1(stopPrice, "Adaptive SuperTrend", iff(direction > 0, red, blue)); # 사용자가 원하는 경우 MA 출력 if showMA then begin plot2(ma(close, atrLen), "Base MA", gray); end else begin NoPlot(2); end # Fill Zone 라인 (위/아래 경계선) var : uptrendStop(0), downtrendStop(0); uptrendStop = ma((high + supertrend) / 2, atrLen/ 2); downtrendStop = ma((low + supertrend) / 2, atrLen/ 2); plot3(iff(direction== 1, uptrendStop, NaN), "Buy Stop Line", darkgreen); plot4(iff(direction== -1, downtrendStop, NaN), "Sell Stop Line", darkred); 즐거운 하루되세요 > 플로스트 님이 쓴 글입니다. > 제목 : 오류 수정 좀 부탁드립니다. > 제가 나름 gpt로 코드를 수정해보려 했는데 초보라서 계속 오류만 발생하네요.ㅠㅠ 아래 코드가 무엇이 문제인지 수정 좀 부탁드립니다. input : atrLen(20), mode(1); # 1: Trending, 2: Scalping input : smoothingLen(10); input : showMA(true); var : priorATR(0), currentATR(0), factor(0); var : supertrend(0), direction(0), stopPrice(0); var : hl2(0), atrVal(0); hl2 = (h + l) / 2; # 현재 ATR 계산 currentATR = atr(atrLen); # 전일 ATR 계산 priorATR = atr(atrLen)[1]; # 적응형 배수 설정 if currentATR <= priorATR * 0.25 then factor = iff(mode = 2, 5.0, 1.0); else if currentATR <= priorATR * 0.5 then factor = iff(mode = 2, 3.0, 3.0); else if currentATR <= priorATR * 0.75 then factor = iff(mode = 2, 1.5, 4.0); else factor = iff(mode = 2, 1.0, 5.0); # Supertrend 계산 (기초선) supertrend = hl2 - factor * currentATR; direction = iff(close > supertrend, 1, -1); # Stop라인 조정: 슈퍼트렌드와 종가의 중간값을 이동 평균으로 부드럽게 처리 stopPrice = ma((close + supertrend)/2, smoothingLen); # 최종 슈퍼트렌드 라인 출력 plot1(stopPrice, "Adaptive SuperTrend", iff(direction > 0, red, blue)); # 사용자가 원하는 경우 MA 출력 if showMA then begin plot2(ma(close, atrLen), "Base MA", gray); end else begin NoPlot(2); end # Fill Zone 라인 (위/아래 경계선) var : uptrendStop(0), downtrendStop(0); uptrendStop = ma((high + supertrend) / 2, atrLen/ 2); downtrendStop = ma((low + supertrend) / 2, atrLen/ 2); plot3(iff(direction= 1, uptrendStop, na), "Buy Stop Line", darkgreen); plot4(iff(direction= -1, downtrendStop, na), "Sell Stop Line", darkred);