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

Arosa

Forumer attivo
per metastock non c'è?
grazie e complimenti
Ciauz
Certo che c'è! :D

Factor:=Input("Factor",1.00,10.00,3.00);
Pd:=Input("ATR Periods",1,100,10);
Up:=MP()+(Factor*ATR(Pd));
Dn:=MP()-(Factor*ATR(Pd));
Td:=If(Cross(C,LLV(Up,13)),1,If(Cross(HHV(Dn,13),C),-1,PREV));
Dnx:=If(Dn=HighestSince(1,Cross(Td,0),Dn),Dn,PREV);
Upx:=If(Up=LowestSince(1,Cross(0,Td),Up),Up,PREV);
ST:=If(Td=1,Dnx,If(Td=-1,Upx,PREV));
ST
 

Damien

Nessuno è mai al sicuro
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

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;

Supertrend è una cosa e Chandelier è un'altra.
Sono due indicatori diversi, con due codici diversi.

Ti saluto, buona giornata.
 

ale73a

break even trader
Supertrend è una cosa e Chandelier è un'altra.
Sono due indicatori diversi, con due codici diversi.

Ti saluto, buona giornata.
grazie Damien, infatti avevo visto che le equity erano diverse tra il ts con proreal e quello su vt, purtroppo avevo letto questa cosa su un paio di post vecchi sul fol e non ho mai approfondito la cosa :wall:
ciao!
 
codice Supertrend

Se avete voglia e pazienza di tradurre il codice del supertrend da prorealtime a vt, il codice di prorealtime è questo:

//*****************************************************************************
//* Algoritmo SuperTrend
//*****************************************************************************

Once Volatilita=0
Once Prezzomediano=0
Once Bandaup=0
Once Bandadn=0
Once trend=0
Once ST=0
Once Inizio=0
Once Coefficiente=3.5

//******************************************************************************
//CALCOLO DELLA VOLATILITA'
//La volatilità è calcolata sull'ATR tra 10 e 15 periodi

volatilita = AverageTrueRange[15]

//******************************************************************************
//CALCOLO DEL PREZZO MEDIANO
//Il prezzo mediano è rappresentato da massimo + minimo diviso due

Prezzomediano = (High + Low) / 2

//******************************************************************************
//CALCOLO DELLE BANDE
//la banda up è corrispondente al prezzomediano + coefficiente x atr
//la banda down è corrispondente al prezzo mediano - coefficiente x atr
//Nota il coefficiente standard è solitamente tra 3 e 4

Bandaup = Prezzomediano + (Coefficiente * Volatilita)
Bandadn = Prezzomediano - (Coefficiente * Volatilita)

//******************************************************************************
//INIZIALIZZAZIONE TREND A 1 CON ESAME PRIMA BARRA

if inizio = 0 then
Trend = 1
Inizio = 1
endif


//******************************************************************************
//CASO 1
//Se il trend = 1 e il close è inferiore alla banda down allora il trend
//diventa negativo, il calcolo della banda diventa quello standard e la
//supertrend assume l'aspetto della banda superiore in quanto il trend
//è diventato negativo.

if Trend = 1 and Close < bandadn[1] then
Trend = -1
bandaup = prezzomediano + (coefficiente * volatilita)
ST = Bandaup
endif

//******************************************************************************
//CASO 2
//Se il trend = 1 e il close è maggiore o uguale della banda down e la bandadown
//è inferiore alla bandadown precedente, il trend rimane sempre positivo ma
//la bandadown rimane sempre allo stesso livello e non scende.
//Il concetto principale è che nel caso in cui il trend è positivo una volta
//determinata la prima volta la bandadown, quest'ultima puo' solo salire ad
//inseguimento (in una sorta di trailing stop).

if Trend = 1 and Close >= Bandadn[1] and Bandadn < Bandadn[1] then
bandadn = bandadn[1]
ST = bandadn
endif

//******************************************************************************
//CASO 3
//Se il trend = 1 e il close è maggiore o uguale della banda down e la bandadown
//è maggiore della bandadown precedente, il trend rimane sempre positivo ma
//la supertrend assume lo stesso livello della bandadown in maniera che il
//limite della banda inferiore si alza ad inseguimento

