
この戦略は,双均線とランダムな指標 (ストキャスティック) をベースにしたトレンド追跡取引システムである.この戦略は,均線システムを組み合わせて市場トレンドを判断し,同時にランダムな指標を使用して,オーバーバイのオーバーセール領域の交差信号を捕捉し,リスクを制御するために動的なストップ・ローズ・レベルを設定する.この方法は,取引信号の信頼性を保証するとともに,各取引のリスク/リターン比率を効果的に管理する.
この戦略は,以下の要素を中心に取引を行います.
購入条件は同時に満たされている必要があります:
売る条件は逆です
これは,トレンド追跡と動的取引を組み合わせた完全な戦略システムである.均線システムとランダムな指標の組み合わせによる使用により,取引方向が主動トレンドに適合することを保証するとともに,適切な価格領域で取引することができる.また,戦略は,ダイナミックな止損と固定されたリスク収益比率を使用してリスクを制御するための完善したリスク管理機構を含んでいる.いくつかの固有の制限があるが,推奨された方向の最適化によって戦略の全体的なパフォーマンスはさらに向上することができる.実際のアプリケーションでは,取引者は,特定の市場特性と自身のリスク好みに応じてパラメータを適切に調整することを推奨する.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-11 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © quadawosanya
//@version=5
//indicator("My script")
//@version=5
strategy("EMA-Stochastic Strategy", overlay=true)
// EMA settings
ema50 = ta.ema(close, 50)
ema150 = ta.ema(close, 150)
// Stochastic settings
kLength = 14
dLength = 3
smoothK = 3
stochK = ta.sma(ta.stoch(close, high, low, kLength), smoothK)
stochD = ta.sma(stochK, dLength)
// Parameters for Stop Loss and Take Profit
var float stopLossLevel = na
var float takeProfitLevel = na
// Buy condition
buySignal = (close > ema50 and close > ema150) and (ema50 > ema150) and (stochK < 30 and ta.crossover(stochK, stochD))
// Sell condition
sellSignal = (close < ema50 and close < ema150) and (ema50 < ema150) and (stochK > 70 and ta.crossunder(stochK, stochD))
// Previous low for Stop Loss for Buy
lowBeforeBuy = ta.lowest(low, 5)
// Previous high for Stop Loss for Sell
highBeforeSell = ta.highest(high, 5)
// Entry and exit logic
if (buySignal)
stopLossLevel := lowBeforeBuy
risk = close - stopLossLevel
takeProfitLevel := close + 2 * risk
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Buy", stop=stopLossLevel, limit=takeProfitLevel)
if (sellSignal)
stopLossLevel := highBeforeSell
risk = stopLossLevel - close
takeProfitLevel := close - 2 * risk
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Sell", stop=stopLossLevel, limit=takeProfitLevel)
// Plotting EMAs
plot(ema50, color=color.blue, title="50 EMA")
plot(ema150, color=color.red, title="150 EMA")
// Visualize Buy and Sell signals
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Visualize Stop Loss and Take Profit levels
plot(stopLossLevel, color=color.red, style=plot.style_line, linewidth=2, title="Stop Loss")
plot(takeProfitLevel, color=color.green, style=plot.style_line, linewidth=2, title="Take Profit")
plot(close)