TS beta - medio/lungo periodo | Azionario - di ale73a (2 lettori)

ale73a

break even trader
Per valutare meglio l'andamento di un trading system cerco sempre di trasformarlo in un indicatore a 3 valori:
1 stai long
0 attendi
-1 stai short

Questo permette semplicemente di confrontarlo con altri indicatori derivati e/o ottimizzati.
In realtà l'indicatore di ale73a non assume mai valore 0 - attendi, ma è sempre o +1, oppure -1. Appena ho un attimo cerco di farne una versione che comprenda anche periodi con valore 0, possibilmente quando il titolo è in trading range.


Ecco il codice:
st=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM20 = EXPONENTIALAVERAGE[20](CLOSE)
MM5 = EXPONENTIALAVERAGE[5](CLOSE)
c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)


if ST < c and MM5 > MM20 and c > MM150 and c < piuAlto[1] then
risposta=1
endif


if ST > c and MM5 < MM20 and c < MM150 and c > piuBasso[1] THEN
risposta=-1
endif

return risposta

grazie, difatti è troppo "aggressivo" come ts, e a tutt'oggi l'unico filtro di trading range che mi è venuto in mente è quello in grassetto
 

f4f

翠鸟科
:help::help::help::help:


st=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM20 = EXPONENTIALAVERAGE[20](CLOSE)
MM5 = EXPONENTIALAVERAGE[5](CLOSE)
c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)


if ST < c and MM5 > MM20 and c > MM150 and c < piuAlto[1] then
risposta=1
endif


if ST > c and MM5 < MM20 and c < MM150 and c > piuBasso[1] THEN
risposta=-1
endif

return risposta





non riesco a trovare / capire la function ''supertrend'' :wall::wall::wall::wall:
grazie
:)
 
Ultima modifica:

ale73a

break even trader
:help::help::help::help:


st=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM20 = EXPONENTIALAVERAGE[20](CLOSE)
MM5 = EXPONENTIALAVERAGE[5](CLOSE)
c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)


if ST < c and MM5 > MM20 and c > MM150 and c < piuAlto[1] then
risposta=1
endif


if ST > c and MM5 < MM20 and c < MM150 and c > piuBasso[1] THEN
risposta=-1
endif

return risposta





non riesco a trovare / capire la function ''supertrend'' :wall::wall::wall::wall:
grazie
:)

ciao, questo è su prorealtime...supertrend è un indicatore con un calcolo complesso che prorealtime ti mette già funzionante
su visual trader la traduzione è questa che ti posto
 

ale73a

break even trader
Codice:
var: ema5, ema20, ema150, l5, h5;
Var: Stop1, Stop2, StopLong, StopShort, PREV, Chandelier(0),OscAtr3, OscAtr25;
Var: contahl,prox0,indzona1,pp,llow,hhigh,aa, bb,expoa,expob,dd,indzona2;
ema5=mov(c,5,e);
ema20=mov(c,20,e);
ema150=mov(c,150,e);
h5=h[5];
l5=l[5];
OscAtr3 = ATR(C, 10) * 3;
OscAtr25 = ATR(C, 10) *2.5;

PREV = Chandelier[1];

if PREV < L THEN
if (H - OscAtr3) >= PREV then
Stop1 = H - OscAtr3;
else
Stop1 = PREV;
endif;
else
Stop1 = H - OscAtr3;
endif;

if PREV < l then
if (C - OscAtr25) >= PREV then
Stop2 = C - OscAtr25;
else
Stop2 = prev;
endif;
else
Stop2 = C - OscAtr25;
endif;


If Stop1 > Stop2 then
StopLong = Stop1;
else
StopLong = Stop2;
endif;


if PREV > H then
if (L + OscAtr3) <= PREV then
Stop1 = L + OscAtr3;
else
Stop1 = PREV;
endif;
else
Stop1 = L + OscAtr3;
endif;


if (PREV > H) then
if (C + OscAtr25) <= PREV then
Stop2 = C + OscAtr25;
else
Stop2 = PREV;
endif;
else
Stop2 = C + OscAtr25;
endif;


If Stop1 < Stop2 then
StopShort = Stop1;
else
StopShort = Stop2;
endif;


if BarSince(L > StopLong[1]) > BarSince(H < StopShort[1]) then
Chandelier = StopLong;
else
Chandelier = StopShort;
endif;

///////////////////////////////////// DD /////////////////////////////////////////
pp=14;

llow=LLV(L,pp);

hhigh=HHV(H,pp);

