This strategy allows flexible configuration of multiple fast/slow moving average pairs. It goes long when all fast MAs crossover above slow MAs, and exits when any fast MA crosses below slow MA. The voting mechanism with multiple MAs aims to form robust position holding decisions.
The key components and rules are:
Multiple fast/slow MAs: Using SMA, WMA, VWMA etc.
Long signal: All fast MAs crossing above slow MAs.
Exit signal: Any fast MA crossing below slow MA.
Profit/loss points: Fixed points based on ATR.
Configurable: Flexible configuration of multiple MA pairs.
The voting-based entry with multiple MAs improves signal reliability. Custom configurations provide flexibility.
Compared to single MA strategies, the advantages are:
Multiple MAs provide more comprehensive trend assessment.
Voting avoids false signals from noise.
Large tuning space from custom MA configurations.
Support for different MA types enhances adaptability.
Defined profit/loss points control per trade risk/reward.
Works better on longer timeframes, less curve whipsaws.
Simple and intuitive logic, easy to implement and operate.
Overall more stable with greater longevity versus single MA.
However, some risks exist:
Increased complexity with multiple MAs.
Risks of over-optimization.
Fundamental lagging in identifying trend changes.
No volume considered, risks being trapped.
Profit/loss points may cause unnecessary exits.
Performance subject to changing market regimes.
Need to monitor reward/risk ratios and curve smoothness.
Robustness across instruments requires validation.
Based on the analysis, enhancements may involve:
Testing parameter robustness across different instruments.
Adding volume or volatility confirmation.
Optimizing profit/loss points.
Setting maximum tolerable drawdown limit.
Constructing dynamic position sizing models.
Evaluating effect from introducing machine learning.
Monitoring maximum drawdown and curve smoothness.
Continual iterations to avoid overfitting.
The configurable multi-MA approach forms a robust position holding mechanism. But preventing overfitting and dynamic adaptations to changing markets are key for any strategy’s longevity. Only through rigorous ongoing optimizations and testing can a quant strategy sustain success.
/*backtest start: 2022-09-16 00:00:00 end: 2023-09-22 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/ // © levieux //@version=5 strategy(title='Configurable Multi MA Crossover Voting System', shorttitle='Configurable Multi MA Crossover Voting System', initial_capital=1000, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1) crossoverConfig= input.string(defval="2x4,3x5,4x6", title="Crossover Config") source= input.source(high) maType= input.string("WMA", title="Moving Average Type", options=["WMA","SMA","VWMA"]) atrPeriod= input(14, title="ATR Period") profitAtr = input(10, title="Profit ATR x") lossAtr = input(5, title="Loss ATR x") ma(src,length,type) => float ma = switch type "SMA" => ta.sma(src, length) "WMA" => ta.wma(src, length) "VWMA" => ta.vwma(src, length) crossoverGroups= str.split(crossoverConfig, ",") crossoverCount= array.size(crossoverGroups) crossovers= array.new_string(crossoverCount) positions= array.new_int(crossoverCount, 0) longVotes= 0 for i= 0 to crossoverCount-1 crossover= str.tostring(array.get(crossoverGroups, i)) crossoverBoundaries= str.split(crossover, "x") int fastLength= math.round(str.tonumber(array.get(crossoverBoundaries, 0))) int slowLength= math.round(str.tonumber(array.get(crossoverBoundaries, 1))) wmaFast= ma(source,fastLength,maType) wmaSlow= ma(source,slowLength,maType) if wmaFast>wmaSlow longVotes:= longVotes + 1 array.set(positions, i, 1) longCondition= longVotes==crossoverCount and strategy.position_size==0 //profitTicks = profitAtr*ta.atr(atrPeriod)/syminfo.mintick //lossTicks = lossAtr*ta.atr(atrPeriod)/syminfo.mintick profitPrice= close+profitAtr*ta.atr(atrPeriod) lossPrice= close-lossAtr*ta.atr(atrPeriod) if strategy.position_size>0 profitPrice:= profitPrice[1] lossPrice:= lossPrice[1] plot(profitPrice, color=color.green) plot(lossPrice, color=color.red) if longCondition and profitPrice>0 strategy.entry("Long", strategy.long) if longVotes<crossoverCount and strategy.position_size>0 and (high>profitPrice or low<lossPrice) strategy.close("Long") longVotes:= 0