Estrategia de cazador de fin de semana

ATR MACD RSI CVD BOLLINGER
Fecha de creación: 2025-09-24 18:12:29 Última modificación: 2025-09-24 18:12:29
Copiar: 4 Número de Visitas: 159
2
Seguir
319
Seguidores

Estrategia de cazador de fin de semana Estrategia de cazador de fin de semana

El centro de la estrategia de Liu: dinero inteligente para el mercado de fin de semana

¿Sabías que el mercado de criptomonedas esconde su porche cuando los grandes de Wall Street están de vacaciones los fines de semana? Esta estrategia es como un guardia de noche que se filtra cuando los inversores institucionales están “fuera de trabajo”.

¡Acentrarse en las cosas!Esta estrategia solo se utiliza en los sábados, y en especial en los domingos entre las 0 y las 8 UTC. ¿Por qué? Porque en esos días la fluidez es relativamente baja y la eficacia del análisis técnico es más alta, como en una biblioteca tranquila donde es más fácil escuchar los sonidos más pequeños.

La convergencia de múltiples indicadores: no luchar solo

La estrategia es como montar una alianza de vengadores:

  • RSI (de 8 ciclos)El precio de venta de las acciones en la Bolsa de Nueva York es de US$1 por dólar.
  • MACD(8,17,9)Confirmación de la dinámica de la tendencia
  • El cinturón de BrinIdentificar las zonas de precios extremos
  • CVD se alejaEl dinero inteligente: Descubrir sus verdaderas intenciones

Guía para evitar las fosas¡Una prueba de un solo indicador es como ver una película en solitario, fácilmente engañada por la trama! ¡Una prueba de varios indicadores es como ver una película con amigos y escuchar diferentes puntos de vista!

Gestión inteligente de dinero: 500 dólares para jugar

El sistema está diseñado para el pequeño capital:

  • El precio mínimo es de 120 dólares.No te dejaré ni un haha.
  • Hasta 4 posiciones simultáneasLa gente no pone sus huevos en una canasta, sino que los dispersa.
  • 5-20 veces el apalancamiento dinámicoEl precio de las acciones se ajusta automáticamente a la volatilidad del mercado.

Al igual que con la conducción, se puede ir rápido en las carreteras, pero se puede ir más despacio en las carreteras. El sistema ajusta el tamaño de la posición en función de las características de riesgo de las diferentes monedas.

️ Control de riesgos: más preocupado que tu madre

Mecanismo de triple protección

  1. El límite de pérdidas diarias es del 5%.¿Ha perdido mucho hoy?
  2. El límite de pérdidas de fin de semana es del 15%.El fin de semana también tiene su límite.
  3. Se suspendieron cuatro pérdidas consecutivasPrevenir el comercio emocional

Sistema de frenado de emergenciaSi la pérdida de la cuenta supera el 30%, se detienen todas las transacciones inmediatamente. ¡Es como el sistema ABS de un auto, que puede salvar vidas en un momento crucial!