aa=((3*close - 2*llow -open[1] ) / close)*100;

bb=((open[1] + 2*hhigh - 3*close)/close)*100;

expoa=(aa-expoa[1])*(2/(5*pp+1))+expoa[1];

expob=(bb-expob[1])*(2/(5*pp+1))+expob[1];

dd=expoa-expob;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if h>h[1] then contahl=(contahl+1);endif;
if l<l[1] then contahl=(contahl-1);endif;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if isfirstbarday then contahl = 0;endif;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
prox0=0.0000000001;
PlotChart(Chandelier, 0, yellow, solid, 2);

Indzona1=CreateViewport(300,0,true);
PlotChart(contahl,INDZONA1,black,solid,2 );
PlotChart(prox0,INDZONA1,black,dot,2);

indzona2=CreateViewport(200, 0, true);
Plotchart(dd,indzona2, blue, istogramma, 2);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if c > chandelier and c > ema150 and ema5 > ema20 and c < h5 then enterlong(nextbar,atopen);
endif;
if c < chandelier and c < ema150 and ema5 < ema20 and c > l5 then entershort(nextbar,atopen);
endif;
 
filtro basato su supertrend

Questo algoritmo assume anche il valore 0, quando non fa niente. Rispetto a quello originale rimane molto meno sul mercato, ha una percentuale di guadagno mediamente superiore, anche se in totale, per un titolo guadagna meno. Questo è dovuto alla minore esposizione al mercato.
Ho cambiato le condizioni sulle media, queste mi sembrano migliori.

Ecco il codice:

st=Supertrend[2.5,10]
st1=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM40 = AVERAGE[40](HIGH)
MM401 = AVERAGE[40](LOW)

c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)

cond1= st < c and CLOSE > MM40 and c > MM150 and c < piuAlto[1] and MM40 > MM401
cond2= st1 crosses over c and risposta=1

if cond1 then
risposta=1
endif

if cond2 then
risposta=0
endif

cond3= st > c and CLOSE < MM401 and c < MM150 and c > piuBasso[1] and MM40 < MM401
cond4= st1 crosses under c and risposta=-1

if cond3 THEN
risposta=-1
endif

If cond4 THEN
risposta=0
endif

return risposta
 

ale73a

break even trader
Questo algoritmo assume anche il valore 0, quando non fa niente. Rispetto a quello originale rimane molto meno sul mercato, ha una percentuale di guadagno mediamente superiore, anche se in totale, per un titolo guadagna meno. Questo è dovuto alla minore esposizione al mercato.
Ho cambiato le condizioni sulle media, queste mi sembrano migliori.

Ecco il codice:

st=Supertrend[2.5,10]
st1=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM40 = AVERAGE[40](HIGH)
MM401 = AVERAGE[40](LOW)

c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)

cond1= st < c and CLOSE > MM40 and c > MM150 and c < piuAlto[1] and MM40 > MM401
cond2= st1 crosses over c and risposta=1

if cond1 then
risposta=1
endif

if cond2 then
risposta=0
endif

cond3= st > c and CLOSE < MM401 and c < MM150 and c > piuBasso[1] and MM40 < MM401
cond4= st1 crosses under c and risposta=-1

if cond3 THEN
risposta=-1
endif

If cond4 THEN
risposta=0
endif

return risposta

ciao e grazie:), correggimi xchè forse sbaglio qualcosa, dato che tranne -logicamente - il minore dd, c'è qualcosa che non va... questo è il codice che ho provato su diversi titoli
Codice:
st=Supertrend[2.5,10]
st1=Supertrend[3,10]
MM150 = EXPONENTIALAVERAGE[150](CLOSE)
MM40 = AVERAGE[40](HIGH)
MM401 = AVERAGE[40](LOW)

c=close
piuBasso = LOWEST[5](LOW)
piuAlto = HIGHEST[5](HIGH)

cond1= st < c and CLOSE > MM40 and c > MM150 and c < piuAlto[1] and MM40 > MM401
cond2= st1 crosses over c 

if cond1 then
buy 100 %capital at market
endif

if longonmarket and cond2 then
sell 100 %capital at market
endif

cond3= st > c and CLOSE < MM401 and c < MM150 and c > piuBasso[1] and MM40 < MM401
cond4= st1 crosses under c 

if cond3 THEN
sellshort 100 %capital at market
endif

If  shortonmarket and cond4 THEN
exitshort 100 %capital at market
endif
 

Users who are viewing this thread

Alto