Discussione: Supertrend segnale trading system
-
20-10-21, 10:33 #41
Salve,
può usare le funzioni MAX(@vector, @periods) e MIN(@vector, @periods) che operano su qualsiasi variabile al posto di HHV(@periods) ed LLV(@periods) che operano esclusivamente su HIGH e LOW rispettivamente.
Inoltre, siccome il numero di periodi calcolato come nel suo esempio potrebbe valere zero, questo porta a generare una condizione di errore nel calcolo di MAX/MIN/HHV/LLV.
Può aggiungere una riga del tipo:
SET hhPeriods = IF(NCandlong > 0, NCandlong, 1)
ed usare hhPeriods come numero di periodi in MAX/MIN/HHV/LLV.
Max FrancarioUltima modifica di Francario Massimiliano; 20-10-21 alle 10:51
-
20-10-21, 11:46 #42
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
-
20-10-21, 11:54 #43
-
20-10-21, 15:18 #44
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
Allora questo indicatore funziona e mostra sul grafico tutte le volte che il supertrend è andato al target prefissato, inoltre mostra anche quanto avrebbe potuto ottenere al massimo, diviso tra trend short e trend long:
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET st1 = SimpleSuperTrend(@ST1periods, @ATR1mul)
SET NCands = LASTIF( @price >= st1 )
SET NCandshort = REF(NCands,1)
SET NCandl = LASTIF( @price <= st1 )
SET NCandlong = REF(NCandl,1)
SET cambiol = CROSSOVER(@price, st1)
SET llPeriods = IF(NCandshort > 0, NCandshort, 1)
SET cambioh = CROSSUNDER(@price, st1)
SET hhPeriods = IF(NCandlong > 0, NCandlong, 1)
SET low1 = IF( cambiol , MIN(@price,llPeriods), 1 )
SET high1 = IF( cambioh , MAX(@price,hhPeriods), 1 )
SET insts = REF(@price, llPeriods)
SET revenues = IF(low1>2, 100*(insts-low1)/insts,0)
SET conds = revenues >= @percent1
SET instl = REF(@price, hhPeriods)
SET revenuel = IF(high1>2, 100*(high1-instl)/instl,0)
SET condl = revenuel >= @percent1
SET PLOT1 = condl*@percent1
SET PLOT2 = revenuel
SET PLOT3 = conds*@percent1
SET PLOT4 = revenues
però ora vorrei farne una funzione da poter utilizzare in altri script e qui ho problemi .... prossimo postIo non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!
-
20-10-21, 15:24 #45
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
funzione non funzionante!
la funzione è:
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET st1 = SimpleSuperTrend(@ST1periods, @ATR1mul)
SET NCands = LASTIF( @price >= st1 )
SET NCandshort = REF(NCands,1)
SET NCandl = LASTIF( @price <= st1 )
SET NCandlong = REF(NCandl,1)
SET cambiol = CROSSOVER(@price, st1)
SET llPeriods = IF(NCandshort > 0, NCandshort, 1)
SET cambioh = CROSSUNDER(@price, st1)
SET hhPeriods = IF(NCandlong > 0, NCandlong, 1)
SET low1 = IF( cambiol , MIN(@price,llPeriods), 1 )
SET high1 = IF( cambioh , MAX(@price,hhPeriods), 1 )
SET insts = REF(@price, llPeriods)
SET revenues = IF(low1>2, 100*(insts-low1)/insts,0)
SET conds = revenues >= @percent1
SET instl = REF(@price, hhPeriods)
SET revenuel = IF(high1>2, 100*(high1-instl)/instl,0)
SET condl = revenuel >= @percent1
SET stok = (conds OR condl)
ed è compilata però ....
.... se la volessi utilizzare ad esempio così (per avere un grafico incrementale dei supetrend andati bene):
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET a = stok(@price, @ST1periods, @ATR1mul, @percent1)
SET somma = COUNTIF(a)
PLOT1 = a
il compilatore mi da errore e mi dice che lo script ha una condizione da valutare e questo non va bene!!
Non capisco perche !Io non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!
-
20-10-21, 15:35 #46
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
solo per info ... la funzione in realtà funziona se viene utilizzata all'interno di una 'custom line' come indicatore ,
ad esempio inserendo sum(stok(close,10,3,5),250) nella Custom 1 Line si ottiene un grafico che mostra quante volte il supertrend abbia dato il 5% in circa un anno
il problema è che non è utilizzabile in uno script, cosa sbaglio?Io non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!
-
20-10-21, 16:54 #47
-
20-10-21, 17:11 #48
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
Si oddio è vero! Grazie Max e scusami!
Ecco l'ultimo pezzo:
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET a = stok(@price, @ST1periods, @ATR1mul, @percent1)
SET somma = COUNTIF(a)
set PLOT1 = somma
Ah non è l'ultimo pezzo ... ora serve una bella watchlist per arrivare al sistema completoUltima modifica di civvic; 20-10-21 alle 23:02
Io non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!
-
21-10-21, 11:17 #49
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
indicatore migliorato e corretto , ora disegna anche le volte che il st è andato male
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET st1 = SimpleSuperTrend(@ST1periods, @ATR1mul)
SET NCands = LASTIF( @price >= st1 )
SET NCandshort = REF(NCands,1)
SET NCandl = LASTIF( @price <= st1 )
SET NCandlong = REF(NCandl,1)
SET cambiol = CROSSOVER(@price, st1)
SET llPeriods = IF(NCandshort > 0, NCandshort, 1)
SET cambioh = CROSSUNDER(@price, st1)
SET hhPeriods = IF(NCandlong > 0, NCandlong, 1)
SET low1 = IF( cambiol , MIN(LOW,llPeriods), 0 )
SET high1 = IF( cambioh , MAX(HIGH,hhPeriods), 0 )
SET insts = REF(@price, llPeriods)
SET revenues = IF(low1>0, 100*(insts-low1)/insts,0)
SET conds = revenues >= @percent1
SET instl = REF(@price, hhPeriods)
SET revenuel = IF(high1>0, 100*(high1-instl)/instl,0)
SET condl = revenuel >= @percent1
SET condnost = (!conds AND !condl AND (cambioh OR cambiol))
SET stno = IF( condnost , -10, 0)
SET PLOT1 = condl*@percent1
SET PLOT2 = revenuel
SET PLOT3 = conds*@percent1
SET PLOT4 = revenues
SET PLOT5 = stno
secondo me su azionario daily ci si può tirar fuori qualcosa di decente , una watchlist potrebbe mostrare a colpo d'occhio i titoli su cui abbia funzionato meglio poi si potrebbero aggiungere altri indicatori (molto interessante la serie degli 'Escursione...' di Tiziano) per capire quale strategia in opzioni applicare per andare a mercato e in caso riparare se va male ... vabbe poi se interessa aggiorneròIo non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!
-
26-10-21, 15:21 #50
- Data Registrazione
- May 2012
- Località
- Roma
- Messaggi
- 593
ancora sulle funzioni
Scusate ho creato quest'altra funzione che mi ritorna se il supertrend non ha dato una certa percentuale del sottostante
function stnok
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET st1 = SimpleSuperTrend(@ST1periods, @ATR1mul)
SET NCands = LASTIF( @price >= st1 )
SET NCandshort = REF(NCands,1)
SET NCandl = LASTIF( @price <= st1 )
SET NCandlong = REF(NCandl,1)
SET cambiol = CROSSOVER(@price, st1)
SET llPeriods = IF(NCandshort > 0, NCandshort, 1)
SET cambioh = CROSSUNDER(@price, st1)
SET hhPeriods = IF(NCandlong > 0, NCandlong, 1)
SET low1 = IF( cambiol , MIN(LOW,llPeriods), 0 )
SET high1 = IF( cambioh , MAX(HIGH,hhPeriods), 0 )
SET insts = REF(@price, llPeriods)
SET revenues = IF(low1>0, 100*(insts-low1)/insts,0)
SET conds = revenues >= @percent1
SET instl = REF(@price, hhPeriods)
SET revenuel = IF(high1>0, 100*(high1-instl)/instl,0)
SET condl = revenuel >= @percent1
SET stnok = (!conds AND !condl AND (cambioh OR cambiol))
quando la chiamo funziona , tipo questo indicatore:
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET a = stnok(@price, @ST1periods, @ATR1mul, @percent1)
SET somma = COUNTIF(a)
set PLOT1 = somma
ma se la chiamo insieme all'altra funzione creata giorni fà (function stok , si trova in questo thread , basta risalire) da errore
INPUTS: @price(CLOSE), @ST1periods(10), @ATR1mul(3), @percent1(5)
SET a = stok(@price, @ST1periods, @ATR1mul, @percent1)
SET b = stnok(@price, @ST1periods, @ATR1mul, @percent1)
SET sommaok = COUNTIF(a)
SET sommanok = COUNTIF(b)
set PLOT1 = sommaok
set PLOT2 = sommaok + sommanok
dice: undefined value 'no_wrap_cache ...': possibile set missing or calling a function without ()
ma le parentesi mi sembra ci siano!
Forse non si possono chiamare 2 funzioni insieme?Io non vendo tasti ! - Tiziano Cagalli ...quindi se c'è un tasto (su Fiuto) vuol dire che serve !!