He preparado cuatro indicadores propios modificando un código que he visto por aquí y consigo que uno funcione bien pero los demás me dan como resultado 0 y no entiendo dónde está el error. La diferencia entre el 1º (el que funciona) y los demás es que he sustituido highest[10](close) por : highest[10](volume), highestPrice = highest[10](range), highestPrice = highest[10](range) y highestPrice = highest[10](ROC[1](close))
¿Alguien me puede ayudar?
Muchas gracias.
//1ºFUNCIONA
highestPrice = highest[10](close)
highBar = 0
for i = 1 to 10
if close[i] = highestPrice then
highBar = i
endif
next
PriceRange = range[highBar]
return highBar as "highbar10C"
// 2º INDICADOR NO FUNCIONA
highestPrice = highest[10](volume)
highBar = 0
for i = 1 to 10
if close[i] = highestPrice then
highBar = i
endif
next
PriceRange = range[highBar]
return highBar as "highbar10volume"
// 3º INDICADOR NO FUNCIONA
highestPrice = highest[10](range)
highBar = 0
for i = 1 to 10
if close[i] = highestPrice then
highBar = i
endif
next
PriceRange = range[highBar]
return highBar as "highbar10RANGE"
// 4º INDICADOR NO FUNCIONA
highestPrice = highest[10](ROC[1](close))
highBar = 0
for i = 1 to 10
if close[i] = highestPrice then
highBar = i
endif
next
return highBar as "highba10ROC1"
Porque en la línea 5, con IF, debe utilizar el mismo tipo de datos que se utilizó en la línea 2 con HIGHEST.
CLOSE con CLOSE, VOLUME con VOLUME, RANGE con RANGE y ROC [1] (close) con ROC [1] (close).
Muchas gracias, funciona perfectamente.