
이 전략은 가격 파동 이론과 평평한 이동 평균을 결합하여 트렌드 형성 기회를 찾고, 합리적인 스톱로스를 설정하고 스톱로스를 추적하여 위험을 통제하여 수익을 극대화합니다. 전략은 지정된 거래 시간 동안만 포지션을 열고, 특정 시간의 시장 변동을 피합니다.
위험 해소:
이 전략은 가격 파동 이론과 평평 평균 지표를 통합하여, 지정된 거래 시간대를 회피한 후, 가격 파동 방향과 트렌드를 판단하여 입장을 확인하고, 스톱로스를 설정하고, 스톱로스를 추적하여 위험을 제어하고, 역전 신호가 발생했을 때 멈춥니다. 전략은 변수 최적화 및 보조 지표를 추가하여 안정성과 수익률을 더욱 향상시킬 수 있습니다.
/*backtest
start: 2022-11-12 00:00:00
end: 2023-11-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("FX Strategy Based on Fractals and SMMA", overlay=true)
// パラメータ
SMMAPeriod1 = input(30, title="SMMA Period")
StopLoss1 = input(7, title="Stop Loss %")
TrailingStopCoef1 = input(2.7, title="Trailing Stop Coefficient")
fractalPeriod = input(5, title="Fractal Period")
// SMMAの計算関数
smma(src, length) =>
var float smma = na
if na(smma[1])
smma := sma(src, length)
else
smma := (smma[1] * (length - 1) + src) / length
smma
// フラクタルの近似
highFractal = high[2] > high[1] and high[2] > high[3] and high[2] > high[4] and high[2] > high
lowFractal = low[2] < low[1] and low[2] < low[3] and low[2] < low[4] and low[2] < low
// エントリー条件
longEntrySignal = lowFractal and close[1] < smma(close, SMMAPeriod1)
shortEntrySignal = highFractal and close[1] > smma(close, SMMAPeriod1)
// エントリー実行
if (longEntrySignal)
strategy.entry("Long", strategy.long)
if (shortEntrySignal)
strategy.entry("Short", strategy.short)
// トレーリングストップの計算
atrValue = atr(10)
longStopPrice = close - atrValue * TrailingStopCoef1
shortStopPrice = close + atrValue * TrailingStopCoef1
// トレーリングストップの設定
strategy.exit("Exit Long", "Long", stop=longStopPrice)
strategy.exit("Exit Short", "Short", stop=shortStopPrice)
// バックテスト期間の設定(MetaTraderのバックテストと同じ期間)
startYear = 2007
startMonth = 05
startDay = 01
endYear = 2022
endMonth = 04
endDay = 01
startDate = timestamp(startYear, startMonth, startDay, 00, 00)
endDate = timestamp(endYear, endMonth, endDay, 23, 59)
// バックテスト期間内でのみトレードを実行
if (time >= startDate and time <= endDate)
if (longEntrySignal)
strategy.entry("Long", strategy.long)
if (shortEntrySignal)
strategy.entry("Short", strategy.short)