Convertir codigo de de pine (tradingview) a metatrader 5

MQL5 Experts

Job finished

Execution time 15 days

Specification

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)


Responded

1
Developer 1
Rating
(184)
Projects
317
24%
Arbitration
23
35% / 13%
Overdue
23
7%
Free
Published: 3 codes
2
Developer 2
Rating
(572)
Projects
664
32%
Arbitration
42
45% / 45%
Overdue
12
2%
Working
3
Developer 3
Rating
(511)
Projects
550
53%
Arbitration
13
69% / 15%
Overdue
3
1%
Working
4
Developer 4
Rating
(851)
Projects
1458
72%
Arbitration
122
29% / 48%
Overdue
356
24%
Free
Published: 3 articles
5
Developer 5
Rating
(131)
Projects
170
39%
Arbitration
10
40% / 0%
Overdue
30
18%
Loaded
6
Developer 6
Rating
(574)
Projects
945
47%
Arbitration
309
58% / 27%
Overdue
125
13%
Free

Project information

Budget
30 - 200 USD
Deadline
from 1 to 3 day(s)