本策略通过计算两组不同参数的EMA指标,并设置买入信号为两组EMA指标发生黄金交叉时,设置卖出信号为另外两组EMA指标发生死亡交叉时,从而实现高效的短线交易策略。
该策略使用4个EMA指标,分别是9周期的EMA1,26周期的EMA2,100周期的EMA3和55周期的EMA4。买入信号设置为EMA1上穿EMA2时,表示短线EMA上穿长线EMA,属于典型的黄金交叉信号。卖出信号设置为EMA3下穿EMA4时,属于死亡交叉信号。这样可以在短线EMA指标发生黄金交叉时快速入市,并在长线EMA指标发生死亡交叉时快速止损止盈出场,实现高效的短线交易。
本策略整体来说是一种非常典型和有效的短线交易策略。优点是快进快出,适合scalping,获利空间大。同时也存在一些风险,需要注意防范。如果参数调整得当,并辅助其他指标进行信号过滤,可以成为非常实用的短线交易策略。
/*backtest
start: 2023-01-05 00:00:00
end: 2024-01-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © YukalMoon
//@version=5
strategy(title="EMA SCALPEUR", overlay=true, initial_capital = 1000)
//// input controls
EMA_L = input.int (title = "EMA_L", defval = 9, minval = 1, maxval = 100, step =1)
EMA_L2 = input.int (title = "EMA_L2", defval = 26, minval = 1, maxval = 100, step =1)
EMA_S = input.int (title = "EMA_S", defval = 100, minval = 1, maxval = 100, step =1)
EMA_S2 = input.int (title = "EMA_S2", defval = 55, minval = 1, maxval = 100, step =1)
/// mise en place de ema
shortest = ta.ema(close, 9)
short = ta.ema(close, 26)
longer = ta.ema(close, 100)
longest = ta.ema(close, 55)
plot(shortest, color = color.red)
plot(short, color = color.orange)
plot(longer, color = color.aqua)
plot(longest, color = color.yellow)
plot(close)
//// trading indicators
EMA1 = ta.ema (close,EMA_L)
EMA2 = ta.ema (close,EMA_L2)
EMA3 = ta.ema (close, EMA_S)
EMA4 = ta.ema (close, EMA_S2)
buy = ta.crossover(EMA1, EMA2)
//sell = ta.crossunder(EMA1, EMA2)
buyexit = ta.crossunder(EMA3, EMA4)
//sellexit = ta.crossover(EMA3, EMA4)
/////strategy
strategy.entry ("long", strategy.long, when = buy, comment = "EXIT-LONG")
//strategy.entry ("short", strategy.short, when = sell, comment = "ENTER-SHORT")
///// market exit
strategy.close ("long", when = buyexit, comment = "ENTER-LONG")
//strategy.close ("short", when = sellexit, comment = "EXIT-SHORT")