This strategy uses Mark Minervini’s stock selection template and moving average indicators to determine price trends for automated entry and stop-loss. It mainly judges whether stock prices are in an uptrend and whether they have broken through key moving averages to generate buy signals. At the same time, the strategy sets a stop-loss line to actively stop losses when prices fall back.
The strategy mainly judges the following conditions and generates a buy signal when they are met at the same time:
When the above conditions are met, the strategy judges that the stock price is in an upward trend and generates a buy signal.
In addition, the strategy also sets a stop-loss line. When the stock price falls back by 5% from its peak or rises by 10%, it will stop loss or take profit.
The strategy overall follows the idea of trend trading, generating buy signals when the uptrend of stock prices is confirmed. At the same time, a stop-loss mechanism is set to control risks. By optimizing various detailed parameters, the stability and profitability of the strategy can be further improved. However, no strategy can completely avoid market risks, so investors need to treat it cautiously.
/*backtest start: 2022-12-13 00:00:00 end: 2023-12-19 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy(title="Pure Mark Minervini 10%TP 5%CL", pyramiding = 0, commission_type=strategy.commission.percent, commission_value=0.08, overlay=true) ma50 = sma(close,50) ma150 = sma(close,150) ma200 = sma(close,200) ma200_22 = ma200[22] high_loopback = input(260, "High Lookback Length") low_loopback = input(260, "Low Lookback Length") highest_price = highest(high, high_loopback) lowest_price = lowest(low, low_loopback) above52lo = ((close/lowest_price)-1)*100 below52hi = (1-(close/highest_price))*100 ep = strategy.position_avg_price trigger = close>ma150 and close>ma200 and ma150>ma200 and ma200>ma200_22 and ma50>ma150 and ma50>ma200 and close>ma50 and above52lo>=25 and below52hi<=25 and close>0.3 var label maLabel = na if (trigger) yLocation = close>ma150 and close>ma200 and ma150>ma200 and ma200>ma200_22 and ma50>ma150 and ma50>ma200 and close>ma50 and above52lo>=25 and below52hi<=25 and close>0.3 ? yloc.abovebar : yloc.belowbar // labelStyle = close>ma150 and close>ma200 and ma150>ma200 and ma200>ma200_22 and ma50>ma150 and ma50>ma200 and close>ma50 and above52lo>=25 and below52hi<=25 and close>0.3 ? // label.style_labeldown : // label.style_labelup buy = close>ma150 and close>ma200 and ma150>ma200 and ma200>ma200_22 and ma50>ma150 and ma50>ma200 and close>ma50 and above52lo>=25 and below52hi<=25 and close>0.3 sell = close>ep*1.1 or close<ep*0.95 strategy.entry("TF", strategy.long, when = buy) strategy.close("TF", when = sell)