
이 전략은 월스트리트 마우스 오락 지표를 기반으로, 기준 암호화폐 시장의 하락세를 비교하여, 타겟 암호화폐에 대한 투기 하락 작업을 수행하는 자동 거래 전략을 구현한다. 이 전략은 다양한 암호화폐에 따라 지원도 지표 파라미터를 설정하여, 여러 종류의 암호화폐에 대한 트래킹을 구현한다.
기준 암호화폐의 월스트리트 쥐잡이 반지 지표 평균선을 계산하고, 평균선의 길이는 200주기로 설정한다.
평균선의 하락상태를 판단하기: 평균선이 상승할 때, 전략은 낙점운동을 한다. 평균선이 하락할 때, 전략은 낙점운동을 한다.
전략은 평균의 하락상태와 현재 포지션 상황에 따라 자동으로 포지션을 개시하고 포지션을 유지합니다:
평균이 높고 현재는 입장이 없는 상태에서 전략적 시장가격이 자동으로 더 많은 입장을 취합니다.
평균이 하락하고 현재 포지션이 없는 상태에서 전략시장가격이 자동으로 하락하는 경우;
다중 거래 수익이 설정된 정지 비율에 도달하면 전략 시장 가격은 자동으로 다중 거래로 평평해집니다.
단위 거래의 이익이 설정된 정지 비율에 도달하면 전략 시장 가격은 자동으로 단위 거래를 평행합니다.
다중 거래 손실이 설정된 중지 비율에 도달하면 전략 시장 가격은 자동으로 다중으로 평평해집니다.
단축 상장 손실이 설정된 스톱 손실 비율에 도달하면 전략 시장 가격은 자동으로 단축 상장을 평행한다.
이 전략은 기준 암호화폐 시장의 변화에 따라 실시간으로 스톱 스톱 손실 가격을 업데이트합니다.
전략은 강력한 적응력을 가지고 있으며, 다른 암호화폐에 대해 다른 매개 변수를 설정하여 여러 암호화폐에 대한 트래킹 거래를 구현할 수 있다.
월스트리트 쥐잡이 광선 지표를 사용하여 시장의 흐름을 판단하여 잡음으로 인한 잘못된 거래를 피할 수 있습니다. 이 지표는 돌파구 상하로 약간의 지연성을 가지고 있으며, 가짜 돌파구로 인한 손실을 줄일 수 있습니다.
이 전략은 스톱 스톱 손실 메커니즘을 포함하고 있으며, 트렌드를 파악하여 하락을 추적하고, 단독 손실을 제어할 수 있다.
전략은 완전히 자동화 된 거래이며, 24 시간 동안 작동 할 수 있습니다.
일부 암호화폐의 가격이 기준 암호화폐와 분리될 가능성이 있으며, 이로 인해 전략이 정상적으로 거래할 수 없는 위험이 있습니다. 여러 기준 암호화폐를 사용하여 관련 계수를 계산하여 가장 연관성이 강한 기준 암호화폐를 선택하여 최적화 할 수 있습니다.
시장의 비정상적인 변동으로 인해 스톱로스가 돌파되는 위험이 있습니다. 스톱로스 비율을 적절히 조정하거나 스톱로스 추적에 포함 할 수 있습니다.
트렌드 추적 또는 동적 스톱을 추가할 수 있습니다.
허위 돌파가 발생하여 평지 손실이 발생할 위험이 있습니다. 지표 파라미터, 식별 설정 또는 재입장 메커니즘을 적절하게 조정할 수 있습니다.
연관성 분석을 사용하여 여러 기준 암호화폐를 선택하여 지표를 조합하여 단일 기준 화폐의 위험을 줄이십시오.
트렌드 추적 장치를 추가하여 변동율에 따라 스톱 스로드를 동적으로 조정합니다.
레벨 상쇄를 증가시켜 극한상황 상쇄가 깨지지 않도록 한다.
재입학 제도를 강화하고, 손실을 막고, 후속 조치를 놓치지 않도록 한다.
지표 매개 변수를 최적화하고, 지표 효과를 향상시킵니다.
다양한 암호화폐에 대한 개별 최적화 매개 변수, 전략 적응성을 향상한다.
포지션 관리를 최적화하고, 자금 규모에 따라 포지션을 동적으로 조정한다.
이 전략은 전체적으로 전형적인 트렌드 추적 전략이다. 핵심 아이디어는 월스트리트 마우스 캐이팅 광대 지표에 따라 기준 암호화폐의 트렌드 방향을 판단하여 목표 암호화폐의 거래 방향을 결정하는 것이다. 전략은 장점이 있지만 주의해야 할 위험도 있다. 지속적인 최적화 매개 변수 및 트렌드 추적, 위험 제어 등의 메커니즘을 증가시킴으로써 전략의 안정성과 수익률을 더욱 강화할 수 있다.
/*backtest
start: 2022-10-25 00:00:00
end: 2023-10-31 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © levieux
//@version=5
strategy(title='Correlation Strategy', shorttitle='Correlation Strategy', initial_capital=1000, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)
supportLength = input.int(200, minval=1, title='Support Length')
supportSymbol = input('BTC_USDT:swap', title='Correlated Symbol')
supportSource = input(hlc3, title='Price Source')
takeprofitLong = input.float(0.2, 'Take Profit Long', step=0.01)
takeprofitShort = input.float(0.15, 'Take Profit Short', step=0.01)
stoplossLong = input.float(0.1, 'Stop Loss Long', step=0.01)
stoplossShort = input.float(0.04, 'Stop Loss Short', step=0.01)
start = input(defval = timestamp("01 Jan 2016 00:00 +0000"), title = "Start Time")
end = input(defval = timestamp("31 Dec 2050 23:59 +0000"), title = "End Time")
supportTicker = request.security(supportSymbol, timeframe.period, supportSource, lookahead=barmerge.lookahead_off) //input(close, title="Source")
supportLine = ta.wma(supportTicker, supportLength)
window() => true
if not window()
strategy.cancel_all()
supportLongPrice = close
supportShortPrice = close
if strategy.position_size > 0
supportLongPrice := supportLongPrice[1]
if strategy.position_size < 0
supportShortPrice := supportShortPrice[1]
longCondition = ta.rising(supportLine, 5) and window() and strategy.position_size <= 0
shortCondition = ta.falling(supportLine, 5) and window() and window() and strategy.position_size > 0
takeprofitLongCondition = takeprofitLong > 0 and window() and strategy.position_size > 0 and supportTicker > supportLongPrice * (1 + takeprofitLong)
stoplossLongCondition = stoplossLong > 0 and window() and strategy.position_size > 0 and supportTicker < supportLongPrice * (1 - stoplossLong)
takeprofitShortCondition = takeprofitShort > 0 and window() and strategy.position_size < 0 and supportTicker > supportShortPrice * (1 + takeprofitShort)
stoplossShortCondition = stoplossShort > 0 and window() and strategy.position_size < 0 and supportTicker < supportShortPrice * (1 - stoplossShort)
if longCondition
strategy.entry('Long', strategy.long)
supportLongPrice := supportTicker
if shortCondition
strategy.entry('Short', strategy.short)
supportShortPrice := supportTicker
if takeprofitLongCondition
strategy.close('Long')
if stoplossLongCondition
strategy.close('Long')
if takeprofitShortCondition
strategy.close('Short')
if stoplossShortCondition
strategy.close('Short')
///////////////////
// MONTHLY TABLE //
new_month = month(time) != month(time[1])
new_year = year(time) != year(time[1])
eq = strategy.equity
bar_pnl = eq / eq[1] - 1
bar_bh = (close-close[1])/close[1]
cur_month_pnl = 0.0
cur_year_pnl = 0.0
cur_month_bh = 0.0
cur_year_bh = 0.0
// Current Monthly P&L
cur_month_pnl := new_month ? 0.0 :
(1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
cur_month_bh := new_month ? 0.0 :
(1 + cur_month_bh[1]) * (1 + bar_bh) - 1
// Current Yearly P&L
cur_year_pnl := new_year ? 0.0 :
(1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1
cur_year_bh := new_year ? 0.0 :
(1 + cur_year_bh[1]) * (1 + bar_bh) - 1
// Arrays to store Yearly and Monthly P&Ls
var month_pnl = array.new_float(0)
var month_time = array.new_int(0)
var month_bh = array.new_float(0)
var year_pnl = array.new_float(0)
var year_time = array.new_int(0)
var year_bh = array.new_float(0)
end_time = false
end_time:= time_close + (time_close - time_close[1]) > timenow or barstate.islastconfirmedhistory
if (not na(cur_month_pnl[1]) and (new_month or end_time))
if (end_time[1])
array.pop(month_pnl)
array.pop(month_time)
array.push(month_pnl , cur_month_pnl[1])
array.push(month_time, time[1])
array.push(month_bh , cur_month_bh[1])
if (not na(cur_year_pnl[1]) and (new_year or end_time))
if (end_time[1])
array.pop(year_pnl)
array.pop(year_time)
array.push(year_pnl , cur_year_pnl[1])
array.push(year_time, time[1])
array.push(year_bh , cur_year_bh[1])
// Monthly P&L Table
var monthly_table = table(na)
getCellColor(pnl, bh) =>
if pnl > 0
if bh < 0 or pnl > 2 * bh
color.new(color.green, transp = 20)
else if pnl > bh
color.new(color.green, transp = 50)
else
color.new(color.green, transp = 80)
else
if bh > 0 or pnl < 2 * bh
color.new(color.red, transp = 20)
else if pnl < bh
color.new(color.red, transp = 50)
else
color.new(color.red, transp = 80)
if end_time
monthly_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_pnl) + 1, border_width = 1)
table.cell(monthly_table, 0, 0, "", bgcolor = #cccccc)
table.cell(monthly_table, 1, 0, "Jan", bgcolor = #cccccc)
table.cell(monthly_table, 2, 0, "Feb", bgcolor = #cccccc)
table.cell(monthly_table, 3, 0, "Mar", bgcolor = #cccccc)
table.cell(monthly_table, 4, 0, "Apr", bgcolor = #cccccc)
table.cell(monthly_table, 5, 0, "May", bgcolor = #cccccc)
table.cell(monthly_table, 6, 0, "Jun", bgcolor = #cccccc)
table.cell(monthly_table, 7, 0, "Jul", bgcolor = #cccccc)
table.cell(monthly_table, 8, 0, "Aug", bgcolor = #cccccc)
table.cell(monthly_table, 9, 0, "Sep", bgcolor = #cccccc)
table.cell(monthly_table, 10, 0, "Oct", bgcolor = #cccccc)
table.cell(monthly_table, 11, 0, "Nov", bgcolor = #cccccc)
table.cell(monthly_table, 12, 0, "Dec", bgcolor = #cccccc)
table.cell(monthly_table, 13, 0, "Year", bgcolor = #999999)
for yi = 0 to array.size(year_pnl) - 1
table.cell(monthly_table, 0, yi + 1, str.tostring(year(array.get(year_time, yi))), bgcolor = #cccccc)
y_color = getCellColor(array.get(year_pnl, yi), array.get(year_bh, yi))
table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100)) + " (" + str.tostring(math.round(array.get(year_bh, yi) * 100)) + ")", bgcolor = y_color)
for mi = 0 to array.size(month_time) - 1
m_row = year(array.get(month_time, mi)) - year(array.get(year_time, 0)) + 1
m_col = month(array.get(month_time, mi))
m_color = getCellColor(array.get(month_pnl, mi), array.get(month_bh, mi))
table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100)) + " (" + str.tostring(math.round(array.get(month_bh, mi) * 100)) +")", bgcolor = m_color)