Convertir codigo de de pine (tradingview) a metatrader 5

MQL5 Experts

Tâche terminée

Temps d'exécution 15 jours

Spécifications

hola buenos dias necesito convertir el siguiente codigo de pine hecho para tradingview a metatrader5, vigilando que la estrategia funcione exactamente igual que en tradingview


//@version=5

strategy("Estrategia de Scalping Optimizada con Apalancamiento", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5)

 

// Configuración de indicadores

lengthRSI = input.int(14, "Longitud RSI")

upperThresholdRSI = input.int(70, "Umbral Superior RSI")

lowerThresholdRSI = input.int(30, "Umbral Inferior RSI")

rsi = ta.rsi(close, lengthRSI)

 

// Configuración de Bandas de Bollinger para confirmación

lengthBB = input.int(20, "Longitud BB")

multBB = input.float(2.0, "Multiplicador BB")

basisBB = ta.sma(close, lengthBB)

devBB = multBB * ta.stdev(close, lengthBB)

upperBB = basisBB + devBB

lowerBB = basisBB - devBB

 

// Opción para elegir operaciones en largo, corto o ambos

tradeDirection = input.string("both", "Dirección de Operación", options=["long", "short", "both"])

 

// Opción para apalancamiento

leverage = input.float(1.0, "Apalancamiento", minval=1.0, maxval=100.0, step=0.1)

 

// Señales de entrada más selectivas

longCondition = (rsi < lowerThresholdRSI) and (close < lowerBB)

shortCondition = (rsi > upperThresholdRSI) and (close > upperBB)

 

// Gestión de riesgo dinámica basada en la volatilidad

atr = ta.atr(14)

riskPerTrade = input.float(1.0, "Riesgo por Operación (%)", step=0.1)

stopLossATRMultiple = input.float(2.0, "Múltiplo de ATR para Stop Loss", step=0.5)

 

// Cálculo de tamaño de posición basado en el riesgo, ATR y apalancamiento

riskAmount = strategy.equity * riskPerTrade / 100

positionSize = (riskAmount / (atr * stopLossATRMultiple)) * leverage

 

// Ejecución de órdenes con gestión de riesgo basada en la dirección seleccionada

if (tradeDirection == "long" or tradeDirection == "both") and longCondition

    strategy.entry("Compra", strategy.long, qty=positionSize)

    strategy.exit("StopLoss/TakeProfit Compra", "Compra", stop=close - atr * stopLossATRMultiple, limit=close + atr * stopLossATRMultiple * 2)

 

if (tradeDirection == "short" or tradeDirection == "both") and shortCondition

    strategy.entry("Venta", strategy.short, qty=positionSize)

    strategy.exit("StopLoss/TakeProfit Venta", "Venta", stop=close + atr * stopLossATRMultiple, limit=close - atr * stopLossATRMultiple * 2)

 

// Visualización en gráfico

plot(upperBB, "Banda Superior BB", color=color.red)

plot(basisBB, "Banda Media BB", color=color.blue)

plot(lowerBB, "Banda Inferior BB", color=color.green)

hline(upperThresholdRSI, "Umbral Superior RSI", color=color.red)

hline(lowerThresholdRSI, "Umbral Inferior RSI", color=color.green)


Répondu

1
Développeur 1
Évaluation
(154)
Projets
258
24%
Arbitrage
12
25% / 8%
En retard
15
6%
Travail
2
Développeur 2
Évaluation
(430)
Projets
488
33%
Arbitrage
25
40% / 44%
En retard
7
1%
Chargé
3
Développeur 3
Évaluation
(467)
Projets
496
53%
Arbitrage
10
60% / 20%
En retard
3
1%
Travail
4
Développeur 4
Évaluation
(791)
Projets
1360
72%
Arbitrage
112
29% / 48%
En retard
340
25%
Travail
5
Développeur 5
Évaluation
(120)
Projets
156
37%
Arbitrage
7
57% / 0%
En retard
27
17%
Gratuit
6
Développeur 6
Évaluation
(559)
Projets
927
48%
Arbitrage
301
59% / 25%
En retard
124
13%
Chargé

Informations sur le projet

Budget
30 - 200 USD
TVA (21%): 6.3 - 42 USD
Total: 36.3 - 242 USD
Pour le développeur
27 - 180 USD
Délais
de 1 à 3 jour(s)