Nhiều chỉ số xác nhận chiến lược chốt lời động DCA của đột phá đường trung bình động

EMA RSI MACD BB DCA HTF
Ngày tạo: 2025-04-11 11:09:00 sửa đổi lần cuối: 2025-04-11 11:09:00
sao chép: 1 Số nhấp chuột: 341
2
tập trung vào
319
Người theo dõi

Nhiều chỉ số xác nhận chiến lược chốt lời động DCA của đột phá đường trung bình động Nhiều chỉ số xác nhận chiến lược chốt lời động DCA của đột phá đường trung bình động

Tổng quan

Chiến lược này sử dụng nhiều chỉ số kỹ thuật như EMA 48, RSI 14, MACD và Bollinger Bands để xác định điểm vào tiềm năng, đồng thời thực hiện các phương pháp quản lý vị trí có cấu trúc và cơ chế kiểm soát rủi ro trước. Cốt lõi của chiến lược là xác định giá và điểm giao thoa của EMA, và sử dụng RSI, MACD và Bollinger Bands để xác nhận, kết hợp với phân tích khung thời gian cao để tránh tín hiệu sai, sử dụng chiến lược DCA ba cấp để tăng vị trí và bảo vệ lợi nhuận bằng nhiều cấp độ dừng và dừng động.

Nguyên tắc chiến lược

