커뮤니티
문의드립니다
오류가 많습니다 수정부탁드립니다
Inputs:
Left(2), Right(2),
MinBarsGap(3), // 이전 피벗과 최소 바수 간격
MinTickGap(8), // 이전 피벗과 최소 틱 간격 (ES tick=0.25 → 8=2pt)
WarmupBars(20),
UseVWAPFilter(1), // 1/0
UseMAFilter(1), MALen(60),
UseATR(1), ATRlen(14), SLmult(1.2), TPmult(2.0);
Vars:
hi1P(0), hi1Bar(0), hi2P(0), hi2Bar(0),
lo1P(0), lo1Bar(0), lo2P(0), lo2Bar(0),
T(0), isPH(0), isPL(0),
tick(0.25), SumPV(0), SumV(0), VW(0), ma(0), atr(0), entryP(0);
If CurrentBar == 1 Then Begin
SumPV = Close * Volume;
SumV = Volume;
End
Else Begin
SumPV = SumPV[1] + Close * Volume;
SumV = SumV[1] + Volume;
End;
If SumV > 0 Then
VW = SumPV / SumV;
Else
VW = Close;
ma = Average(Close, MALen);
atr = Average(TrueRange, ATRlen);
isPH = 0;
isPL = 0;
If CurrentBar > Left + Right Then Begin
If Highest(High, Left + Right + 1)[Right] = High[Right] Then isPH = 1;
If Lowest (Low , Left + Right + 1)[Right] = Low [Right] Then isPL = 1;
End;
If isPH = 1 Then Begin
If hi1Bar > 0 Then Begin
If (CurrentBar - Right - hi1Bar) < MinBarsGap Then isPH = 0;
If AbsValue((High[Right] - hi1P) / tick) < MinTickGap Then isPH = 0;
End;
End;
If isPL = 1 Then Begin
If lo1Bar > 0 Then Begin
If (CurrentBar - Right - lo1Bar) < MinBarsGap Then isPL = 0;
If AbsValue((lo1P - Low[Right]) / tick) < MinTickGap Then isPL = 0;
End;
End;
If isPH = 1 Then Begin
hi2P = hi1P; hi2Bar = hi1Bar;
hi1P = High[Right]; hi1Bar = CurrentBar - Right;
T = 1;
End;
If isPL = 1 Then Begin
lo2P = lo1P; lo2Bar = lo1Bar;
lo1P = Low[Right]; lo1Bar = CurrentBar - Right;
T = -1;
End;
If CurrentBar < WarmupBars Then T = T[1];
If (T = 1) and (T[1] <> 1) Then Begin
If ( (UseVWAPFilter = 0) or (Close >= VW) )
and ( (UseMAFilter = 0) or (Close >= ma) ) Then Begin
Buy next bar at market;
If UseATR = 1 Then Begin
entryP = EntryPrice;
Sell next bar at entryP + TPmult * atr limit;
Sell next bar at entryP - SLmult * atr stop;
End;
End;
End;
If (T = -1) and (T[1] <> -1) Then Begin
If ( (UseVWAPFilter = 0) or (Close <= VW) )
and ( (UseMAFilter = 0) or (Close <= ma) ) Then Begin
Sell Short next bar at market;
If UseATR = 1 Then Begin
entryP = EntryPrice;
Buy to Cover next bar at entryP - TPmult * atr limit;
Buy to Cover next bar at entryP + SLmult * atr stop;
End;
End;
End;
답변 1
예스스탁 예스스탁 답변
2025-11-11 15:37:01