
이 전략은 회선 축점 (Pivot Point) 을 기반으로 한 평균값 회귀 거래 시스템이다. 그것은 매주 지원 (S1-S4) 및 저항 (R1-R4) 을 계산하여 거래 입점과 출구를 결정한다. 이 전략은 단계적으로 포지션을 구축하는 방식을 채택하고, 다양한 지원 (Support) 지점에서 여러 번 구매하고, 대응 저항 지점에서 수익을 얻는다. 이 방법은 시장의 변동성을 최대한 활용하여 수평 변동 시장에서 우수한 성능을 발휘한다.
이 전략의 핵심은 전주 최고, 최저, 종전 가격을 통해 이번 주 축점을 계산한 다음, 미리 설정된 점수 거리에 따라 여러 지지점과 저항점을 결정하는 것이다. 가격이 지지점에 닿을 때 구매하고, 그에 따른 저항점에 수익을 목표로 설정하는 것이다. 구체적인 계산 공식은 다음과 같다: 축점 = (과거 주 최고 가격 +과거 주 최저 가격 +과거 주 종점 가격) / 3 전략은 최대 4개의 포지션을 동시에 가질 수 있으며, 각 포지션은 다른 지지점과 저항점에 대응한다. 모든 포지션은 매주 초에 새로운 거래 수준을 재 계산한다. 이 디자인은 거래의 연속성을 보장하면서도 시장의 변화에 적응할 수 있다.
이것은 고전적인 기술 분석 이론에 기초한 평균값 회귀 전략으로, 주위를 뒷받침하는 저항점의 돌파 회귀를 통해 거래 기회를 포착한다. 전략 설계는 간결하고 탄력적이며, 변동성이 큰 시장에서 적용된다. 합리적인 매개 변수 최적화 및 위험 관리를 통해, 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 수 있다. 거래자는 실장 사용 전에 매개 변수 설정을 충분히 테스트하고, 특정 시장 특성에 따라 적절한 조정을 하도록 권장한다.
/*backtest
start: 2024-02-19 00:00:00
end: 2025-02-17 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ViZiV
//@version=5
strategy("Weekly Pivot Strategy, Created by ViZiV", overlay=true, pyramiding=50, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=25, dynamic_requests=true)
// This is my first COMPLETED strategy, go easy on me :) - Feel free to imrprove upon this script by adding more features if you feel up to the task. Im 100% confiedent there are better coders than me :) I'm still learning.
// This is a LONG ONLY SWING STRATEGY (Patience REQUIRED) that being said, you can go short at you're own discretion. I prefer to use on NQ / US100 / USTech 100 but not limited to it. Im sure it can work in most markets. "You'll need to change settings to suit you're market".
// IMPORTANT NOTE: "default_qty_type=strategy.percent_of_equity" Can be changed to "Contacts" within the properties tab which allow you to see backtest of other markets. Reccomend 1 contract but it comes to preference.
// Inputs for support/resistance distances (Defined by Points). // IMPORTANT NOTE: Completely user Defined. Figure out best settings for what you're trading. Each market is different with different characteristics. Up to you to figure out YOU'RE market volatility for better results.
s1_offset = input.float(155, "S1 Distance", step=1)
s2_offset = input.float(310, "S2 Distance", step=1)
s3_offset = input.float(465, "S3 Distance", step=1)
s4_offset = input.float(775, "S4 Distance", step=1)
r1_offset = input.float(155, "R1 Distance", step=1)
r2_offset = input.float(310, "R2 Distance", step=1)
r3_offset = input.float(465, "R3 Distance", step=1)
r4_offset = input.float(775, "R4 Distance", step=1)
// Weekly pivot calculation
var float pivot = na
var float s1 = na
var float s2 = na
var float s3 = na
var float s4 = na
var float r1 = na
var float r2 = na
var float r3 = na
var float r4 = na
// Get weekly data (Pivot Calculation)
prevWeekHigh = request.security(syminfo.tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
prevWeekLow = request.security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)
prevWeekClose = request.security(syminfo.tickerid, "W", close[1], lookahead=barmerge.lookahead_on)
// Track active trades
var array<string> entry_ids = array.new<string>(0)
var array<float> profit_targets = array.new<float>(0)
// Update weekly levels
isNewWeek = ta.change(time("W")) != 0
if isNewWeek or na(pivot)
pivot := (prevWeekHigh + prevWeekLow + prevWeekClose) / 3
s1 := pivot - s1_offset
s2 := pivot - s2_offset
s3 := pivot - s3_offset
s4 := pivot - s4_offset
r1 := pivot + r1_offset
r2 := pivot + r2_offset
r3 := pivot + r3_offset
r4 := pivot + r4_offset
// Plot current week's levels
plot(pivot, "Pivot", color=color.gray, linewidth=2)
plot(s1, "S1", color=color.blue, linewidth=1)
plot(s2, "S2", color=color.blue, linewidth=1)
plot(s3, "S3", color=color.blue, linewidth=1)
plot(s4, "S4", color=color.blue, linewidth=1)
plot(r1, "R1", color=color.red, linewidth=1)
plot(r2, "R2", color=color.red, linewidth=1)
plot(r3, "R3", color=color.red, linewidth=1)
plot(r4, "R4", color=color.red, linewidth=1)
// Function to create unique trade entries
checkEntry(level, target, entryNumber) =>
currentWeek = str.tostring(year(time)) + "_" + str.tostring(weekofyear(time))
entryId = "Entry" + str.tostring(entryNumber) + "_W" + currentWeek
if low <= level and not array.includes(entry_ids, entryId)
array.push(entry_ids, entryId)
array.push(profit_targets, target)
strategy.entry(entryId, strategy.long)
strategy.exit("Exit" + entryId, entryId, limit=target)
// Check all entry levels
checkEntry(s1, r1, 1)
checkEntry(s2, r2, 2)
checkEntry(s3, r3, 3)
checkEntry(s4, r4, 4)
// Clean up completed trades using while loop
i = array.size(entry_ids) - 1
while i >= 0
entryId = array.get(entry_ids, i)
target = array.get(profit_targets, i)
if high >= target
array.remove(entry_ids, i)
array.remove(profit_targets, i)
i := i - 1