Nguyên tắc của chiến lược dựa trên sự xác nhận kết hợp của nhiều chỉ số kỹ thuật, bao gồm các thành phần quan trọng sau:

  1. Hệ thống điều kiện nhập học

    • Giá phải đi qua 48 chu kỳ EMA, đi lên khi nhiều đầu, đi xuống khi trống
    • RSI phải xác nhận cường độ hướng ((trong nhiều đầu> 60, trong không đầu<40)
    • Đường MACD phải đi qua đường tín hiệu để xác nhận hướng động lực
    • Giá phải gần vùng hỗ trợ / kháng cự trước đó
    • RSI ở đỉnh/chèo 5 cho thấy tín hiệu sai
    • High Time Frame xác nhận đây là vị trí điểm dựa thứ hai
  2. Quản lý vị trí động

    • Rủi ro ban đầu được giới hạn ở mức 1-3% tài khoản
    • Kích thước vị trí theo tỷ lệ DCA 1-2-6 để gia tăng vị trí
    • Đặt lệnh dừng lỗ đầu tiên ở vị trí 1-3% điểm vào, tính theo số tiền tiền tệ
    • Sau khi triển khai tất cả DCA, cập nhật dừng lỗ đến vị trí 1.3% của điểm vào
  3. Cơ chế lợi nhuận thông minh

    • Khi giá đạt mức lợi nhuận 0,5%, đóng 25% vị trí
    • Khóa 50% khi giá đạt mức lợi nhuận 1%
    • Sau lần thắng thứ hai, dừng lỗ di chuyển đến vị trí bảo vệ

Phân tích sâu về mã hóa cho thấy chiến lược này cũng bao gồm hệ thống nhận dạng thung lũng đỉnh thông minh để phát hiện sự lệch khỏi mô hình bằng cách theo dõi giá và 5 điểm dao động gần nhất của RSI. Hệ thống xác nhận khung thời gian cao sẽ phân tích các vị trí hỗ trợ và kháng cự trên biểu đồ đường nhật thực để tránh tín hiệu giả trên khung thời gian thấp.

Lợi thế chiến lược

Một phân tích sâu hơn về mã của chiến lược này, chúng ta có thể tóm tắt những ưu điểm đáng chú ý sau:

  1. Hệ thống xác nhận đa tầng: Bằng sự phối hợp của nhiều chỉ số kỹ thuật, khả năng tín hiệu sai bị giảm đáng kể, tăng tỷ lệ giao dịch. Việc sử dụng kết hợp của EMA, RSI, MACD và BRI đảm bảo chất lượng cao của điểm vào.

  2. Quản lý tài chính thông minhPhương pháp sử dụng tỷ lệ 1-2-6 DCA có thể sử dụng chi phí trung bình biến động của thị trường và hạn chế lỗ hổng rủi ro tổng thể. Rủi ro ban đầu chỉ giới hạn trong 1-3% tài khoản, đảm bảo rằng ngay cả trong trường hợp xấu nhất cũng không gây ra tổn thất thảm khốc.

  3. Bảo vệ dừng độngCơ chế dừng lỗ được điều chỉnh theo sự phát triển của giao dịch, đặc biệt là khi một phần lợi nhuận được lấy và dừng lỗ được chuyển sang vị trí bảo vệ, điều này cân bằng hiệu quả giữa nhu cầu bảo vệ lợi nhuận và cho phép giao dịch có không gian thở.

  4. Chiến lược lợi nhuận theo giai đoạnBằng cách đóng 25% và 50% vị trí tại các điểm lợi nhuận 0,5% và 1%, chiến lược có thể khóa một phần lợi nhuận, đồng thời giữ vị trí để nắm bắt các chuyển động thị trường lớn hơn, để cân bằng rủi ro và lợi nhuận.

  5. Xác nhận khung thời gian cao: Sử dụng các mức hỗ trợ và kháng cự của khung thời gian cao hơn để lọc tín hiệu giao dịch, giảm tác động của tiếng ồn và phá vỡ giả mạo thường gặp trên khung thời gian thấp hơn.

Rủi ro chiến lược

Mặc dù chiến lược này được thiết kế tinh tế, nhưng vẫn có một số yếu tố rủi ro cần lưu ý:

  1. Độ nhạy tham sốHiệu suất của chiến lược phụ thuộc rất nhiều vào các thiết lập tham số, bao gồm chu kỳ EMA, ngưỡng RSI và mức DCA. Những thay đổi nhỏ trong các tham số này có thể dẫn đến sự khác biệt đáng kể trong kết quả giao dịch và cần được tối ưu hóa và kiểm tra lại một cách cẩn thận.

  2. Rủi ro biến động lớnMặc dù có cơ chế DCA, giá có thể nhanh chóng vượt quá tất cả các điểm dừng lỗ được thiết lập khi thị trường biến động mạnh, dẫn đến tổn thất thực tế cao hơn dự kiến. Đối với rủi ro này, bạn có thể xem xét sử dụng kích thước vị trí ban đầu nghiêm ngặt hơn hoặc tạm dừng giao dịch trong thời gian biến động cao.

  3. Tác động chồng lên nhau của tổn thất liên tục: Ngay cả khi rủi ro của một giao dịch đơn lẻ là hạn chế, thua lỗ liên tục có thể dẫn đến sự sụt giảm đáng kể của đường cong vốn. Các biện pháp kiểm soát rủi ro tổng thể bổ sung được đề xuất, chẳng hạn như giới hạn tổn thất tối đa hàng ngày hoặc hàng tuần.

  4. Sự phức tạp trong việc nhận diện RSI: Phát hiện RSI lệch trong mã dựa trên độ chính xác của dữ liệu lịch sử, có thể không đủ tin cậy trong một số điều kiện thị trường. Sử dụng các phương pháp thống kê tiên tiến hơn để xác nhận tín hiệu lệch có thể được xem xét.

  5. Tùy thuộc vào thị trường thanh khoảnTrong các thị trường có tính thanh khoản thấp, một lượng lớn các lệnh DCA có thể gặp phải vấn đề trượt điểm, ảnh hưởng đến hiệu quả tổng thể của chiến lược.

Hướng tối ưu hóa chiến lược

Dựa trên phân tích sâu về mã, đây là một số hướng mà chiến lược này có thể được tối ưu hóa:

  1. Điều chỉnh tham số động: Có thể đưa ra cơ chế điều chỉnh tham số động dựa trên biến động của thị trường. Ví dụ, yêu cầu giảm giá RSI tự động tăng trong thời gian biến động cao, hoặc điều chỉnh độ dài EMA để phù hợp với chu kỳ thị trường khác nhau.

  2. Tăng cường từ chối phát hiện: RSI hiện tại khá đơn giản để phát hiện và có thể tăng độ chính xác bằng cách giới thiệu các thuật toán phức tạp hơn, chẳng hạn như sử dụng chuyển đổi Fisher RSI hoặc thêm xác nhận giao dịch. Điều này sẽ làm giảm tín hiệu báo cáo sai và tăng độ chính xác của chiến lược.

  3. Tối ưu hóa lợi nhuận thông minhLợi ích cố định hiện tại có thể được cải thiện thành lợi ích động dựa trên biến động của thị trường. Ví dụ, đặt mục tiêu lợi nhuận cao hơn trong thời gian biến động cao và giảm mục tiêu trong thời gian biến động thấp để thích ứng với điều kiện thị trường thay đổi.

  4. Quản lý tài chính chi tiết: Có thể tối ưu hóa tỷ lệ DCA và điểm kích hoạt, điều chỉnh động lực theo cấu trúc thị trường và cường độ của xu hướng hiện tại. Ví dụ, tỷ lệ DCA mạnh hơn trong xu hướng mạnh và bảo thủ hơn trong xu hướng yếu.

  5. Tối ưu hóa thời gian giao dịchGhi chú: giới thiệu bộ lọc thời gian dựa trên khối lượng giao dịch và biến động, tránh giao dịch trong thời gian hoạt động thấp. Điều này có thể được thực hiện bằng cách phân tích dữ liệu lịch sử để xác định cửa sổ thời gian giao dịch tốt nhất.

Tóm tắt

Chiến lược DCA Breakthrough Dynamic Stop (DCA) là một hệ thống giao dịch đường ngắn được thiết kế tinh tế, kết hợp một số công cụ phân tích kỹ thuật với các kỹ thuật quản lý tiền tiên tiến. Bằng cách làm việc với các chỉ số như EMA, RSI, MACD và Blink, chiến lược này có thể xác định các điểm vào có xác suất cao, đồng thời sử dụng phương pháp DCA có cấu trúc và cơ chế dừng / dừng động để quản lý rủi ro và khóa lợi nhuận.

Mặc dù chiến lược này có những ưu điểm rõ ràng, bao gồm kiểm soát rủi ro nghiêm ngặt, hệ thống xác nhận nhiều cấp và cơ chế lợi nhuận thông minh, người dùng vẫn cần cảnh giác với các rủi ro do sự nhạy cảm của tham số và biến động mạnh của thị trường.

Đối với các nhà giao dịch, chiến lược này phù hợp nhất với các thị trường có đủ tính thanh khoản, và cần có sự phản hồi lịch sử và tối ưu hóa tham số đầy đủ trước khi sử dụng. Với việc thực hiện cẩn thận và điều chỉnh theo dõi liên tục, hệ thống giao dịch đa cấp này có thể trở thành một vũ khí mạnh mẽ trong hộp công cụ của các nhà giao dịch ngắn.

Mã nguồn chiến lược
/*backtest
start: 2024-04-11 00:00:00
end: 2025-04-10 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=6
strategy("Scalping Strategy with DCA - V2", overlay=true, margin_long=100, margin_short=100)

// Input parameters
emaLength = input.int(48, title="EMA Length", minval=1, group="Main Indicators")
rsiLength = input.int(14, title="RSI Length", minval=1, group="Main Indicators")
macdShortLength = input.int(12, title="MACD Short Length", minval=1, group="Main Indicators")
macdLongLength = input.int(30, title="MACD Long Length", minval=1, group="Main Indicators")
macdSignalLength = input.int(9, title="MACD Signal Length", minval=1, group="Main Indicators")
bbLength = input.int(20, title="Bollinger Bands Length", group="Main Indicators")
bbMult = input.float(2.0, title="Bollinger Bands Multiplier", group="Main Indicators")

// Risk management parameters
initialRiskPercent = input.float(1.0, title="Initial Risk % of Account", minval=0.1, maxval=3.0, step=0.1, group="Risk Management")
stopLossPercent = input.float(1.5, title="Stop Loss % (Unboosted)", minval=0.5, maxval=3.0, step=0.1, group="Risk Management")
fixedSLPercent = input.float(1.3, title="Fixed SL % after full DCA", minval=0.1, maxval=5.0, step=0.1, group="Risk Management")
takeProfitPercent1 = input.float(0.5, title="First Take Profit % (25% Volume)", minval=0.1, group="Risk Management")
takeProfitPercent2 = input.float(1.0, title="Second Take Profit % (50% Volume)", minval=0.1, group="Risk Management")

// DCA parameters
enableDCA = input.bool(true, title="Enable DCA", group="DCA Settings")
dcaLevel1 = input.float(1.0, title="DCA Level 1 % Drop", minval=0.1, group="DCA Settings")
dcaLevel2 = input.float(2.0, title="DCA Level 2 % Drop", minval=0.1, group="DCA Settings")

// Higher Timeframe parameters
higherTF = input.timeframe("D", title="Higher Timeframe for Confirmation", group="Advanced Settings")
useHTFConfirmation = input.bool(true, title="Use Higher Timeframe Confirmation", group="Advanced Settings")

// Debug parameters
showLabels = input.bool(true, title="Show Entry/Exit Labels", group="Visual")
showSL = input.bool(true, title="Show Stop Loss Lines", group="Visual")
showTP = input.bool(true, title="Show Take Profit Lines", group="Visual")

// Calculate indicators
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
[macdLine, signalLine, _] = ta.macd(close, macdShortLength, macdLongLength, macdSignalLength)
[middle, upper, lower] = ta.bb(close, bbLength, bbMult)

// Variables for tracking peaks and troughs
var priceHighs = array.new_float(0)
var priceLows = array.new_float(0)
var rsiHighs = array.new_float(0)
var rsiLows = array.new_float(0)

// Track last 5 peaks and troughs for both price and RSI
pivot_high = ta.pivothigh(high, 2, 2)
if not na(pivot_high)
    array.push(priceHighs, pivot_high)
    if array.size(priceHighs) > 5
        array.shift(priceHighs)

pivot_low = ta.pivotlow(low, 2, 2)
if not na(pivot_low)
    array.push(priceLows, pivot_low)
    if array.size(priceLows) > 5
        array.shift(priceLows)

rsi_pivot_high = ta.pivothigh(rsi, 2, 2)
if not na(rsi_pivot_high)
    array.push(rsiHighs, rsi_pivot_high)
    if array.size(rsiHighs) > 5
        array.shift(rsiHighs)

rsi_pivot_low = ta.pivotlow(rsi, 2, 2)
if not na(rsi_pivot_low)
    array.push(rsiLows, rsi_pivot_low)
    if array.size(rsiLows) > 5
        array.shift(rsiLows)

// Check for RSI divergence
rsiDivergenceBullish = array.size(priceLows) >= 5 and array.size(rsiLows) >= 5 and array.get(priceLows, array.size(priceLows) - 1) < array.get(priceLows, array.size(priceLows) - 5) and array.get(rsiLows, array.size(rsiLows) - 1) > array.get(rsiLows, array.size(rsiLows) - 5)

rsiDivergenceBearish = array.size(priceHighs) >= 5 and array.size(rsiHighs) >= 5 and array.get(priceHighs, array.size(priceHighs) - 1) > array.get(priceHighs, array.size(priceHighs) - 5) and array.get(rsiHighs, array.size(rsiHighs) - 1) < array.get(rsiHighs, array.size(rsiHighs) - 5)

// Check if price is near previous high/low (Rule #4)
isNearPrevHigh = array.size(priceHighs) >= 2 and math.abs(high - array.get(priceHighs, array.size(priceHighs) - 2)) / array.get(priceHighs, array.size(priceHighs) - 2) < 0.01
isNearPrevLow = array.size(priceLows) >= 2 and math.abs(low - array.get(priceLows, array.size(priceLows) - 2)) / array.get(priceLows, array.size(priceLows) - 2) < 0.01

// Higher timeframe confirmation (Rule #10)
// Get pivot points from higher timeframe
htf_is_pivot_low = request.security(syminfo.tickerid, higherTF, not na(ta.pivotlow(low, 2, 2)), barmerge.gaps_off, barmerge.lookahead_off)
htf_is_pivot_high = request.security(syminfo.tickerid, higherTF, not na(ta.pivothigh(high, 2, 2)), barmerge.gaps_off, barmerge.lookahead_off)

// Count pivots in higher timeframe to check if this is the 2nd pivot
var htf_pivot_low_count = 0
var htf_pivot_high_count = 0

if htf_is_pivot_low
    htf_pivot_low_count := htf_pivot_low_count + 1
    htf_pivot_low_count := math.min(htf_pivot_low_count, 10)  // Prevent unlimited counting

if htf_is_pivot_high
    htf_pivot_high_count := htf_pivot_high_count + 1
    htf_pivot_high_count := math.min(htf_pivot_high_count, 10)  // Prevent unlimited counting

// Reset counts after a while to maintain relevance
if not htf_is_pivot_low and not htf_is_pivot_high and bar_index % 100 == 0
    htf_pivot_low_count := 0
    htf_pivot_high_count := 0

// Check if this is the 2nd pivot in higher timeframe
isHTFSecondPivotLow = htf_is_pivot_low and htf_pivot_low_count == 2
isHTFSecondPivotHigh = htf_is_pivot_high and htf_pivot_high_count == 2

// Check crossing of Bollinger Bands
crossUpperBand = ta.crossover(close, upper)
crossLowerBand = ta.crossunder(close, lower)

// Entry conditions refined with higher timeframe confirmation
longCondition = close > ema and close[1] <= ema[1] and rsi > 60 and macdLine > signalLine and isNearPrevLow and rsiDivergenceBullish and (not useHTFConfirmation or isHTFSecondPivotLow)
shortCondition = close < ema and close[1] >= ema[1] and rsi < 40 and macdLine < signalLine and isNearPrevHigh and rsiDivergenceBearish and (not useHTFConfirmation or isHTFSecondPivotHigh)

// Additional entry conditions when price crosses Bollinger Bands (Rule #11)
longBBCondition = crossLowerBand and rsi < 30
shortBBCondition = crossUpperBand and rsi > 70

// Calculate position sizes for DCA
initialSize = strategy.equity * initialRiskPercent / 100 / 9  // Initial sizing according to the 1-2-6 rule
dca1Size = initialSize * 2
dca2Size = initialSize * 6

// Calculate SL in money terms (Rule #3)
slMoneyAmount = strategy.equity * initialRiskPercent / 100 * stopLossPercent / 100

// Variables to track DCA levels
var float longEntryPrice = 0.0
var float shortEntryPrice = 0.0
var int longDCACount = 0
var int shortDCACount = 0
var float stopLossLevel = 0.0
var float takeProfit1Level = 0.0
var float takeProfit2Level = 0.0
var float slMoneyValue = 0.0

// Close partial positions at take profit levels
if strategy.position_size > 0
    if close >= takeProfit1Level and takeProfit1Level > 0 and strategy.position_size == initialSize + (longDCACount > 0 ? dca1Size : 0) + (longDCACount > 1 ? dca2Size : 0)
        strategy.order("Long TP1", strategy.short, qty=strategy.position_size * 0.25)
        if showLabels
            label.new(bar_index, high, "TP1 (25%)", color=color.green, textcolor=color.white, style=label.style_label_down)
    
    if close >= takeProfit2Level and takeProfit2Level > 0 and strategy.position_size > initialSize * 0.25
        strategy.order("Long TP2", strategy.short, qty=strategy.position_size * 0.5)
        stopLossLevel := longEntryPrice  // Move SL to breakeven after TP2
        if showLabels
            label.new(bar_index, high, "TP2 (50%) & SL→BE", color=color.green, textcolor=color.white, style=label.style_label_down)

if strategy.position_size < 0
    if close <= takeProfit1Level and takeProfit1Level > 0 and math.abs(strategy.position_size) == initialSize + (shortDCACount > 0 ? dca1Size : 0) + (shortDCACount > 1 ? dca2Size : 0)
        strategy.order("Short TP1", strategy.long, qty=math.abs(strategy.position_size) * 0.25)
        if showLabels
            label.new(bar_index, low, "TP1 (25%)", color=color.red, textcolor=color.white, style=label.style_label_up)
    
    if close <= takeProfit2Level and takeProfit2Level > 0 and math.abs(strategy.position_size) > initialSize * 0.25
        strategy.order("Short TP2", strategy.long, qty=math.abs(strategy.position_size) * 0.5)
        stopLossLevel := shortEntryPrice  // Move SL to breakeven after TP2
        if showLabels
            label.new(bar_index, low, "TP2 (50%) & SL→BE", color=color.red, textcolor=color.white, style=label.style_label_up)

// DCA Logic
if enableDCA and strategy.position_size > 0 and longDCACount < 2
    if close < longEntryPrice * (1 - dcaLevel1/100) and longDCACount == 0
        strategy.entry("Long DCA1", strategy.long, qty=dca1Size)
        longDCACount := 1
        if showLabels
            label.new(bar_index, low, "DCA1", color=color.blue, textcolor=color.white, style=label.style_label_up)
    
    if close < longEntryPrice * (1 - dcaLevel2/100) and longDCACount == 1
        strategy.entry("Long DCA2", strategy.long, qty=dca2Size)
        longDCACount := 2
        // Update SL to fixed percentage after full DCA (Rule #6)
        stopLossLevel := longEntryPrice * (1 - fixedSLPercent/100)
        if showLabels
            label.new(bar_index, low, "DCA2 & SL Update", color=color.blue, textcolor=color.white, style=label.style_label_up)

if enableDCA and strategy.position_size < 0 and shortDCACount < 2
    if close > shortEntryPrice * (1 + dcaLevel1/100) and shortDCACount == 0
        strategy.entry("Short DCA1", strategy.short, qty=dca1Size)
        shortDCACount := 1
        if showLabels
            label.new(bar_index, high, "DCA1", color=color.purple, textcolor=color.white, style=label.style_label_down)
    
    if close > shortEntryPrice * (1 + dcaLevel2/100) and shortDCACount == 1
        strategy.entry("Short DCA2", strategy.short, qty=dca2Size)
        shortDCACount := 2
        // Update SL to fixed percentage after full DCA (Rule #6)
        stopLossLevel := shortEntryPrice * (1 + fixedSLPercent/100)
        if showLabels
            label.new(bar_index, high, "DCA2 & SL Update", color=color.purple, textcolor=color.white, style=label.style_label_down)

// Entry with initial position
if longCondition or longBBCondition
    strategy.close("Short")
    strategy.entry("Long", strategy.long, qty=initialSize)
    longEntryPrice := close
    longDCACount := 0
    shortDCACount := 0
    
    // Set SL based on money value (not percentage)
    slMoneyValue := slMoneyAmount
    // Convert to price level - simplified version
    stopLossLevel := close * (1 - stopLossPercent/100)
    
    takeProfit1Level := close * (1 + takeProfitPercent1/100)
    takeProfit2Level := close * (1 + takeProfitPercent2/100)
    if showLabels
        label.new(bar_index, low, "LONG", color=color.green, textcolor=color.white, style=label.style_label_up)

if shortCondition or shortBBCondition
    strategy.close("Long")
    strategy.entry("Short", strategy.short, qty=initialSize)
    shortEntryPrice := close
    longDCACount := 0
    shortDCACount := 0
    
    // Set SL based on money value (not percentage)
    slMoneyValue := slMoneyAmount
    // Convert to price level - simplified version
    stopLossLevel := close * (1 + stopLossPercent/100)
    
    takeProfit1Level := close * (1 - takeProfitPercent1/100)
    takeProfit2Level := close * (1 - takeProfitPercent2/100)
    if showLabels
        label.new(bar_index, high, "SHORT", color=color.red, textcolor=color.white, style=label.style_label_down)

// Stop Loss
if strategy.position_size > 0 and low <= stopLossLevel
    strategy.close("Long")
    if showLabels
        label.new(bar_index, low, "SL", color=color.red, textcolor=color.white, style=label.style_label_up)

if strategy.position_size < 0 and high >= stopLossLevel
    strategy.close("Short")
    if showLabels
        label.new(bar_index, high, "SL", color=color.red, textcolor=color.white, style=label.style_label_down)

// Market cap and holder % check can't be done directly in TradingView, but we display a reminder
if strategy.position_size != 0 and bar_index % 100 == 0
    label.new(bar_index, close, "Remember: Only trade coins with large market cap and >7% holder ratio", 
              color=color.yellow, textcolor=color.black, style=label.style_label_left)

// Plot indicators - these must be at the global scope in Pine Script v6
plot(ema, color=color.blue, title="48 EMA")
plot(upper, color=color.red, title="Upper BB")
plot(lower, color=color.green, title="Lower BB")
plot(middle, color=color.yellow, title="Middle BB")

// Plot stop loss and take profit levels - conditions need to be part of the plot function in v6
plotSL = showSL and stopLossLevel > 0 ? stopLossLevel : na
plot(plotSL, color=color.red, style=plot.style_circles, linewidth=2, title="Stop Loss")

// TP for long positions
plotTP1Long = showTP and strategy.position_size > 0 and takeProfit1Level > 0 ? takeProfit1Level : na
plot(plotTP1Long, color=color.green, style=plot.style_circles, linewidth=1, title="TP1 Long")

plotTP2Long = showTP and strategy.position_size > 0 and takeProfit2Level > 0 ? takeProfit2Level : na
plot(plotTP2Long, color=color.green, style=plot.style_circles, linewidth=2, title="TP2 Long")

// TP for short positions
plotTP1Short = showTP and strategy.position_size < 0 and takeProfit1Level > 0 ? takeProfit1Level : na
plot(plotTP1Short, color=color.green, style=plot.style_circles, linewidth=1, title="TP1 Short")

plotTP2Short = showTP and strategy.position_size < 0 and takeProfit2Level > 0 ? takeProfit2Level : na
plot(plotTP2Short, color=color.green, style=plot.style_circles, linewidth=2, title="TP2 Short")

// Additional table with strategy information
if barstate.islastconfirmedhistory
    var table infoTable = table.new(position=position.top_right, columns=2, rows=5, bgcolor=color.new(color.black, 70), frame_width=1)
    
    table.cell(infoTable, 0, 0, "Strategy:", bgcolor=color.new(color.blue, 90), text_color=color.white)
    table.cell(infoTable, 1, 0, "Scalping with DCA", text_color=color.white)
    
    table.cell(infoTable, 0, 1, "Initial Risk:", bgcolor=color.new(color.blue, 90), text_color=color.white)
    table.cell(infoTable, 1, 1, str.tostring(initialRiskPercent, "#.##") + "% of account", text_color=color.white)
    
    table.cell(infoTable, 0, 2, "DCA Ratio:", bgcolor=color.new(color.blue, 90), text_color=color.white)
    table.cell(infoTable, 1, 2, "1-2-6", text_color=color.white)
    
    table.cell(infoTable, 0, 3, "SL After DCA:", bgcolor=color.new(color.blue, 90), text_color=color.white)
    table.cell(infoTable, 1, 3, str.tostring(fixedSLPercent, "#.##") + "%", text_color=color.white)
    
    table.cell(infoTable, 0, 4, "REMINDERS:", bgcolor=color.new(color.red, 90), text_color=color.white)
    table.cell(infoTable, 1, 4, "Only trade coins with market cap and >7% holder ratio", text_color=color.white)