답변완료
부탁드립니다
수고하십니다아래수식을 오류 없게 수정부탁드립니다Inputs: Period(200), VPResolution(50), ShowPoC(true), ShowPivots(true), PivotLength(10), PivotFilter(20);Variables: i(0), j(0), k(0), HighestPrice(0), LowestPrice(0), BinSize(0), BinLow(0), BinHigh(0), BinMid(0), BinValue(0), MaxBinValue(0), VolPercent(0), Left(0), Right(0), PocPrice(0), PocVolume(0), TotalDelta(0), CurrentDelta(0), // Pivot 관련 PH(0), PL(0), PivotPrice(0), PivotBar(0), PivotIndex(0), // Drawing Objects TLRef(0), TextRef(0), RectRef(0), // 색상 ProfileColor(0), BarColor(0);Arrays: VolumeBins[100](0), DeltaBins[100](0), PivotPrices[500](0), PivotBars[500](0), PivotTypes[500](0), // 1 = High, -1 = Low PivotProcessed[500](0), // 0 = not processed, 1 = processed VPTrendLines[100](0), VPLabels[100](0);// 이전 Drawing Objects 삭제 (마지막 바에서만)if Date <> Date[1] or Time <> Time[1] then begin for i = 0 to VPResolution - 1 begin if VPTrendLines[i] > 0 then begin TL_Delete(VPTrendLines[i]); VPTrendLines[i] = 0; end; if VPLabels[i] > 0 then begin Text_Delete(VPLabels[i]); VPLabels[i] = 0; end; end;end;// Pivot High 감지PH = 0;if CurrentBar > PivotLength * 2 then begin if High[PivotLength] == Highest(High, 2 * PivotLength + 1) then PH = High[PivotLength];end;// Pivot Low 감지PL = 0;if CurrentBar > PivotLength * 2 then begin if Low[PivotLength] == Lowest(Low, 2 * PivotLength + 1) then PL = Low[PivotLength];end;// Pivot 저장 및 처리if PH > 0 then begin PivotIndex = -1; // 빈 슬롯 찾기 for i = 0 to 499 begin if PivotBars[i] = 0 then begin PivotIndex = i; break; end; end; if PivotIndex >= 0 then begin PivotPrices[PivotIndex] = PH; PivotBars[PivotIndex] = CurrentBar - PivotLength; PivotTypes[PivotIndex] = 1; // High PivotProcessed[PivotIndex] = 0; end;end;if PL > 0 then begin PivotIndex = -1; // 빈 슬롯 찾기 for i = 0 to 499 begin if PivotBars[i] = 0 then begin PivotIndex = i; break; end; end; if PivotIndex >= 0 then begin PivotPrices[PivotIndex] = PL; PivotBars[PivotIndex] = CurrentBar - PivotLength; PivotTypes[PivotIndex] = -1; // Low PivotProcessed[PivotIndex] = 0; end;end;// Volume Profile 계산 및 시각화if CurrentBar >= Period then begin // 범위 계산 HighestPrice = Highest(High, Period); LowestPrice = Lowest(Low, Period); if HighestPrice > LowestPrice then begin BinSize = (HighestPrice - LowestPrice) / VPResolution; // Bins 초기화 for i = 0 to VPResolution - 1 begin VolumeBins[i] = 0; DeltaBins[i] = 0; end; // Volume 데이터 수집 for j = 0 to Period - 1 begin for i = 0 to VPResolution - 1 begin BinLow = LowestPrice + BinSize * i; BinHigh = BinLow + BinSize; if Close[j] >= BinLow - BinSize and Close[j] < BinHigh + BinSize then begin VolumeBins[i] = VolumeBins[i] + Volume[j]; // Delta 계산 if Close[j] > Open[j] then DeltaBins[i] = DeltaBins[i] + Volume[j]; else DeltaBins[i] = DeltaBins[i] - Volume[j]; end; end; end; // 최대 Volume 찾기 MaxBinValue = 0; for i = 0 to VPResolution - 1 begin if VolumeBins[i] > MaxBinValue then MaxBinValue = VolumeBins[i]; end; // PoC 및 Total Delta 계산 PocVolume = 0; PocPrice = 0; TotalDelta = 0; for i = 0 to VPResolution - 1 begin TotalDelta = TotalDelta + DeltaBins[i]; if VolumeBins[i] > PocVolume then begin PocVolume = VolumeBins[i]; BinLow = LowestPrice + BinSize * i; BinHigh = BinLow + BinSize; PocPrice = (BinLow + BinHigh) / 2; end; end; // 색상 결정 (Delta 기반) if TotalDelta > 0 then ProfileColor = Cyan; else ProfileColor = Red; // Volume Profile 히스토그램 그리기 (마지막 바에서만) if LastBarOnChart then begin Left = CurrentBar - Period; for i = 0 to VPResolution - 1 begin BinLow = LowestPrice + BinSize * i; BinHigh = BinLow + BinSize; BinMid = (BinLow + BinHigh) / 2; BinValue = VolumeBins[i]; if MaxBinValue > 0 then begin VolPercent = (BinValue / MaxBinValue) * 100; Right = Left + Round((BinValue / MaxBinValue) * 50); // Delta 기반 색상 if DeltaBins[i] > 0 then BarColor = Cyan else BarColor = Red; // Volume Profile 바 그리기 (TrendLine 사용) if VPTrendLines[i] > 0 then TL_Delete(VPTrendLines[i]); VPTrendLines[i] = TL_New(Date[Period], Time[Period], BinMid, Date[Period - Right + Left], Time[Period - Right + Left], BinMid); TL_SetColor(VPTrendLines[i], BarColor); TL_SetSize(VPTrendLines[i], 4); // Pivot과 Volume Profile 교차점 표시 if ShowPivots then begin for k = 0 to 499 begin if PivotBars[k] > 0 and PivotProcessed[k] = 0 then begin PivotPrice = PivotPrices[k]; PivotBar = PivotBars[k]; // Pivot이 Volume Profile 범위 내에 있고 필터 조건 만족 if AbsValue(BinMid - PivotPrice) <= BinSize and VolPercent >= PivotFilter and CurrentBar - Period <= PivotBar then begin // Pivot 라인 그리기 if PivotTypes[k] = 1 then begin // Pivot High TLRef = TL_New(Date[CurrentBar - PivotBar + PivotLength], Time[CurrentBar - PivotBar + PivotLength], PivotPrice, Date[CurrentBar - PivotBar - PivotLength], Time[CurrentBar - PivotBar - PivotLength], PivotPrice); TL_SetColor(TLRef, DarkRed); TL_SetSize(TLRef, 2); // 라벨 추가 TextRef = Text_New(Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice, NumToStr(BinValue, 0) + " (" + NumToStr(VolPercent, 0) + "%)"); Text_SetColor(TextRef, DarkRed); Text_SetLocation(TextRef, Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice + BinSize); // 연장선 그리기 (Dotted) TLRef = TL_New(Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice, Date, Time, PivotPrice); TL_SetColor(TLRef, DarkRed); TL_SetStyle(TLRef, Tool_Dotted); TL_SetExtRight(TLRef, True); end else begin // Pivot Low TLRef = TL_New(Date[CurrentBar - PivotBar + PivotLength], Time[CurrentBar - PivotBar + PivotLength], PivotPrice, Date[CurrentBar - PivotBar - PivotLength], Time[CurrentBar - PivotBar - PivotLength], PivotPrice); TL_SetColor(TLRef, DarkGreen); TL_SetSize(TLRef, 2); // 라벨 추가 TextRef = Text_New(Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice, NumToStr(VolPercent, 0) + "% (" + NumToStr(BinValue, 0) + ")"); Text_SetColor(TextRef, DarkGreen); Text_SetLocation(TextRef, Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice - BinSize); // 연장선 그리기 (Dotted) TLRef = TL_New(Date[CurrentBar - PivotBar], Time[CurrentBar - PivotBar], PivotPrice, Date, Time, PivotPrice); TL_SetColor(TLRef, DarkGreen); TL_SetStyle(TLRef, Tool_Dotted); TL_SetExtRight(TLRef, True); end; PivotProcessed[k] = 1; end; end; end; end; end; end; end; end;end;// 오래된 Pivot 제거for i = 0 to 499 begin if PivotBars[i] > 0 and CurrentBar - PivotBars[i] > Period then begin PivotBars[i] = 0; PivotPrices[i] = 0; PivotTypes[i] = 0; PivotProcessed[i] = 0; end;end;// PoC 레벨 표시if ShowPoC and PocPrice > 0 then begin Plot1(PocPrice, "PoC Level", ProfileColor, Default, 2); // PoC 라벨 (마지막 바에서만) if LastBarOnChart then begin TextRef = Text_New(Date, Time, PocPrice, "POC: " + NumToStr(PocVolume, 0)); Text_SetColor(TextRef, ProfileColor); Text_SetLocation(TextRef, Date, Time, PocPrice); end;end;
2025-10-28
284
글번호 227383
지표
답변완료
문의드립니다
안녕하세요? 아래수식에 에러가있습니다 그리고신호가발생했으면 합니다 감사합니다Inputs: TL11(0), TL21(0), CrossTolerance(10), ContractCount(1);Vars: valTL1_now(0), valTL2_now(0), valTL1_prev(0), valTL2_prev(0), diff(0), LastCrossBar(0), CrossLine(0);//---------------------------------------------// 추세선 존재 시에만 작동//---------------------------------------------If (TL11 > 0) and (TL21 > 0) ThenBegin // 현재 봉 값 valTL1_now = TL_GetValue(TL11, Date, Time); valTL2_now = TL_GetValue(TL21, Date, Time); // 이전 봉 값 valTL1_prev = TL_GetValue(TL11, Date[1], Time[1]); valTL2_prev = TL_GetValue(TL21, Date[1], Time[1]); diff = AbsValue(valTL1_now - valTL2_now); // 교차 근접 표시 If diff <= (PriceScale * CrossTolerance) Then Begin If LastCrossBar <> CurrentBar Then Begin CrossLine = TL_New(Date[1], Time[1], Close[1], Date, Time, Close); TL_SetColor(CrossLine, Yellow); TL_SetSize(CrossLine, 1); LastCrossBar = CurrentBar; End; End; // 교차 감지 → 1봉 뒤 자동매매 If (valTL1_prev < valTL2_prev) and (valTL1_now > valTL2_now) Then Buy ContractCount contracts next bar at market Else If (valTL1_prev > valTL2_prev) and (valTL1_now < valTL2_now) Then Sell ContractCount contracts next bar at market;End;
2025-10-27
127
글번호 227339
시스템