//@version=4 study("Estrategia con Niveles de Cuartos") // Calcular los niveles de cuartos highYesterday = security(syminfo.tickerid, "D", high[1], lookahead=true) lowYesterday = security(syminfo.tickerid, "D", low[1], lookahead=true) closeYesterday = security(syminfo.tickerid, "D", close[1], lookahead=true) pivot = (highYesterday + lowYesterday + closeYesterday) / 3 r1 = 2 * pivot - lowYesterday s1 = 2 * pivot - highYesterday r2 = pivot + (r1 - s1) s2 = pivot - (r1 - s1) // Dibujar los niveles de cuartos en el gráfico plot(pivot, color=color.yellow, style=plot.style_line) plot(r1, color=color.green, style=plot.style_line) plot(s1, color=color.red, style=plot.style_line) plot(r2, color=color.green, style=plot.style_dotted) plot(s2, color=color.red, style=plot.style_dotted) // Señal de entrada longCondition = crossover(close, r1) shortCondition = crossunder(close, s1) // Generar señales de compra y venta plotshape(longCondition, style=shape.triangleup, color=color.green, size=size.small) plotshape(shortCondition, style=shape.triangledown, color=color.red, size=size.small)
fix invalid codeWed, 12 Apr 2023