この戦略は,均線交差に基づく定量取引システムで,ダイナミックなストップ・ストラップ・メカニズムを組み合わせている.戦略の核心は,10サイクルと26サイクルインデックス移動平均の交差を介して市場のトレンドを認識し,逆転時に取引する.システムは,固定したストップ・ストラップ・ポイントの設定を採用し,厳格なリスク制御によって資金の安全を保護する.この戦略は,波動率が高い取引品種に特に適しています.
戦略は,2つの異なる周期のEMA平均線を中心の指標として使用します:短期10周期EMAと長期26周期EMA.短期平均線が長期平均線を上方から横切ると,システムは上昇傾向として認識し,買取シグナルを生成します.短期平均線が長期平均線を下方から横切ると,システムは下方傾向として認識し,売り出しシグナルを生成します.システムは,トレンドが確認された後に,価格が戻ってくるのを待って,30ポイントのストップと15ポイントのストップを設定することでリスクをコントロールします.戦略は,単一の信号機構を採用します.つまり,同時に1つの方向での取引のみを許可します.これはシステムの複雑さを軽減し,信頼性を高めるのに役立ちます.
この戦略は,EMA均線交差と価格回調を組み合わせて,完全な取引システムを構築している.戦略の設計はシンプルで直感的で,リスク管理は明確で,波動性の高い取引品種に適している.合理的な最適化とパラメータ調整により,この戦略は,実況取引で安定した収益を期待している.
/*backtest
start: 2023-11-18 00:00:00
end: 2024-11-17 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("30 Pips Target & 15 Pips Stop-Loss with One Signal at a Time", overlay=true)
// Define settings for target and stop-loss in pips
target_in_pips = 30
stoploss_in_pips = 10
// Convert pips to price value based on market (for forex, 1 pip = 0.0001 for major pairs like GBP/JPY)
pip_value = syminfo.mintick * 10 // For forex, 1 pip = 0.0001 or 0.01 for JPY pairs
target_value = target_in_pips * pip_value
stoploss_value = stoploss_in_pips * pip_value
// Define EMAs (10-EMA and 26-EMA) for the crossover strategy
ema10 = ta.ema(close, 10)
ema26 = ta.ema(close, 26)
// Buy signal: when 10 EMA crosses above 26 EMA
longCondition = ta.crossover(ema10, ema26)
// Sell signal: when 10 EMA crosses below 26 EMA
shortCondition = ta.crossunder(ema10, ema26)
// Define price levels with explicit type float
var float long_entry_price = na
var float long_take_profit = na
var float long_stop_loss = na
var float short_entry_price = na
var float short_take_profit = na
var float short_stop_loss = na
// Variable to track if a trade is active
var bool inTrade = false
// Check if the trade hit stop loss or take profit
if (inTrade)
if (not na(long_take_profit) and close >= long_take_profit)
inTrade := false // Exit the trade after hitting target
long_entry_price := na
long_take_profit := na
long_stop_loss := na
strategy.close("Long")
if (not na(long_stop_loss) and close <= long_stop_loss)
inTrade := false // Exit the trade after hitting stoploss
long_entry_price := na
long_take_profit := na
long_stop_loss := na
strategy.close("Long")
if (not na(short_take_profit) and close <= short_take_profit)
inTrade := false // Exit the trade after hitting target
short_entry_price := na
short_take_profit := na
short_stop_loss := na
strategy.close("Short")
if (not na(short_stop_loss) and close >= short_stop_loss)
inTrade := false // Exit the trade after hitting stoploss
short_entry_price := na
short_take_profit := na
short_stop_loss := na
strategy.close("Short")
// Only generate new signals if not already in a trade
if (not inTrade)
if (longCondition)
long_entry_price := close
long_take_profit := close + target_value
long_stop_loss := close - stoploss_value
strategy.entry("Long", strategy.long) // Enter a long trade
strategy.exit("Take Profit/Stop Loss", "Long", limit=long_take_profit, stop=long_stop_loss)
inTrade := true // Mark trade as active
if (shortCondition)
short_entry_price := close
short_take_profit := close - target_value
short_stop_loss := close + stoploss_value
strategy.entry("Short", strategy.short) // Enter a short trade
strategy.exit("Take Profit/Stop Loss", "Short", limit=short_take_profit, stop=short_stop_loss)
inTrade := true // Mark trade as active
// Plot the levels on the chart only when in a trade
plot(inTrade and not na(long_take_profit) ? long_take_profit : na, color=color.green, linewidth=2, style=plot.style_linebr, title="Take Profit (Long)")
plot(inTrade and not na(long_stop_loss) ? long_stop_loss : na, color=color.red, linewidth=2, style=plot.style_linebr, title="Stop Loss (Long)")
plot(inTrade and not na(short_take_profit) ? short_take_profit : na, color=color.green, linewidth=2, style=plot.style_linebr, title="Take Profit (Short)")
plot(inTrade and not na(short_stop_loss) ? short_stop_loss : na, color=color.red, linewidth=2, style=plot.style_linebr, title="Stop Loss (Short)")
plotshape(series=longCondition and not inTrade, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=shortCondition and not inTrade, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")