Salve a tutti,
sto cercando di modificare il mio indicatore di pivot flessibile.
Quello che voglio ottenere è che il periodo di barre a sinistra del pivot diventi variabile in base alla volatilità,
prendendo spunto dal codice di Thalos.

Lo script editor continua a darmi il seguente messaggio d'errore:
Error: Riferimento a un oggetto non impostato su un'istanza di oggetto
e non riesco a capire quale sia l'errore ???
Qualsiasi suggerimento sarebbe molto gradito.
Saluti
Massimo

Il codice e il seguente :



#
# Indicatore Pivot + Volatilità
#
INPUTS: @vPrice(LOW), @vRight(5), @vDir(0)
INPUTS: @MaxLB(60), @MinLB(5)

SET HistVol=SDV(CLOSE, 30, 1, SIMPLE)+0.000001
SET YestHistVol = REF(HistVol, 1)
SET DeltaHistVol = (HistVol - REF(HistVol, 1))/HistVol
SET EntryLB = BARLOOP (20 , 1, MULTIPLY , (1 + DeltaHistVol) ,@MinLB , @MaxLB )
SET vLeft = FLOOR(EntryLB)
SET A = PIVOT_FLESSIBILE (@vPrice , vLeft , @vRight , @vDir)
SET PLOT1 = A



con la funzione PIVOT_FLESSIBILE così codificata:




# PIVOT FLESSIBILE
#
# Ritorna il pivot del vettore vPrice
# minore o maggiore delle vLeft e vRight barre
# in direzione high o low (vDir 0 o 1)
#
Inputs: @vPrice(LOW), @vLeft(10), @vRight(5), @vDir(0)
# Condizione per individuare il pivot point Low
# Il vPrice del pivot deve essere <= ai vPrice delle vLeft barre a sinistra
# e minore del vPrice delle vRight barre a destra
SET Condition1 = (@vDir = 0) AND (REF(@vPrice, @vRight) <= REF(MIN(@vPrice, @vLeft), @vRight + 1) AND REF(@vPrice, @vRight) < MIN(@vPrice, @vRight))
# Condizione per individuare il pivot point High
# L' vPrice del pivot deve essere >= all'vPrice delle vLeft barre a sinistra
# e maggiore degli vPrice delle vRight barre a destra
SET Condition2 = (@vDir = 1) AND (REF(@vPrice, @vRight) >= REF(MAX(@vPrice, @vLeft), @vRight + 1) AND REF(@vPrice, @vRight) > MAX(@vPrice, @vRight))
SET Condition = Condition1 OR Condition2
SET PIVOT_FLESSIBILE = CHANGEIF(Condition, REF(@vPrice, @vRight))