
この戦略は,5日目指数移動平均 ((EMA5) と13日目指数移動平均 ((EMA13) の交差を用いて取引信号を生成する.EMA5の上を穿ったとき,マルチシグナルを生成する;EMA5下を穿ったとき,空きシグナルを生成する.この戦略は,短期トレンドの変化を捉え,二つの移動平均の交差を用いて入場と出場点を決定する.
この戦略の核心は,2つの異なる周期の指標移動平均 (EMA) の交差を利用して取引シグナルを生成することである.EMAは一般的な技術指標であり,最近の価格データにより高い重みを与え,したがって,単純な移動平均 (SMA) に比べて価格の変化をより迅速に反映することができる.短期EMA (EMA5のような) が長期EMA (EMA13のような) を越えたときに,価格の上昇が強化され,多値シグナルが生成することを示す.逆に,短期EMAが長期EMAを越えたときに,価格の下落が強化され,空きシグナルが生成することを示す.
EMA5とEMA13の交差戦略は,二つの異なる周期EMAの交差によって価格の傾向の変化を捕捉する簡単な使いやすいトレンド追跡戦略である.この戦略の優点は,シンプルで,適応力があり,タイムリーであることにあるが,同時に,偽信号,遅滞性,停止の欠如などのリスクもある.戦略のパフォーマンスをさらに最適化するために,トレンドフィルター,停止の設定,最適化パラメータの追加,および他の技術指標の方法との組み合わせを考慮することができる.実際のアプリケーションでは,特定の市場環境と取引品種に応じて調整と最適化が必要である.
/*backtest
start: 2023-05-11 00:00:00
end: 2024-05-16 00:00:00
period: 2d
basePeriod: 1d
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/
// © Milankacha
//@version=5
strategy('5-13 EMA by Naimesh ver04', overlay=true)
qty = input(1, 'Buy quantity')
testStartYear = input(2021, 'Backtest Start Year')
testStartMonth = input(1, 'Backtest Start Month')
testStartDay = input(1, 'Backtest Start Day')
testStartHour = input(0, 'Backtest Start Hour')
testStartMin = input(0, 'Backtest Start Minute')
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, testStartHour, testStartMin)
testStopYear = input(2099, 'Backtest Stop Year')
testStopMonth = input(1, 'Backtest Stop Month')
testStopDay = input(30, 'Backtest Stop Day')
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)
testPeriodBackground = input(title='Color Background?', defval=true)
testPeriodBackgroundColor = testPeriodBackground and time >= testPeriodStart and time <= testPeriodStop ? #00FF00 : na
testPeriod() => true
ema1 = input(5, title='Select EMA 1')
ema2 = input(13, title='Select EMA 2')
//ema3 = input(50, title='Select EMA 3')
//SL = input(70, title='Stoploss')
//TR = input(250, title='Target')
expo = ta.ema(close, ema1)
ma = ta.ema(close, ema2)
//EMA_50 = ta.ema(close, ema3)
//avg_1 = avg (expo, ma)
//s2 = ta.cross(expo, ma) ? avg_1 : na
//plot(s2, style=plot.style_line, linewidth=3, color=color.red, transp=0)
p1 = plot(expo, color=color.rgb(231, 15, 15), linewidth=2)
p2 = plot(ma, color=#0db63a, linewidth=2)
fill(p1, p2, color=color.new(color.white, 80))
longCondition = ta.crossover(expo, ma)
shortCondition = ta.crossunder(expo, ma)
if testPeriod()
//strategy.entry('Long', strategy.long, when=longCondition)
strategy.entry('Short', strategy.short, when=expo<ma)
//strategy.close("Long", expo<ma, comment= 'SL hit')
strategy.close("Short", expo>ma, comment= 'SL hit')
//plotshape(longCondition and close>EMA_50, title='Buy Signal', text='B', textcolor=color.new(#FFFFFF, 0), style=shape.labelup, size=size.normal, location=location.belowbar, color=color.new(#1B8112, 0))
//plotshape(shortCondition and close<EMA_50, title='Sell Signal', text='S', textcolor=color.new(#FFFFFF, 0), style=shape.labeldown, size=size.normal, location=location.abovebar, color=color.new(#FF5733, 0))