This is a trend following strategy based on moving average crossover. It uses two moving averages with different periods. When the shorter period moving average crosses above the longer period moving average, it goes long. When the shorter period moving average crosses below the longer period moving average, it goes short. This is a typical trend following strategy.
The strategy uses 20-period and 50-period moving averages. It first calculates these two moving averages, then identifies crossover points between them to generate trading signals. When the 20-period moving average crosses above the 50-period moving average, it generates a buy signal. When the 20-period moving average crosses below the 50-period moving average, it generates a sell signal. So the core logic of this strategy is to track the crossover between the two moving averages to determine the turning points in the market trend.
After generating trading signals, the strategy will place orders with fixed stop loss and take profit margins. For example, after buying, it will set a 0.4% stop loss and 0.7% take profit. By setting stop loss and take profit, it controls the risk and reward of individual trades.
The strategy has the following advantages:
There are also some risks with this strategy:
Countermeasures:
The strategy can be optimized in the following aspects:
Overall this is a simple and effective trend following strategy. It catches trend turning points using moving average crossover and controls risk via stop loss and take profit. The strategy suits investors who don’t have high requirements on trend judgment. Further optimization on parameters and models can lead to better strategy performance.
]
/*backtest start: 2022-11-29 00:00:00 end: 2023-12-05 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/ // © danielfepardo //@version=5 strategy("QUANT", overlay=true) lenght1 = input(20) lenght2 = input(50) ema1 = ta.ema(close, lenght1) ema2 = ta.ema(close, lenght2) plot(ema1, color=color.black) plot(ema2, color=color.red) long = ta.crossover(ema1, ema2) SL = 0.004 TP = 0.007 if long == true strategy.entry("Compra Call", strategy.long) longstop=strategy.position_avg_price*(1-SL) longprofit=strategy.position_avg_price*(1+TP) strategy.exit("Venta Call", stop=longstop, limit=longprofit) short = ta.crossover(ema2, ema1) if short == true strategy.entry("Compra Put", strategy.short) shortstop=strategy.position_avg_price*(1+SL) shortprofit=strategy.position_avg_price*(1-TP) strategy.exit("Venta Put", stop=shortstop, limit=shortprofit)