CASHISKING | CASHISKING
CMF, EMA, SMA
이 전략은 Chaikin 자금 흐름 ((CMF) 지표와 지수 이동 평균 ((EMA) 를 기반으로 거래 신호를 생성한다. 먼저 지정된 주기 내의 CMF 값을 계산하고, 그 다음 두 개의 다른 주기의 EMA를 사용하여 CMF 데이터를 평형화한다. 빠른 EMA가 느린 EMA 위를 가로지르면 구매 신호를 생성하고, 반대로 판매 신호를 생성한다. 이 전략은 또한 위험을 제어하고 이익을 잠금하기 위해 중지 및 중지 조건을 설정한다.
이 전략은 Chaikin 자금 흐름 지표와 지수 이동 평균을 사용하여 가격과 거래량 데이터를 결합하여 트렌드 추적을 주요 아이디어로 삼고 있으며 위험을 제어하기 위해 스톱 및 스톱 조건을 설정합니다. 전략의 장점은 여러 측면의 요소를 종합적으로 고려하여 다양한 시간 단위의 추세를 포착 할 수 있다는 것입니다. 그러나 매개 변수 설정 및 트렌드 식별에서 여전히 최적화 할 수있는 공간이 있습니다.
/*backtest
start: 2023-06-01 00:00:00
end: 2024-06-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("CASHISKING", overlay=false)
// Kullanıcı girişleri ile parametreler
cmfPeriod = input.int(200, "CMF Periyodu", minval=1)
emaFastPeriod = input.int(80, "Hızlı EMA Periyodu", minval=1)
emaSlowPeriod = input.int(160, "Yavaş EMA Periyodu", minval=1)
stopLossPercent = input.float(3, "Stop Loss Yüzdesi", minval=0.1) / 100
stopGainPercent = input.float(5, "Stop Gain Yüzdesi", minval=0.1) / 100
// CMF hesaplama fonksiyonu
cmfFunc(close, high, low, volume, length) =>
clv = ((close - low) - (high - close)) / (high - low)
valid = not na(clv) and not na(volume) and (high != low)
clv_volume = valid ? clv * volume : na
sum_clv_volume = ta.sma(clv_volume, length)
sum_volume = ta.sma(volume, length)
cmf = sum_volume != 0 ? sum_clv_volume / sum_volume : na
cmf
// CMF değerlerini hesaplama
cmf = cmfFunc(close, high, low, volume, cmfPeriod)
// EMA hesaplamaları
emaFast = ta.ema(cmf, emaFastPeriod)
emaSlow = ta.ema(cmf, emaSlowPeriod)
// Göstergeleri çiz
plot(emaFast, color=color.blue, title="EMA 23")
plot(emaSlow, color=color.orange, title="EMA 50")
// Alım ve Satım Sinyalleri
crossOverHappened = ta.crossover(emaFast, emaSlow)
crossUnderHappened = ta.crossunder(emaFast, emaSlow)
// Kesişme sonrası bekleme sayacı
var int crossOverCount = na
var int crossUnderCount = na
if (crossOverHappened)
crossOverCount := 0
if (crossUnderHappened)
crossUnderCount := 0
if (not na(crossOverCount))
crossOverCount += 1
if (not na(crossUnderCount))
crossUnderCount += 1
// Alım ve Satım işlemleri
if (crossOverCount == 2)
strategy.entry("Buy", strategy.long)
crossOverCount := na // Sayaç sıfırlanır
if (crossUnderCount == 2)
strategy.entry("Sell", strategy.short)
crossUnderCount := na // Sayaç sıfırlanır
// Stop Loss ve Stop Gain hesaplama
longStopPrice = strategy.position_avg_price * (1 - stopLossPercent)
shortStopPrice = strategy.position_avg_price * (1 + stopLossPercent)
longTakeProfitPrice = strategy.position_avg_price * (1 + stopGainPercent)
shortTakeProfitPrice = strategy.position_avg_price * (1 - stopGainPercent)
// Stop Loss ve Stop Gain'i uygula
if (strategy.position_size > 0 and strategy.position_avg_price > 0)
strategy.exit("Stop", "Buy", stop=longStopPrice, limit=longTakeProfitPrice)
else if (strategy.position_size < 0 and strategy.position_avg_price > 0)
strategy.exit("Stop", "Sell", stop=shortStopPrice, limit=shortTakeProfitPrice)