Tags: TAEMAATR

This strategy is a trading bot strategy based on the CDC action zone. It uses the 12-period and 26-period Exponential Moving Averages (EMA) to determine market trends, going long when the short-term EMA is above the long-term EMA and going short when the opposite is true. The strategy employs Average True Range (ATR) to set dynamic take profit and stop loss levels. The take profit level is determined based on ATR and a multiplier, while the stop loss level is fixed at 5% of the current closing price.

- Calculate the 12-period and 26-period EMAs to determine market trends.
- Calculate ATR to set dynamic take profit and stop loss levels.
- When the short-term EMA is above the long-term EMA, a buy signal is generated, and a long position is opened.
- When the short-term EMA is below the long-term EMA, a sell signal is generated, and a short position is opened.
- The take profit level is determined based on ATR and a multiplier, and the position is closed when the price reaches the take profit level.
- The stop loss level is fixed at 5% of the current closing price, and the position is closed when the price reaches the stop loss level.

- Using EMAs to capture market trends can effectively adapt to different market conditions.
- Employing ATR to set dynamic take profit levels can better protect profits.
- Fixed stop loss levels help control risk and limit losses to an acceptable range.
- The code structure is clear and easy to understand and modify, making it suitable for further optimization.

- EMAs are lagging indicators and may generate false signals when the market changes rapidly.
- ATR-based take profit levels may not protect profits in time during high market volatility.
- Fixed stop loss levels may lead to premature position closures in some cases, missing out on potential profits.
- The strategy does not consider trading costs and slippage, so actual trading results may differ from backtesting results.

- Experiment with other trend indicators, such as MACD or moving average crossovers, to improve signal accuracy.
- Optimize the ATR multiplier and take profit/stop loss percentages to better adapt to different market conditions.
- Introduce dynamic stop loss mechanisms, such as trailing stops or volatility-based stops, to better control risk.
- Consider trading costs and slippage, and choose appropriate trading instruments and trading sessions to improve the strategy’s actual performance.

This strategy is an ATR-based take profit and stop loss trading bot strategy based on the CDC action zone. It uses EMAs to capture market trends, ATR to set dynamic take profit levels, and fixed percentage stop losses to control risk. Although the strategy has certain advantages, it still has some risks and room for improvement. With further optimization and testing, the strategy may achieve good performance in actual trading.

/*backtest start: 2024-05-01 00:00:00 end: 2024-05-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("CDC Action Zone Trading Bot with ATR for Take Profit and 5% Stop Loss", overlay=true) // ดึงข้อมูลราคาปิด close_price = close // คำนวณเส้น EMA 12 และ EMA 26 ema12 = ta.ema(close_price, 12) ema26 = ta.ema(close_price, 26) // คำนวณ ATR atr_length = input.int(14, title="ATR Length") atr = ta.atr(atr_length) // กำหนด Multiplier สำหรับ ATR Trailing Stoploss mult_atr_stoploss = input.float(2.5, title="ATR Stoploss Multiplier") // คำนวณ ATR Trailing Stoploss prev_stoploss = close_price for i = 1 to 10 prev_stoploss := math.max(prev_stoploss, high[i] - mult_atr_stoploss * atr) // กำหนด Take Profit เป็น ATR Trailing Stoploss takeProfitPercent = input.float(10, title="Take Profit (%)") / 100 takeProfit = close_price + (close_price - prev_stoploss) * takeProfitPercent // กำหนด Stop Loss เป็น 5% ของราคาปิดปัจจุบัน stopLossPercent = input.float(5, title="Stop Loss (%)") / 100 stopLoss = close_price * stopLossPercent // กำหนดสีแท่งกราฟ buyColor = input.color(color.green, title="Buy Color") sellColor = input.color(color.red, title="Sell Color") neutralColor = input.color(color.gray, title="Neutral Color") color = if (ema12 > ema26) buyColor else if (ema12 < ema26) sellColor else neutralColor // สัญญาณ Buy buySignal = (color == buyColor) and (color[1] != buyColor) // สัญญาณ Sell sellSignal = (color == sellColor) and (color[1] != sellColor) // เปิด Position Long if (buySignal) strategy.entry("Long", strategy.long) // เปิด Position Short if (sellSignal) strategy.entry("Short", strategy.short) // ปิด Position เมื่อถึง Take profit if (strategy.position_size > 0 and close_price > takeProfit) strategy.exit("Long", profit=takeProfit) // ปิด Position เมื่อถึง Stop loss if (strategy.position_size > 0 and close_price < stopLoss) strategy.exit("Long", loss=stopLoss) // ปิด Position เมื่อถึง Take profit if (strategy.position_size < 0 and close_price < takeProfit) strategy.exit("Short", profit=takeProfit) // ปิด Position เมื่อถึง Stop loss if (strategy.position_size < 0 and close_price > stopLoss) strategy.exit("Short", loss=stopLoss)

- EMA Dynamic Trend Following Trading Strategy
- G-Trend EMA ATR Intelligent Trading Strategy
- Volatility and Linear Regression-based Long-Short Market Regime Optimization Strategy
- Keltner Channels EMA ATR Strategy
- K Consecutive Candles Bull Bear Strategy
- Supertrend and EMA Combination Strategy
- ATR and EMA-based Dynamic Take Profit and Stop Loss Adaptive Strategy
- Triple EMA Crossover Strategy
- EMA, RSI, TA, Multi-Indicator Trading Strategy
- RSI50_EMA Long Only Strategy

- Dynamic Trend Following Strategy
- Smooth Moving Average Stop Loss & Take Profit Strategy with Trend Filter and Exception Exit
- MACD Convergence Strategy with R:R, Daily Limits, and Tighter Stop Loss
- Starlight Moving Average Crossover Strategy
- Percentage Threshold Quantitative Trading Strategy
- Moving Average Crossover Strategy Based on Dual Moving Averages
- MACD and Supertrend Combination Strategy
- Buy/Sell Strategy Based on Volume & Candlestick Patterns
- SMA Trend Following Strategy with Trailing Stop-Loss and Disciplined Re-Entry
- EMA and Bollinger Bands Breakout Strategy
- Continuous Candle Based Dynamic Grid Adaptive Moving Average with Dynamic Stop Loss Strategy
- MA Cross Strategy
- Trend-Following Trading Strategy with Momentum Filtering
- RSI and Linear Regression Channel Trading Strategy
- Double Vegas Channel Volatility-Adjusted SuperTrend Quantitative Trading Strategy
- EMA RSI Crossover Strategy
- Moving Average Convergence Momentum Cloud Strategy
- Dual Moving Average Crossover Stop Loss and Take Profit Strategy
- TEMA Dual Moving Average Crossover Strategy
- Multi-Timeframe SMA Trend Following Strategy with Dynamic Stop Loss