if trend = 1 and Close >= Bandadn[1] and Bandadn >= Bandadn[1] then
ST = Bandadn
endif

//******************************************************************************
//CASO 4
//Se il trend è negativo e il close risulta maggiore della bandaup allora il
//trend diventa positivo, il calcolo della banda diventa quello standard e la
//supertrend assume l'aspetto della banda inferiore in quanto il trend è
//diventato positivo

if Trend =-1 and close > Bandaup[1] then
Trend = 1
Bandadn = Prezzomediano - (Coefficiente * Volatilita)
ST = Bandadn
endif

//**************************************** **************************************
//CASO 5
//Se il trend è negativo e il close risulta inferiore uguale alla bandaup e la
//bandaup risulta maggiore della bandaup precedente allora il trend rimane
//sempre negativo e la bandaup rimane sempre allo stesso livello.
//Il concetto è che se il trend è negativo la banda superiore, una volta fissata
//puo' solo scendere ad inseguimento come in una sorta di trailing stop.

if Trend =-1 and Close <= Bandaup and Bandaup > Bandaup[1] then
Bandaup = bandaup[1]
ST = bandaup
endif

//**************************************** **************************************
//CASO 6
//Se il trend è negativo e il close risulta inferiore uguale alla bandaup e la
//bandaup risulta inferiore della banda precedente allora la supertrend assume
//il nuovo valore della bandaup

if Trend =-1 and Close <= Bandaup and Bandaup <= Bandaup[1] then
ST = Bandaup
endif

//**************************************** **************************************
//Colora le barre a seconda che il trend sia positivo (1) o negativo (-1)
A= close - ST

//**************************************** **************************************
//Disegno il SuperTrend
Return ST coloured by A
 

ale73a

break even trader
Se avete voglia e pazienza di tradurre il codice del supertrend da prorealtime a vt, il codice di prorealtime è questo:

//*****************************************************************************
//* Algoritmo SuperTrend
//*****************************************************************************

Once Volatilita=0
Once Prezzomediano=0
Once Bandaup=0
Once Bandadn=0
Once trend=0
Once ST=0
Once Inizio=0
Once Coefficiente=3.5

//******************************************************************************
//CALCOLO DELLA VOLATILITA'
//La volatilità è calcolata sull'ATR tra 10 e 15 periodi

volatilita = AverageTrueRange[15]

//******************************************************************************
//CALCOLO DEL PREZZO MEDIANO
//Il prezzo mediano è rappresentato da massimo + minimo diviso due

Prezzomediano = (High + Low) / 2

//******************************************************************************
//CALCOLO DELLE BANDE
//la banda up è corrispondente al prezzomediano + coefficiente x atr
//la banda down è corrispondente al prezzo mediano - coefficiente x atr
//Nota il coefficiente standard è solitamente tra 3 e 4

Bandaup = Prezzomediano + (Coefficiente * Volatilita)
Bandadn = Prezzomediano - (Coefficiente * Volatilita)

//******************************************************************************
//INIZIALIZZAZIONE TREND A 1 CON ESAME PRIMA BARRA

if inizio = 0 then
Trend = 1
Inizio = 1
endif


//******************************************************************************
//CASO 1
//Se il trend = 1 e il close è inferiore alla banda down allora il trend
//diventa negativo, il calcolo della banda diventa quello standard e la
//supertrend assume l'aspetto della banda superiore in quanto il trend
//è diventato negativo.

if Trend = 1 and Close < bandadn[1] then
Trend = -1
bandaup = prezzomediano + (coefficiente * volatilita)
ST = Bandaup
endif

//******************************************************************************
//CASO 2
//Se il trend = 1 e il close è maggiore o uguale della banda down e la bandadown
//è inferiore alla bandadown precedente, il trend rimane sempre positivo ma
//la bandadown rimane sempre allo stesso livello e non scende.
//Il concetto principale è che nel caso in cui il trend è positivo una volta
//determinata la prima volta la bandadown, quest'ultima puo' solo salire ad
//inseguimento (in una sorta di trailing stop).

