
Đây là một chiến lược giao dịch năng lượng thông minh dựa trên TRAMA ((Triangular Moving Average) và đường trung bình di chuyển đơn giản ((SMA)). Chiến lược kết hợp hai hệ thống đồng tuyến để tạo tín hiệu giao dịch và thiết lập cơ chế dừng lỗ để kiểm soát rủi ro. Chiến lược sử dụng giao dịch 4 chu kỳ và 28 chu kỳ giao dịch SMA và chỉ số TRAMA để xác nhận tín hiệu giao dịch, tăng độ chính xác của giao dịch thông qua nhiều tín hiệu xác nhận.
Chiến lược sử dụng hai thành phần cốt lõi để tạo ra tín hiệu giao dịch. Đầu tiên là hệ thống chéo dựa trên 4 chu kỳ và 28 chu kỳ SMA, tạo ra nhiều tín hiệu khi đường trung bình ngắn hạn vượt lên đường trung bình dài hạn và tạo ra tín hiệu trống khi đi xuống. Tiếp theo, chiến lược giới thiệu chỉ số TRAMA như một hệ thống xác nhận hỗ trợ.
Đây là một chiến lược kết hợp phân tích kỹ thuật truyền thống và tư tưởng giao dịch định lượng hiện đại. Chiến lược này cho thấy tính thực tế tốt hơn bằng cách xác nhận nhiều tín hiệu và kiểm soát rủi ro nghiêm ngặt. Mặc dù có một số nơi cần được tối ưu hóa, nhưng thiết kế khung tổng thể hợp lý và có triển vọng ứng dụng tốt.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
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/
// © ivanvallejoc
//@version=5
strategy("MANCOS2.0", overlay=true, margin_long=80, margin_short=80)
longCondition = ta.crossover(ta.sma(close, 4), ta.sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 4), ta.sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
// Parámetros de la TRAMA
length = input(1.5, title="TRAMA Length")
src = close
filt = 2 / (length + 1)
trama = 0.0
var tramaPrev = na(trama[1]) ? close : trama[1]
trama := (src - tramaPrev) * filt + tramaPrev
// Plot de la TRAMA
plot(trama, color=color.blue, linewidth=2, title="TRAMA")
// Señales de compra y venta basadas en TRAMA
buySignal = ta.crossover(close, trama)
sellSignal = ta.crossunder(close, trama)
// Configuración de Take Profit y Stop Loss
takeProfitPerc = input(2, title="Take Profit (%)") / 100
stopLossPerc = input(1, title="Stop Loss (%)") / 100
// Precios de TP y SL
takeProfitPrice = strategy.position_avg_price * (1 + takeProfitPerc)
stopLossPrice = strategy.position_avg_price * (1 - stopLossPerc)
// Condiciones de entrada en largo
if (buySignal)
strategy.entry("Long", strategy.long)
// Condiciones de salida para posición larga (TP/SL)
if (strategy.position_size > 0)
strategy.exit("TP/SL", "Long", limit=takeProfitPrice, stop=stopLossPrice)
// Entrada en corto basada en TRAMA
if (sellSignal)
strategy.entry("Short", strategy.short)
// Precios de TP y SL para posiciones cortas
takeProfitPriceShort = strategy.position_avg_price * (1 - takeProfitPerc)
stopLossPriceShort = strategy.position_avg_price * (1 + stopLossPerc)
if (strategy.position_size < 0)
strategy.exit("TP/SL", "Short", limit=takeProfitPriceShort, stop=stopLossPriceShort)