この戦略は,移動平均の集積差値指数 ((MACD) と相対強度指数 ((RSI) をベースに暗号通貨の買賣点を判断する取引戦略である.それは,短期と長期の移動平均の差値を計算し,RSIと組み合わせて,市場の傾向と超買超売り状況を判断し,取引決定にシグナルを提供する.
12日間のEMAと26日間のEMAを,短期および長期の移動平均として計算する
MACD柱状図として,短期および長期EMAの差値を計算する
MACDの9日EMAを信号線として計算する
14日RSIを計算して,超買いと超売りを判断します.
MACDで信号線を通過し,RSIが81より大きい場合,買取信号が表示されます.
MACDが信号線を下回り,RSIが27より小さいとき,売り信号が表示されます.
組み込みのポリシーモジュールで入場と出場
MACD指標はトレンドとトレンドの変化を識別し,RSI指標は過剰買いと過剰売りを示し,両者は組み合わせて取引信号の正確性を向上させる
MACD 0軸の上下は,短期および長期のトレンドの方向と強さの変化を表し,市場の方向を判断するための根拠を提供します.
RSI高は過熱と過買の可能性を示し,RSI低は過売の可能性を示し,買い手と売り手を見つけるための根拠を提供します.
取引シグナルがシンプルで明快で,規則に従って取引が容易に実行されます.
設定可能なパラメータを最適化して,異なる市場環境に対応
MACDとRSIによるデータは,偽の突破や異常データの影響を受けやすいので,誤ったシグナルを発信することがあります.
固定のパラメータ設定は,市場の変化に適応し得ず,最適化が必要である
買い/売却のシグナルが遅れて,ターニングポイントで買い/売却ができない
ポジションの空白は2番目で,震災の利潤は得られない.
異なるパラメータの組み合わせをテストし,最適なパラメータを見つけます.
偽突破を防ぐために追加フィルタリング条件を追加
単一取引による損失を減らすために,損失を抑える戦略を増やす.
ポジション管理を増やし,トレンドでポジションを増やし,震動でポジションを減らします.
価格の上昇と価格の上昇を比較して,
異なる品種と時間周期でテスト
この戦略は,MACDとRSIの2つの指標の互補的な優位性を利用して,トレンドの方向とバイズポイントを識別する.最適化パラメータとフィルタリング条件の追加により,戦略の安定性と利益因子を改善することができる.適切な止損とポジション管理の調整も,利益レベルを向上させ,リスクを軽減するのに役立ちます.MACDとRSIの優位性と欠陥は,この戦略がショートラインの取引ではなく,中線トレンドを識別するのに適していることを決定する.全体的に,この戦略はシンプルで実用的で,よりよい回転と実盤の結果を得るため,さらなるテストと最適化に値する.
/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-12 04:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
// Revision: 5
// Author: @Hugo_Moriceau
//study("Thesis_EMLYON_Withdate-strategies-Daily_Crypto_Moriceau_indicator",overlay=true)
// Pyramide 10 order size 100, every tick
strategy("Daily_Crypto_Moriceau_indicator",overlay=true)
// === GENERAL INPUTS ===
fast = 12, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
rsi = rsi(close,14)
tradeInvert = input(defval = false, title = "Invert Trade Direction?")
// === LOGIC ===
// is fast ma above slow ma?
aboveBelow = fastMA >= slowMA ? true : false
// are we inverting our trade direction?
tradeDirection = tradeInvert ? aboveBelow ? false : true : aboveBelow ? true : false
// === Plot Setting ===
//plot(fastMA,color=red)
//plot(slowMA,color=blue)
//barcolor(color=iff(fastMA > slowMA, yellow, na))
//barcolor(color=iff(fastMA < slowMA, black, na))
barcolor(color=iff(macd > 0.12*close , fuchsia, na))
barcolor(color=iff(macd < -0.1*close , lime, na))
dataS= macd > 0.125 and rsi>81 and fastMA > slowMA
dataB= macd < -0.1 and rsi<27 and fastMA< slowMA
plotchar(dataB, char='B',color=black,size = size.tiny,location = location.belowbar,transp= 0)
plotchar(dataS, char='S',color=black,size = size.tiny,location = location.abovebar,transp= 0)
// === BACKTEST RANGE ===
FromMonth = input(defval = 01, title = "From Month", minval = 1)
FromDay = input(defval = 01, title = "From Day", minval = 1)
FromYear = input(defval = 2017, title = "From Year", minval = 2014)
ToMonth = input(defval = 2, title = "To Month", minval = 1)
ToDay = input(defval = 10, title = "To Day", minval = 1)
ToYear = input(defval = 2019, title = "To Year", minval = 2018)
// === STRATEGY RELATED INPUTS ===+
// the risk management inputs
inpTakeProfit = input(defval = 20000, title = "Take Profit", minval = 0)
inpStopLoss = input(defval = 1500, title = "Stop Loss", minval = 0)
inpTrailStop = input(defval = 100, title = "Trailing Stop Loss", minval = 0)
inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)
// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na
useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na
useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na
useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na
// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => not tradeDirection[1] and tradeDirection
exitLong() => tradeDirection[1] and not tradeDirection
strategy.entry(id = "Long", long = true, when = enterLong()) // use function or simple condition to decide when to get in
strategy.close(id = "Long", when = exitLong()) // ...and when to get out
// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => tradeDirection[1] and not tradeDirection
exitShort() => not tradeDirection[1] and tradeDirection
strategy.entry(id = "Short", long = false, when = enterShort())
strategy.close(id = "Short", when = exitShort())
// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)