
이 전략은 홍콩恒生指数 ETF ((00631L) 을 투자 대상으로, 현금 포지션과 포지션 비율을 동적으로 조정하여, 투자 포트폴리오의 수익과 위험을 균형 잡는다. 전략은 간단하고 쉽게 실행할 수 있으며, 시장 추세를 판단할 필요가 없으며, 시장을 자주 볼 수 없는 투자자에게 적합하다.
초기 투자의 50%의 총 자금을 00631L을 구입;
수익이 발생하지 않은 것과 잔여 현금의 비율을 감시합니다.
10% 이상의 수익을 얻지 못하면 5%의 지분을 매각합니다.
남은 현금이 미취득 수익의 10%를 초과할 때, 추가로 5%의 지분을 추가로 구매합니다.
시장에 대한 판단 없이 간단하고 쉽게 운영할 수 있습니다.
동적으로 포지션을 조정하여 투자 위험을 효과적으로 제어합니다.
두방향 추적, 적시 정지
시장을 자주 체크할 수 없는 투자자들에게 적합하다.
: : :
최대 손실을 제어하기 위해 스톱 라인을 설정하십시오.
적당히 균형을 완화하고 지분을 줄여라.
포지션과 현금 비율을 최적화합니다.
다양한 ETF의 수익 효과를 테스트합니다.
트렌드를 판단하는 지표에 가입하여 자금 활용 효율성을 높여라.
이 전략은 역동적으로 균형 잡힌 투자 포트폴리오를 구축하여 투자 위험을 제어하고 시장 추세를 판단하지 않고 간단하게 작동하며 자주 체크할 수 없는 투자자에게 적합하며 매우 실용적인 양적 투자 전략이다.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-24 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("00631L Trading Simulation", shorttitle="Sim", overlay=true, initial_capital = 1000000)
// 设置本金
capital = 1000000
// 设置购买和出售日期范围
start_date = timestamp(2022, 10, 6)
next_date = timestamp(2022, 10, 7) // 較好的開始日
//start_date = timestamp(2022, 3, 8)
//next_date = timestamp(2022, 3, 9) // 較差的的開始日
sell_date = timestamp(2024, 1, 19)
end_date = timestamp(2024, 1, 21) // 结束日期为2024年01月21日
// 判断是否在交易期间
in_trade_period = time >= start_date and time <= end_date
// 实现的盈亏
realized_profit_loss = strategy.netprofit
plot(realized_profit_loss, title="realized_profit_loss", color=color.blue)
// 未实现的盈亏
open_profit_loss = strategy.position_size * open
plot(open_profit_loss, title="open_profit_loss", color=color.red)
// 剩余资金
remaining_funds = capital + realized_profit_loss - (strategy.position_size * strategy.position_avg_price)
plot(remaining_funds, title="remaining_funds", color=color.yellow)
// 總權益
total_price = remaining_funds + open_profit_loss
plot(total_price, title="remaining_funds", color=color.white)
// 购买逻辑:在交易期间的每个交易日买入 daily_investment 金额的产品
first_buy = time >= start_date and time <= next_date
buy_condition = in_trade_period and dayofmonth != dayofmonth[1]
// 出售邏輯 : 在交易期间的截止日出售所有商品。
sell_all = time >= sell_date
// 在交易期間的第一日買入50%本金
if first_buy
strategy.order("First", strategy.long, qty = capital/2/open)
// 在每个K线的开盘时进行买入
// 加碼邏輯 : 剩余资金 > 未实现的盈亏 * 1.05
add_logic = remaining_funds > open_profit_loss * 1.05
if buy_condition
strategy.order("Buy", strategy.long, when = add_logic, qty = remaining_funds * 0.025 / open)
//
// 減碼邏輯 : 剩余资金 > 未实现的盈亏 * 1.05
sub_logic = open_profit_loss > remaining_funds * 1.05
if buy_condition
strategy.order("Sell", strategy.short, when = sub_logic, qty = open_profit_loss * 0.025/open)
//
strategy.order("Sell_all", strategy.short, when = sell_all, qty = strategy.position_size)
// 绘制交易期间的矩形区域
bgcolor(in_trade_period ? color.green : na, transp=90)