커뮤니티
부탁드립니다
수고하십니다
아래수식을 오류 없게 수정부탁드립니다
Inputs:
PivotLength(10),
TrendLength(50),
ShowProfile(true),
ColorUp(Blue),
ColorDn(Red);
Variables:
PH(0), PL(0),
HighestH(0), LowestL(0),
TrendLine(0),
ATRValue(0),
IsTrendUp(false),
PivotDetected(false),
StartBar(0),
TopPrice(0), BotPrice(0),
Levels(0), StepSize(0),
i(0), k(0),
MidPrice(0),
POCPrice(0), POCVolume(0),
CurrentColor(0);
Arrays:
VolumeBins[1000](0);
// ATR 계산
ATRValue = Average(TrueRange, 200) * 0.1;
// Pivot 감지
PH = 0;
PL = 0;
// Pivot High 감지
if High[PivotLength] = Highest(High, 2 * PivotLength + 1) then
PH = High[PivotLength];
// Pivot Low 감지
if Low[PivotLength] = Lowest(Low, 2 * PivotLength + 1) then
PL = Low[PivotLength];
// 트렌드 계산
HighestH = Highest(High, TrendLength);
LowestL = Lowest(Low, TrendLength);
TrendLine = (HighestH + LowestL) / 2;
// 트렌드 방향 결정
if High = HighestH then
IsTrendUp = true;
if Low = LowestL then
IsTrendUp = false;
// 색상 설정
if IsTrendUp = false then
CurrentColor = ColorUp
else
CurrentColor = ColorDn;
// Pivot 감지
PivotDetected = false;
if IsTrendUp = false then begin
if PH > 0 then
PivotDetected = true;
end else begin
if PL > 0 then
PivotDetected = true;
end;
// Volume Profile 계산
if CurrentBar - PivotLength - StartBar > PivotLength then begin
if PivotDetected then begin
StartBar = CurrentBar - PivotLength;
// 경계 설정
TopPrice = High;
BotPrice = Low;
for i = 0 to PivotLength * 2 begin
if High[i] > TopPrice then
TopPrice = High[i];
if Low[i] < BotPrice then
BotPrice = Low[i];
end;
// 레벨 계산
Levels = (TopPrice - BotPrice) / ATRValue;
StepSize = (TopPrice - BotPrice) / Levels;
// Volume Bins 초기화
for k = 0 to Levels begin
VolumeBins[k] = 0;
end;
// Volume 수집
for i = 0 to PivotLength * 2 begin
for k = 0 to Levels begin
MidPrice = BotPrice + StepSize * k + StepSize / 2;
if AbsValue(MidPrice - Close[i]) <= StepSize * 2 then
VolumeBins[k] = VolumeBins[k] + Volume[i];
end;
end;
// POC (Point of Control) 찾기
POCVolume = 0;
POCPrice = 0;
for k = 0 to Levels begin
if VolumeBins[k] > POCVolume then begin
POCVolume = VolumeBins[k];
POCPrice = BotPrice + StepSize * k + StepSize / 2;
end;
end;
end;
end;
// 플롯
Plot1(TrendLine, "Trend");
if ShowProfile then
Plot2(POCPrice, "POC Level");
// 색상 적용
SetPlotColor(1, CurrentColor);
SetPlotWidth(1, 4);
if ShowProfile then begin
SetPlotColor(2, CurrentColor);
SetPlotWidth(2, 1);
end;
답변 1
예스스탁 예스스탁 답변
2025-10-27 11:02:35