
この戦略は,ウォールストリートキャッチャー光環指数に基づいて,基準暗号通貨市場の下落を比較し,ターゲット暗号通貨に対する看板・下落操作を行う自動取引戦略を実現する. 戦略は,異なる暗号通貨の設定による支持度指標パラメータに基づいて,複数の暗号通貨の取引を追跡することができる.
基準暗号通貨のウォール街捕鼠光環指標平均線を計算し,平均線の長さを200周期に設定する.
平均線が上昇する状態を判断する:平均線が上昇するときに,戦略は看板操作を行う.平均線が低下するときに,戦略は看板操作を行う.
戦略: 平均線の上昇と下落の状況,および現在のポジション状況に基づいて,自動開設と平定のポジションを実現します.
平均線が上昇し,当時はポジションがないとき,戦略的な市場価格が自動的にポジションを大きく開きます.
平均線が下がり,現在ポジションがないとき,戦略的市場価格が自動的に空白する.
複数の取引で利益が設定された止まり率に達すると,戦略の市場価格は自動的に平らになります.
利回りが設定された止まり率に達すると,戦略市場価格は自動的に空白券を平らにする.
多項の損失が設定された停止比率に達すると,戦略の市場価格は自動的に多項で平らになります.
短期外為の損失が設定された止損比率に達すると,戦略市場価格は自動的に空白券を平らげます.
戦略は,基準仮想通貨の市場状況の変化に応じて,リアルタイムでストップ・ストラスト価格を更新する.
策略は高度な適応性を持ち,異なる暗号通貨に対して異なるパラメータを設定し,複数の暗号通貨の取引を追跡することができます.
ウォールストリートマウス捕獲光環指数を用いて市場動向を判断し,騒音による誤取引を回避する.この指数は,突破上下軌道に一定の遅延性があり,偽突破による損失を減らすことができる.
戦略は,ストップ・ストップ・メカニズムを組み込み,トレンドを把握し,落下を阻止し,単一の損失を制御することができます.
戦略は,全自動取引で,人間の介入を必要とせず,24時間稼働します.
特定の暗号通貨の価格が基準暗号通貨と脱線する可能性があり,その結果,戦略が正常に取引できないリスクが生じます.複数の基準暗号通貨を使用して関連系数を計算し,最も関連性のある基準暗号通貨を選択することで最適化できます.
市場の異常な波動によりストップが突破されるリスクがあります. ストップの割合を適切に調整するか,ストップ・トラッキングに加入することができます.
ストップ比率の設定が小さすぎると,十分なトレンドの利益が捉えられないリスクがあります. トレンド追跡またはダイナミックストップを追加できます.
偽突破により平仓の損失が起こるリスクがある.指標パラメータ,識別設定または再入場メカニズムを適切に調整することができる.
関連性分析を使用して複数の基准暗号通貨を選択し,指標を組み合わせて計算し,単一の基准通貨のリスクを軽減します.
トレンド追跡機能を追加し,波動率の動向に応じてストップ・ストップ・ロスを調整する.
エクストリームモードのストップダメージを突破しないよう,レベルアップのストップダメージを増やす.
また,再入学メカニズムを導入し,損失を抑えた後に失敗した再入学を回避する.
指標パラメータ,identificationsettingsを最適化して,指標の効果を向上させる.
異なる暗号通貨に対してそれぞれ最適化パラメータを設定し,戦略の適応性を向上させる.
ポジション管理の最適化,資金規模に応じてポジションの動的調整
この戦略は,全体的に見ると,典型的なトレンド追跡戦略である. 核心的な考え方は,ウォール街のマウスキャッシング光環指標に基づいて,基準暗号通貨のトレンド方向を判断し,それによってターゲット暗号通貨の取引方向を決定することである. この戦略には一定の利点があるが,注意すべきいくつかのリスクもある.
/*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)