Stepwise Pyramiding Moving Average Breakout Strategy
Overview
This strategy uses a stepwise pyramiding approach based on the comparison between the current close price and previous close price to determine the market direction. When a long opportunity is identified, it will long with multiple gradual entries. When a short opportunity is identified, it will short with multiple gradual entries. The number of entries can be set through parameters. At the same time, the strategy incorporates time frame filters where trading signals are only generated within the configured trading time frame.
Strategy Logic
-
Compare current bar's close price (close) with previous bar's close price (close[1]). If close > close[1], it is determined as a long opportunity and set longCondition=1. If close < close[1], it is determined as a short opportunity and set shortCondition=1.
-
Within the allowed trading time frame, if longCondition=1, it will long with multiple gradual entries. If shortCondition=1, it will short with multiple gradual entries.
-
The number of entries is set through the pyramiding parameter, which can be configured from 1 to 5, with 4 as the default.
-
A stop loss condition is set after each entry in case the market reverses.
-
Trading signals can be output to different trading interfaces such as toast or telegram.
The strategy mainly considers the advantages of breakout and moving average strategies. During long or short opportunities, it uses a stepwise pyramiding approach to better follow the trend while controlling risks. It also incorporates time frame filters to avoid generating signals during non-major trading sessions.
Advantage Analysis
-
Stepwise pyramiding follows trends better.
-
Adjustable number of entries makes it more flexible.
-
Supports different trading interfaces for scalability.
-
Has stop loss mechanisms to control risks.
-
Time frame filter avoids false signals.
Risk Analysis
-
Improper parameter settings may lead to larger losses.
-
Network issues may prevent timely stop loss.
-
Parameters need adjustments for different products.
-
Need timely stop loss to lock in profits.
Solutions:
-
Default 4 entries is appropriate.
-
Check network connectivity.
-
Adjust parameters according to product characteristics.
-
Set stop loss levels.
Optimization Directions
-
Consider adding more indicators to judge signal strength.
-
Test parameter optimization results across different products.
-
Incorporate machine learning algorithms to optimize parameters.
-
Enhance risk management mechanisms.
Summary
This stepwise pyramiding moving average breakout strategy integrates the advantages of trend following and risk control. When effective signals are identified, it uses stepwise pyramiding to follow the trend while controlling risk exposure through configurable number of entries. It also incorporates functionalities like time frame filter to avoid false signals. The strategy can be further optimized in many aspects and has great extensibility. In general, it is very effective for trending products and is strongly recommended.
/*backtest
start: 2024-01-05 00:00:00
end: 2024-02-04 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © torresbitmex
//@version=5- 1

