
この記事では,パーセントの値に基づく量的な取引戦略について説明します. この戦略は,パーセントの値を設定し,適切な時間周期を選択することで,買入と売却のタイミングを決定します. 価格が前回の閉盘価格に比べて上昇または下落し,指定されたパーセントの値を超えると,買入または売却のシグナルが誘発されます. この戦略は,ユーザーのリスク好みと市場状況に応じて柔軟に調整され,様々な金融商品の取引に適用されます.
この戦略の核心は,価格の変化のパーセントに基づいて取引シグナルを生成することです. まず,ユーザーは,価格が前の閉店価格に比べて変化の幅を表すパーセントの値下げを設定する必要があります. また,ユーザーは,その時間帯の最高価格,最低価格,閉店価格を計算するために,1分,1時間,1日などの時間周期を選択する必要があります. この戦略は,市場価格をリアルタイムで監視し,現在の時間周期の最高価格が前の閉店価格を上回ると,値下げが加わると,買入シグナルが誘発されます.
この記事では,パーセントの値に基づく量化取引戦略を紹介し,価格の変化のパーセントの値と時間周期を設定することで,自動的に買入と売却の信号を生成する.この戦略は操作が簡単で,柔軟性があり,適用範囲は広いが,同時に市場波動,パラメータ設定および過適合などのリスクにも直面する.ストップ・ストップ・メカニズム,パラメータの動的な調整,および他の技術指標と組み合わせる方法を追加することで,この戦略のパフォーマンスをさらに最適化し,実際の取引における効果を高めることができる.
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("GBS Percentage", overlay=true)
// Define input options for percentage settings and timeframe
percentage = input.float(1.04, title="Percentage Threshold", minval=0.01, step=0.01) / 100
timeframe = input.timeframe("D", title="Timeframe", options=["1", "3", "5", "15", "30", "60", "240", "D", "W", "M"])
// Calculate high, low, and close of the selected timeframe
high_timeframe = request.security(syminfo.tickerid, timeframe, high)
low_timeframe = request.security(syminfo.tickerid, timeframe, low)
close_timeframe = request.security(syminfo.tickerid, timeframe, close)
// Calculate the percentage threshold based on the previous close
threshold = close_timeframe[1] * percentage
// Define conditions for Buy and Sell
buyCondition = high_timeframe > (close_timeframe[1] + threshold)
sellCondition = low_timeframe < (close_timeframe[1] - threshold)
// Entry and exit rules
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Close the positions based on the conditions
if (sellCondition)
strategy.close("Buy")
if (buyCondition)
strategy.close("Sell")
// Plot Buy and Sell signals on the chart
plotshape(series=buyCondition, title="Buy Entry", color=color.green, style=shape.triangleup, location=location.belowbar)
plotshape(series=sellCondition, title="Sell Entry", color=color.red, style=shape.triangledown, location=location.abovebar)
// Plot the equity curve of the strategy
plot(strategy.equity, title="Equity", color=color.blue, linewidth=2)