
この戦略は,速動平均,遅動平均,MACD指標を計算することによって,価格傾向の判断を実現し,金叉死叉取引シグナルを構築し,ストップ・ストップ・ストラストラストと組み合わせて利益をロックし,トレンドの継続的な追跡を実現します.
この戦略は,主に3つの指標に基づいて構築されています.
まず,急速移動平均と2つのゆっくり移動平均を計算する. 急速移動平均の上に2つのゆっくり移動平均を穿越すると買い信号が生成され,急速移動平均の下に2つのゆっくり移動平均を穿越すると売り信号が生成される. これにより,価格の短期的傾向と長期的傾向の関係を判断し,金叉死叉取引を実現する.
次に,MACD線,信号線,直角図を含むMACD指標を計算する.MACD直角図>0時には多頭指標;MACD直角図時には空頭指標である.このように金叉死叉信号の信頼性を判断する.
最後に,ストップ・ストップ・トラッキング・ストップ・メカニズムと組み合わせる. ストップ・ストップとストップ・ストップの利用により,利益をロックし,リスクをコントロールする. ストップ・ストップの利用により,利益をトラッキングする.
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
リスクに対する対処法:
この戦略は,以下の点で最適化できます.
この戦略は,全体として,金叉死叉とMACD指標を用いてトレンド判断し,ストップロスを追跡するためのシンプルで効果的な戦略である.トレンド追跡と利潤ロックが実現され,カスタマイズ性が強く,複数の品種に適用され,汎用型のパラメータ最適化戦略である.一定のリスクと最適化余地があるが,全体的に言えば,信頼できる実用的な取引戦略である.
/*backtest
start: 2023-12-14 00:00:00
end: 2023-12-21 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy('The Puria Method', shorttitle = 'Puria',overlay = true)
//=== GENERAL INPUTS ===
// short ma
maFastSource = input(defval = close, title = "Fast MA Source")
maFastLength = input(defval = 5, title = "Fast MA Period", minval = 1)
// long ma 1
maSlow1Source = input(defval = low, title = "Slow MA1 Source")
maSlow1Length = input(defval = 85, title = "Slow MA Period", minval = 1)
// long ma 2
maSlow2Source = input(defval = low, title = "Slow MA2 Source")
maSlow2Length = input(defval = 75, title = "Slow MA Period", minval = 1)
//macd
macdFastLength = input(defval = 12, title = "Fast MACD Period", minval = 1)
macdSlowLength = input(defval = 26, title = "Slow MACD Period", minval = 1)
macdSmaLength = input(defval = 9, title = "SMA MACD Period", minval = 1)
// the risk management inputs
inpTakeProfit = input(defval = 30, title = "Take Profit", minval = 0)
inpStopLoss = input(defval = 10, title = "Stop Loss", minval = 0)
inpTrailStop = input(defval = 5, title = "Trailing Stop Loss", minval = 0)
inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)
// 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
// === SERIES SETUP ===
maFast = ema(maFastSource, maFastLength)
maSlow1 = wma(maSlow1Source, maSlow1Length)
maSlow2 = wma(maSlow2Source, maSlow2Length)
[_, signal, histLine] = macd(close, macdFastLength, macdSlowLength, macdSmaLength)
// === PLOTTING ===
fast = plot(maFast, title = "Fast MA", color = green, linewidth = 2, style = line, transp = 50)
slow1 = plot(maSlow1, title = "Slow MA1", color = red, linewidth = 2, style = line, transp = 50)
slow2 = plot(maSlow2, title = "Slow MA2", color = red, linewidth = 2, style = line, transp = 50)
// === LOGIC ===
signalUp = crossover(maFast, maSlow1) and crossover(maFast, maSlow2) and histLine > 0
signalDown = crossunder(maFast, maSlow1) and crossunder(maFast, maSlow2) and histLine < 0
// ===STRATEGY===
strategy.entry(id = "Long", long = true, when = signalUp)
strategy.entry(id = "Short", long = false, when = signalDown)
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)