本策略属于短线 scalping 策略类型,其目标是频繁开仓平仓,通过小额盈利并控制下行风险来实现稳定收益。策略通过均线指标判断可能的反转点入场做多,并设定快速止盈目标来锁定小额利润。
该策略使用 4 个移动均线,分别是 9 周期、50 周期、100 周期和 200 周期均线。
具体交易规则为:
这样的组合判断可以找到价格短期处于下跌但可能反转的时机点做多。
平仓规则为 9 周期均线上穿 200 周期均线时平多仓。这里设置一个较近的止盈目标,旨在通过频繁小额盈利实现稳定收益。
可以通过以下方法降低风险:
该策略可以从以下几个方面进行优化:
测试更多均线周期参数,找到更准确判断反转的组合。
适当放宽止盈距离,追求更多趋势利润。
例如 KDJ、MACD 等,进行确认,减少无效交易。
设定仓位大小根据具体止盈点和止损点进行动态调整。
在止盈出场后,如果趋势继续,可以考虑通过条件重新入场。
本策略属于短线 scalping 策略类型,通过判断短期反转的均线组合形成交易信号,并设定较近止盈来频繁获利。这可以有效控制单笔损失和风险,适合于小资金量的增长。但存在盈利空间小、交易频繁等问题。我们可以通过参数优化、止盈调整、加入指标过滤等方法进行改进,在保持其优势的基础上,进一步扩大盈利空间,使策略更稳定高效。同时要注重持续学习其他更多元化的策略思路。
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
//strategy(shorttitle='Moving Average Scalper (by Coinrule)',title='Moving Average Scalper', overlay=true, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)
//Backtest dates
fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)
fromDay = input(defval = 10, title = "From Day", type = input.integer, minval = 1, maxval = 31)
fromYear = input(defval = 2019, title = "From Year", type = input.integer, minval = 1970)
thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)
thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)
thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970)
showDate = input(defval = true, title = "Show Date Range", type = input.bool)
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => true // create function "within window of time"
//MA inputs and calculations
movingaverage_signal = sma(close, input(9))
movingaverage_fast = sma(close, input(50))
movingaverage_slow = sma(close, input(200))
movingaverage_mid= sma(close, input(100))
//Entry
bullish = crossover(movingaverage_signal, movingaverage_fast)
strategy.entry(id="long", long = true, when = bullish and movingaverage_fast < movingaverage_mid and movingaverage_mid < movingaverage_slow and window())
//Exit
bearish = crossover(movingaverage_signal, movingaverage_slow)
Stop_loss= ((input (2))/100)
Take_profit= ((input (8))/100)
longStopPrice = strategy.position_avg_price * (1 - Stop_loss)
longTakeProfit = strategy.position_avg_price * (1 + Take_profit)
strategy.close("long", when = bearish)
// close < longStopPrice or close > longTakeProfit and window())
//PLOT
plot(movingaverage_signal, color=color.black, linewidth=2 )
plot(movingaverage_fast, color=color.orange, linewidth=2)
plot(movingaverage_slow, color=color.purple, linewidth=2)
plot(movingaverage_mid, color=color.blue, linewidth=2)