커뮤니티
부탁드립니다
수고하십니다
아래수식을 오류 없게 수정부탁드립니다
Inputs:
ChannelLength(150), // 채널 길이
ChannelWidth(1.5), // 채널 폭
ShowMidLine(true), // 50선 표시
RSILength(14), // RSI 길이
RSIOpacity(70), // RSI 선 투명도 (0~100)
UpperThreshold(70), // Scale
ShowThresholdLabels(true), // 기준선 라벨 표시
ShowSignalLine(true), // Signal Line 표시
SignalLength(14); // Signal 길이
Variables:
SumX(0),
SumY(0),
SumXSqr(0),
SumXY(0),
Slope(0),
Intercept(0),
RegStart(0),
RegEnd(0),
Deviation(0),
UpperStart(0),
UpperEnd(0),
LowerStart(0),
LowerEnd(0),
RSIValue(0),
SmaRSI(0),
LowerThreshold(0),
StepValue(0),
SlopeValue(0),
i(0),
Val(0),
Per(0),
LowerVal(0),
RSIPlotValue(0),
SigPlotValue(0);
// 로그 회귀 계산
SumX = 0;
SumY = 0;
SumXSqr = 0;
SumXY = 0;
For i = 0 to ChannelLength - 1 Begin
Val = Log(Close[i]);
Per = i + 1;
SumX = SumX + Per;
SumY = SumY + Val;
SumXSqr = SumXSqr + (Per * Per);
SumXY = SumXY + (Val * Per);
End;
Slope = (ChannelLength * SumXY - SumX * SumY) / (ChannelLength * SumXSqr - SumX * SumX);
Intercept = (SumY - Slope * SumX) / ChannelLength;
// 회귀선 시작과 끝
RegStart = ExpValue(Intercept + Slope * ChannelLength);
RegEnd = ExpValue(Intercept);
// 표준편차
Deviation = StandardDev(Close, ChannelLength, 1);
// 채널 상단/하단
UpperStart = RegStart + Deviation * ChannelWidth;
UpperEnd = RegEnd + Deviation * ChannelWidth;
LowerStart = RegStart - Deviation * ChannelWidth;
LowerEnd = RegEnd - Deviation * ChannelWidth;
// RSI 계산
RSIValue = RSI(Close, RSILength);
SmaRSI = Average(RSIValue, SignalLength);
// 스케일 계산
LowerThreshold = 100 - UpperThreshold;
SlopeValue = (RegStart - RegEnd) / ChannelLength;
StepValue = (UpperEnd - LowerEnd) / (UpperThreshold - LowerThreshold);
// RSI를 채널에 매핑
LowerVal = LowerEnd + SlopeValue * 0;
RSIPlotValue = LowerVal + StepValue * (RSIValue - LowerThreshold);
SigPlotValue = LowerVal + StepValue * (SmaRSI - LowerThreshold);
// 채널 라인 플롯
Plot1(UpperEnd, "Upper Channel", RGB(167, 171, 185), default, 2);
Plot2(LowerEnd, "Lower Channel", RGB(167, 171, 185), default, 2);
// 중앙선 (옵션)
If ShowMidLine Then
Plot3(RegEnd, "Mid Line", Yellow, Dash, 1);
// RSI 라인 플롯
Plot4(RSIPlotValue, "RSI", RGB(161, 0, 182), default, 4);
// Signal 라인 (옵션)
If ShowSignalLine Then
Plot5(SigPlotValue, "Signal", Red, default, 2);
// 배경색 (옵션 - EasyLanguage는 제한적)
// SetPlotBGColor 또는 Plot6-8을 활용하여 영역 표시 가능
// 텍스트 표시 (옵션)
If ShowThresholdLabels and BarNumber = CurrentBar Then Begin
Value1 = Text_New(Date, Time, UpperEnd, " " + NumToStr(UpperThreshold, 2));
Value2 = Text_New(Date, Time, LowerEnd, " " + NumToStr(LowerThreshold, 2));
Value3 = Text_New(Date, Time, RSIPlotValue, " RSI: " + NumToStr(RSIValue, 2));
Text_SetColor(Value1, White);
Text_SetColor(Value2, White);
Text_SetColor(Value3, White);
End;
답변 1

예스스탁 예스스탁 답변
2025-10-20 14:33:51