if Trend = 1 and Close >= Bandadn[1] and Bandadn < Bandadn[1] then
bandadn = bandadn[1]
ST = bandadn
endif

//******************************************************************************
//CASO 3
//Se il trend = 1 e il close è maggiore o uguale della banda down e la bandadown
//è maggiore della bandadown precedente, il trend rimane sempre positivo ma
//la supertrend assume lo stesso livello della bandadown in maniera che il
//limite della banda inferiore si alza ad inseguimento

if trend = 1 and Close >= Bandadn[1] and Bandadn >= Bandadn[1] then
ST = Bandadn
endif

//******************************************************************************
//CASO 4
//Se il trend è negativo e il close risulta maggiore della bandaup allora il
//trend diventa positivo, il calcolo della banda diventa quello standard e la
//supertrend assume l'aspetto della banda inferiore in quanto il trend è
//diventato positivo

if Trend =-1 and close > Bandaup[1] then
Trend = 1
Bandadn = Prezzomediano - (Coefficiente * Volatilita)
ST = Bandadn
endif

//**************************************** **************************************
//CASO 5
//Se il trend è negativo e il close risulta inferiore uguale alla bandaup e la
//bandaup risulta maggiore della bandaup precedente allora il trend rimane
//sempre negativo e la bandaup rimane sempre allo stesso livello.
//Il concetto è che se il trend è negativo la banda superiore, una volta fissata
//puo' solo scendere ad inseguimento come in una sorta di trailing stop.

if Trend =-1 and Close <= Bandaup and Bandaup > Bandaup[1] then
Bandaup = bandaup[1]
ST = bandaup
endif

//**************************************** **************************************
//CASO 6
//Se il trend è negativo e il close risulta inferiore uguale alla bandaup e la
//bandaup risulta inferiore della banda precedente allora la supertrend assume
//il nuovo valore della bandaup

if Trend =-1 and Close <= Bandaup and Bandaup <= Bandaup[1] then
ST = Bandaup
endif

//**************************************** **************************************
//Colora le barre a seconda che il trend sia positivo (1) o negativo (-1)
A= close - ST

//**************************************** **************************************
//Disegno il SuperTrend
Return ST coloured by A

:up: grazie, anche se mi sembrano migliori i rendimenti su vt e quindi col chandelier confronto a quelli su proreal col supertrend...quindi, in teoria, sarebbe da tradurre il chandelier su prorealtime
 

ale73a

break even trader
se mi fornisci il codice del vt lo traduco in prorealtime

questo è quello creato da :up: javier sardà :up:

Codice:
Var: Stop1, Stop2, StopLong, StopShort, PREV, Chandelier(0),OscAtr3, OscAtr25;
Var: contahl,prox0,indzona1,pp,llow,hhigh,aa, bb,expoa,expob,dd,indzona2;
/////////////////////////////////////////////////////////////////////////////////
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, blue, 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);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

@ndy

Virgo Fidelis
a voler essere pignoli........il codice del candelier è solo questo...



Codice:
Var: Stop1, Stop2, StopLong, StopShort, PREV, Chandelier(0),OscAtr3, OscAtr25;
Var: contahl,prox0,indzona1,pp,llow,hhigh,aa, bb,expoa,expob,dd,indzona2;
/////////////////////////////////////////////////////////////////////////////////
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;


PlotChart(Chandelier, 0, blue, solid, 2);
 

ale73a

break even trader
a voler essere pignoli........il codice del candelier è solo questo...



Codice:
Var: Stop1, Stop2, StopLong, StopShort, PREV, Chandelier(0),OscAtr3, OscAtr25;
Var: contahl,prox0,indzona1,pp,llow,hhigh,aa, bb,expoa,expob,dd,indzona2;
/////////////////////////////////////////////////////////////////////////////////
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;


PlotChart(Chandelier, 0, blue, solid, 2);

grazie :D
 

Users who are viewing this thread

Alto