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)