// Checkbox para backtesting, configuraciones recomendadas, trailing stop
enableChartBacktesting = input.bool(false, "Enable strategy backtesting on chart (use Recommended Strategy and please Activate Trailing Stop Control if not an expert⬇)")
activateTrailingStop = input.bool(true, "Activate Trailing Stop Control (On-chart Risk Management) __________ and please select an option from 'Indicator parameters to use'")
Assistant
User
pero mi codigo no tenia input type tampoco tenia input para length
Assistant
User
Error at 105:198 Undeclared identifier 'trailLevel100'
11:18:48
Error at 106:182 Undeclared identifier 'trailPoints100'
Assistant
User
Error at 12:145 Syntax error at input 'Indicator'
Assistant
El error de sintaxis en la línea 12:145 puede deberse a un problema con la estructura del código. Para corregirlo, revisa esa línea y las líneas cercanas para asegurarte de que no haya errores de escritura o de colocación de elementos. Aquí tienes el
trailingSettingGroup = 'Trailing Settings (only for experts)'
// Define valores específicos para BNBUSDT1H
trailLevel = 0.2/100
trailPoints = 0.6/100
src = close
per = 180
mult = 1
stopLossPercent = 0.9
inDateRange = time >= startdate and time <= enddate
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Logica de la estrategia
if longCondition and inDateRange
qty = strategy.equity/close
strategy.entry('long', strategy.long, qty=qty)
if activateTrailingStop
trailp = close * (1 + trailLevel)
trailOffset = trailPoints * close
stop_loss_price_long = (1 - stopLossPercent / 100.) * close
strategy.exit("Trail Exit long", from_entry="long", stop= stop_loss_price_long, trail_price= trailp, trail_offset= trailOffset)
if shortCondition and inDateRange
qty = strategy.equity/close
strategy.entry('short', strategy.short, qty=qty)
if activateTrailingStop
trailps = close * (1 - trailLevel)
trailOffset = trailPoints * close
stop_loss_price_short = (1 + stopLossPercent / 100.) * close
strategy.exit("Trail Exit short", from_entry="short", stop= stop_loss_price_short, trail_price= trailps, trail_offset= trailOffset)
// Mostrar valores en la esquina superior derecha si están activados
if activateTrailingStop
var label lblTrailPrice = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Trail price in %: " + str.tostring(trailLevel100))
var label lblTrail = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Trail: " + str.tostring(trailPoints100))
var label lblSamplingPeriod = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Sampling Period: " + str.tostring(per))
var label lblRangeMultiplier = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Range Multiplier: " + str.tostring(mult))
code
// Posicionando las etiquetas en la esquina superior derecha
label.set_xy(lblTrailPrice, x = bar_index, y = high + 5*(ta.atr(14)))
label.set_xy(lblTrail, x = bar_index, y = high + 4*(ta.atr(14)))
label.set_xy(lblSamplingPeriod, x = bar_index, y = high + 3*(ta.atr(14)))
label.set_xy(lblRangeMultiplier, x = bar_index, y = high + 2*(ta.atr(14)))
// Checkbox para backtesting, configuraciones recomendadas, trailing stop
enableChartBacktesting = input.bool(false, "Enable strategy backtesting on chart (use Recommended Strategy and please Activate Trailing Stop Control if not an expert⬇)")
activateTrailingStop = input.bool(true, "Activate Trailing Stop Control (On-chart Risk Management) __________ and please select an option from 'Indicator parameters to use'")
trailingSettingGroup = 'Trailing Settings (only for experts)'
// Define valores específicos para BNBUSDT1H
trailLevel = 0.2/100
trailPoints = 0.6/100
src = close
per = 180
mult = 1
stopLossPercent = 0.9
inDateRange = time >= startdate and time <= enddate
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Logica de la estrategia
if longCondition and inDateRange
qty = strategy.equity/close
strategy.entry('long', strategy.long, qty=qty)
if activateTrailingStop
trailp = close * (1 + trailLevel)
trailOffset = trailPoints * close
stop_loss_price_long = (1 - stopLossPercent / 100.) * close
strategy.exit("Trail Exit long", from_entry="long", stop= stop_loss_price_long, trail_price= trailp, trail_offset= trailOffset)
if shortCondition and inDateRange
qty = strategy.equity/close
strategy.entry('short', strategy.short, qty=qty)
if activateTrailingStop
trailps = close * (1 - trailLevel)
trailOffset = trailPoints * close
stop_loss_price_short = (1 + stopLossPercent / 100.) * close
strategy.exit("Trail Exit short", from_entry="short", stop= stop_loss_price_short, trail_price= trailps, trail_offset= trailOffset)
// Mostrar valores en la esquina superior derecha si están activados
if activateTrailingStop
var label lblTrailPrice = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Trail price in %: " + str.tostring(trailLevel100))
var label lblTrail = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Trail: " + str.tostring(trailPoints100))
var label lblSamplingPeriod = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Sampling Period: " + str.tostring(per))
var label lblRangeMultiplier = label.new(x = bar_index, y = na, style = label.style_label_left, color = #B164EC, textcolor=color.white, size = size.small, text = "Range Multiplier: " + str.tostring(mult))
code
// Posicionando las etiquetas en la esquina superior derecha
label.set_xy(lblTrailPrice, x = bar_index, y = high + 5*(ta.atr(14)))
label.set_xy(lblTrail, x = bar_index, y = high + 4*(ta.atr(14)))
label.set_xy(lblSamplingPeriod, x = bar_index, y = high + 3*(ta.atr(14)))
label.set_xy(lblRangeMultiplier, x = bar_index, y = high + 2*(ta.atr(14)))
Este código fusionado incluye las funcionalidades de ambos códigos originales. Por favor, revisa y ajusta según sea necesario.
Para corregir los errores de identificadores no declarados 'trailLevel100' y 'trailPoints100', puedes modificar las líneas correspondientes en el código fusionado. Aquí tienes el código corregido:
Con estos cambios, los errores relacionados con los identificadores 'trailLevel100' y 'trailPoints100' deberían estar resueltos. Por favor, inténtalo y avísame si necesitas más ayuda.