Código Fuente de la Estrategia
/*backtest
start: 2024-09-24 00:00:00
end: 2025-09-22 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/

//@version=6
strategy("Weekend Hunter Ultimate v6.2 [PRODUCTION READY]", 
         overlay=true, 
         pyramiding=0,
         calc_bars_count=5000,
         default_qty_type=strategy.percent_of_equity, 
         default_qty_value=10,
         commission_type=strategy.commission.percent,
         commission_value=0.075,
         slippage=3,
         initial_capital=500)

// ========================================
// WEEKEND-ONLY CONFIGURATION
// ========================================

enable_weekend_only = input.bool(true, "WEEKEND TRADING ONLY", tooltip="Saturday-Sunday when institutions are offline")
weekend_start_day = input.string("Saturday", "Weekend Start", options=["Friday", "Saturday"])
weekend_end_day = input.string("Sunday", "Weekend End", options=["Sunday", "Monday"])

// Optimal Weekend Windows (Research-Based)
optimal_saturday_start = input.int(0, "Saturday Start Hour (UTC)", minval=0, maxval=23)
optimal_sunday_end = input.int(23, "Sunday End Hour (UTC)", minval=0, maxval=23)
prime_sunday_window = input.bool(true, "Enable Prime Sunday Window (0-8 UTC)")

// Weekend Detection Logic
is_saturday = dayofweek == dayofweek.saturday
is_sunday = dayofweek == dayofweek.sunday
is_weekend = is_saturday or is_sunday
current_hour = hour(time)

// Prime Weekend Window
in_prime_window = is_sunday and current_hour >= 0 and current_hour <= 8
in_weekend_hours = (is_saturday and current_hour >= optimal_saturday_start) or 
                  (is_sunday and current_hour <= optimal_sunday_end)

weekend_trading_active = enable_weekend_only ? (is_weekend and in_weekend_hours) : true

// ========================================
// POSITION & CAPITAL MANAGEMENT
// ========================================

var float daily_pnl = 0.0
var float weekend_pnl = 0.0
var int last_day = 0
var int consecutive_losses = 0

// Maximum concurrent positions with $500
max_concurrent_positions = 4
current_positions = strategy.opentrades

// Smart Capital Management
available_capital = strategy.equity - (strategy.position_size * close)
min_capital_per_trade = 120.0
safety_buffer = 50.0
can_afford_position = available_capital > (min_capital_per_trade + safety_buffer)
position_available = current_positions < max_concurrent_positions

// ========================================
// AGGRESSIVE 65% WIN RATE CONFIGURATION
// ========================================

historical_win_rate = input.float(65.0, "Target Win Rate %", minval=60.0, maxval=70.0) / 100
avg_win_percent = input.float(5.5, "Average Win %", minval=4.0, maxval=7.0) / 100
avg_loss_percent = input.float(1.8, "Average Loss %", minval=1.5, maxval=2.5) / 100

// Loss Limits
max_daily_loss = input.float(5.0, "Max Daily Loss %", minval=3.0, maxval=8.0)
max_weekend_loss = input.float(15.0, "Max Weekend Loss %", minval=10.0, maxval=20.0)
max_consecutive_losses_allowed = 4

// ========================================
// DYNAMIC LEVERAGE SYSTEM 5-20x
// ========================================

min_leverage = input.float(5.0, "Minimum Leverage", minval=5.0, maxval=10.0)
max_leverage = input.float(20.0, "Maximum Leverage", minval=15.0, maxval=25.0)

// EXACT COIN-SPECIFIC RISK PROFILES
symbol_risk_profile = syminfo.ticker == "BTCUSDT" ? 0.9 : 
                      syminfo.ticker == "ETHUSDT" ? 0.85 : 
                      syminfo.ticker == "LINKUSDT" ? 0.75 :
                      syminfo.ticker == "XRPUSDT" ? 0.75 :
                      syminfo.ticker == "DOGEUSDT" ? 0.6 :
                      syminfo.ticker == "SOLUSDT" ? 0.7 :
                      syminfo.ticker == "AVAXUSDT" ? 0.7 :
                      syminfo.ticker == "1000PEPEUSDT" ? 0.5 :
                      syminfo.ticker == "TONUSDT" ? 0.65 :
                      syminfo.ticker == "POLUSDT" ? 0.7 : 0.5

// ========================================
// PROFIT PROTECTION SYSTEM
// ========================================

use_trailing = input.bool(true, "Enable Smart Trailing", tooltip="Protects profits when approaching target")
trailing_activation_percent = input.float(2.5, "Trailing Activation %", minval=2.0, maxval=3.5)
trailing_distance_percent = input.float(1.5, "Trail Distance %", minval=1.0, maxval=2.0)

// ========================================
// MULTI-TIMEFRAME CONFLUENCE
// ========================================

// 4H Trend Bias
htf_4h_close = request.security(syminfo.tickerid, "240", close, lookahead=barmerge.lookahead_off)
htf_4h_ema50 = request.security(syminfo.tickerid, "240", ta.ema(close, 50), lookahead=barmerge.lookahead_off)

// 1H Momentum Confirmation - Fixed MACD
[htf_1h_macd, htf_1h_signal, htf_1h_hist] = request.security(syminfo.tickerid, "60", ta.macd(close, 12, 26, 9), lookahead=barmerge.lookahead_off)
htf_1h_rsi = request.security(syminfo.tickerid, "60", ta.rsi(close, 14), lookahead=barmerge.lookahead_off)

// Trend Alignment Scoring
htf_4h_trend = htf_4h_close > htf_4h_ema50 ? 1 : -1
htf_1h_momentum = htf_1h_macd > htf_1h_signal ? 1 : -1
current_trend = close > ta.ema(close, 20) ? 1 : -1

trend_alignment = (htf_4h_trend + htf_1h_momentum + current_trend) / 3.0

// ========================================
// VOLATILITY & MARKET REGIME
// ========================================

atr_period = 14
atr_value = ta.atr(atr_period)
atr_percentage = (atr_value / close) * 100

volatility_regime = atr_percentage < 2.0 ? "Low" : atr_percentage < 5.0 ? "Medium" : "High"

// Weekend Liquidity Adjustment
volume_sma = ta.sma(volume, 20)
current_liquidity_ratio = volume / volume_sma
weekend_liquidity_adjustment = is_weekend ? math.min(current_liquidity_ratio * 0.8, 1.0) : 1.0

// ========================================
// CVD DIVERGENCE DETECTION
// ========================================

var float cvd = 0.0
bull_volume = close > open ? volume : 0
bear_volume = close < open ? volume : 0
volume_delta = bull_volume - bear_volume
cvd := cvd + volume_delta

// Divergence Detection
price_higher = close > close[10]
cvd_lower = cvd < cvd[10]
bearish_divergence = price_higher and cvd_lower

price_lower = close < close[10]
cvd_higher = cvd > cvd[10]
bullish_divergence = price_lower and cvd_higher

// ========================================
// SIGNAL GENERATION SYSTEM
// ========================================

// Primary Indicators
rsi = ta.rsi(close, 8)

// Fixed MACD unpacking
[macd_line, signal_line, histogram] = ta.macd(close, 8, 17, 9)

// Fixed Bollinger Bands unpacking
[bb_upper, bb_middle, bb_lower] = ta.bb(close, 20, 2.5)

// Volume Confirmation
volume_surge = volume > (volume_sma * 1.5)
min_volume_threshold = ta.sma(volume, 100) * 0.1
valid_volume = volume > min_volume_threshold
volume_confirmation = volume_surge and current_liquidity_ratio > 0.7 and valid_volume

// Signal Strength Calculation
var float signal_strength = 0.0

// Trend Component (40% weight)
trend_score = trend_alignment * 40

// Momentum Component (30% weight)
momentum_bullish = rsi < 30 and rsi > rsi[1]
momentum_bearish = rsi > 70 and rsi < rsi[1]
momentum_score = momentum_bullish ? 30 : momentum_bearish ? -30 : 0

// Volume Component (20% weight)
volume_score = volume_confirmation ? 20 : 0
volume_score := volume_score + (bullish_divergence ? 10 : bearish_divergence ? -10 : 0)

// Weekend Component (10% weight) - Fixed type
weekend_score = is_weekend ? 10.0 : 0.0
if in_prime_window
    weekend_score := weekend_score * 1.5

signal_strength := trend_score + momentum_score + volume_score + weekend_score

// Weekend Signal Boost
if is_weekend
    signal_strength := signal_strength * 1.2
if in_prime_window
    signal_strength := signal_strength * 1.3

// ========================================
// DYNAMIC LEVERAGE CALCULATION
// ========================================

// Safety Score Components
volatility_safety = volatility_regime == "Low" ? 1.0 : volatility_regime == "Medium" ? 0.7 : 0.4
signal_confidence = math.abs(signal_strength) / 100
overall_safety = (volatility_safety + signal_confidence) / 2 * symbol_risk_profile

// Calculate Dynamic Leverage
leverage_range = max_leverage - min_leverage
dynamic_leverage = min_leverage + (leverage_range * overall_safety)
final_leverage = math.round(math.max(min_leverage, math.min(max_leverage, dynamic_leverage)), 1)

// ========================================
// POSITION SIZING WITH CAPITAL CHECK
// ========================================

// Signal Thresholds
min_signal_strength = input.float(55.0, "Minimum Signal Strength", minval=45.0, maxval=65.0)
high_confidence_threshold = input.float(75.0, "High Confidence Threshold", minval=70.0, maxval=85.0)

high_confidence = math.abs(signal_strength) > high_confidence_threshold
position_multiplier = high_confidence ? 1.3 : 1.0

// Calculate Position Size
base_position_usd = 120.0
desired_position_usd = base_position_usd * position_multiplier

// Pair-specific adjustment
pair_multiplier = syminfo.ticker == "1000PEPEUSDT" ? 0.5 : syminfo.ticker == "BTCUSDT" ? 1.0 : syminfo.ticker == "ETHUSDT" ? 1.0 : 0.8

final_position_usd = desired_position_usd * pair_multiplier
contracts = can_afford_position ? final_position_usd / close : 0

// ========================================
// ENTRY CONDITIONS WITH ALL SAFETY CHECKS
// ========================================

// Signal Conditions
strong_bullish_signal = signal_strength > min_signal_strength and trend_alignment > 0
strong_bearish_signal = signal_strength < -min_signal_strength and trend_alignment < 0

// Flash Crash Protection (8%)
flash_crash_detected = math.abs((close - close[4]) / close[4]) > 0.08

// Loss Tracking
if dayofmonth != last_day
    daily_pnl := 0.0
    if dayofweek == dayofweek.monday
        weekend_pnl := 0.0
    last_day := dayofmonth

daily_loss_pct = (daily_pnl / strategy.equity) * 100
weekend_loss_pct = (weekend_pnl / strategy.equity) * 100
loss_limits_active = daily_loss_pct <= -max_daily_loss or weekend_loss_pct <= -max_weekend_loss or consecutive_losses >= max_consecutive_losses_allowed

// Emergency Stop at -30% Account Level
account_emergency_stop = strategy.equity < (strategy.initial_capital * 0.7)

// Final Entry Conditions (fixed line continuation)
can_enter_long = strong_bullish_signal and weekend_trading_active and not loss_limits_active and position_available and can_afford_position and strategy.position_size == 0 and not flash_crash_detected and not account_emergency_stop

can_enter_short = strong_bearish_signal and weekend_trading_active and not loss_limits_active and position_available and can_afford_position and strategy.position_size == 0 and not flash_crash_detected and not account_emergency_stop

// ========================================
// DYNAMIC STOP LOSS & TAKE PROFIT
// ========================================

// ATR-Based with Leverage Adjustment  
base_atr_mult_sl = input.float(1.5, "Base ATR Multiplier SL", minval=1.0, maxval=2.0)
base_atr_mult_tp = input.float(4.5, "Base ATR Multiplier TP", minval=3.5, maxval=6.0)

leverage_adjustment = 1.0 + (final_leverage - 5) / 50
atr_mult_sl = base_atr_mult_sl / leverage_adjustment
atr_mult_tp = base_atr_mult_tp * (1.0 + signal_confidence * 0.2)

stop_distance = atr_value * atr_mult_sl
tp_distance = atr_value * atr_mult_tp

long_stop = close - stop_distance
long_tp = close + tp_distance
short_stop = close + stop_distance
short_tp = close - tp_distance

// ========================================
// STRATEGY EXECUTION WITH ALERTS
// ========================================

// Long Entry with alert
if can_enter_long
    alert_message = '{"action":"open_long","ticker":"' + syminfo.ticker + '","price":"' + str.tostring(close) + '","leverage":"' + str.tostring(final_leverage) + '","stop_loss":"' + str.tostring(long_stop) + '","take_profit":"' + str.tostring(long_tp) + '"}'
    strategy.entry("Long", strategy.long, qty=contracts, comment="L " + str.tostring(final_leverage, "#.#") + "x S:" + str.tostring(signal_strength, "#"))
    alert(alert_message, alert.freq_once_per_bar)
    
    if use_trailing
        strategy.exit("Long Exit", "Long", stop=long_stop, limit=long_tp, trail_points=close * trailing_activation_percent / 100, trail_offset=close * trailing_distance_percent / 100)
    else
        strategy.exit("Long Exit", "Long", stop=long_stop, limit=long_tp)

// Short Entry with alert
if can_enter_short  
    alert_message = '{"action":"open_short","ticker":"' + syminfo.ticker + '","price":"' + str.tostring(close) + '","leverage":"' + str.tostring(final_leverage) + '","stop_loss":"' + str.tostring(short_stop) + '","take_profit":"' + str.tostring(short_tp) + '"}'
    strategy.entry("Short", strategy.short, qty=contracts, comment="S " + str.tostring(final_leverage, "#.#") + "x S:" + str.tostring(signal_strength, "#"))
    alert(alert_message, alert.freq_once_per_bar)
    
    if use_trailing
        strategy.exit("Short Exit", "Short", stop=short_stop, limit=short_tp, trail_points=close * trailing_activation_percent / 100, trail_offset=close * trailing_distance_percent / 100)
    else
        strategy.exit("Short Exit", "Short", stop=short_stop, limit=short_tp)

// Emergency Exits with alert
if strategy.position_size != 0
    entry_price = strategy.position_avg_price
    current_profit_pct = strategy.position_size > 0 ? ((close - entry_price) / entry_price * 100) : ((entry_price - close) / entry_price * 100)
    
    // Liquidation Protection
    liq_distance = 100 / final_leverage * 0.8
    approaching_liquidation = math.abs(current_profit_pct) > liq_distance
    
    if approaching_liquidation or flash_crash_detected or account_emergency_stop
        alert('{"action":"close_all","ticker":"' + syminfo.ticker + '"}', alert.freq_once_per_bar)
        strategy.close_all(comment="EMERGENCY")

// Weekend End Exit
if dayofweek == dayofweek.monday and hour == 0 and strategy.position_size != 0
    alert('{"action":"close_all","ticker":"' + syminfo.ticker + '"}', alert.freq_once_per_bar)
    strategy.close_all(comment="Weekend End")


// Weekend Background
bgcolor(is_weekend ? color.new(color.blue, 95) : na, title="Weekend")
bgcolor(in_prime_window ? color.new(color.purple, 90) : na, title="Prime")

// Signal Strength
plot(signal_strength, "Signal", signal_strength > 0 ? color.lime : color.red, 2)
hline(min_signal_strength, "Min Signal", color.green, hline.style_dashed)
hline(-min_signal_strength, "Min Signal", color.red, hline.style_dashed)

// Entry Signals
plotshape(can_enter_long, "Long", shape.triangleup, location.belowbar, high_confidence ? color.lime : color.green, size=size.small)
plotshape(can_enter_short, "Short", shape.triangledown, location.abovebar, high_confidence ? color.red : color.maroon, size=size.small)

// Warnings
bgcolor(loss_limits_active ? color.new(color.red, 80) : na, title="Loss Limit")
bgcolor(account_emergency_stop ? color.new(color.purple, 80) : na, title="Emergency")