Programmazione Visual Trader Raccolta indicatori e TS per Visualtrader (1 Viewer)

100pezzi

Nuovo forumer
SUPERTREND

Codice:
{******************************************************************************
* SUPERTREND by ender85
* Codice di Robom1 preso dal Fol e modificato in minima parte
* solo per renderlo simile alla versione di Prorealtime
* Ringraziamenti: Robom1, Damien e Ronzy
******************************************************************************}
Var: volatilita(0),
prezzomediano(0),
bandaup(0),
bandadn(0),
trend(0),
strend(0),
colore(0),
inizio(0);

input: Moltiplicatore(3),
Nm_periodi(100);
//******************************************************************************
//CALCOLO DELLA VOLATILITA'
//La volatilità è calcolata sull'ATR di 100 periodi

volatilita = ATR(C, Nm_periodi);

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

prezzomediano = (H + L) / 2;

//******************************************************************************
//CALCOLO DELLE BANDE
//la banda up è corrispondente al prezzomediano + moltiplicatore x atr
//la banda down è corrispondente al prezzo mediano - moltiplicatore x atr
//Nota il moltiplicatore standard è solitamente impostato a 3

bandaup = prezzomediano + (moltiplicatore * volatilita);
bandadn = prezzomediano - (moltiplicatore * volatilita);

//******************************************************************************
//INIZIALIZZAZIONE TREND A 1 CON ESAME PRIMA BARRA (non necessario se iniz. la var.

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
C < bandadn[1]
then
trend = -1;
bandaup = prezzomediano +
(moltiplicatore * volatilita);
strend = 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
C >= bandadn[1] and
bandadn < bandadn[1]
then
bandadn = bandadn[1];
strend = bandadn;
endif;

//******************************************************************************
//CASO 3
//Se il trend = 1 e il close è maggiore o uguale della banda down e la banddown
//è 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
C >= bandadn[1] and
bandadn >= bandadn[1]
then
strend = 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 -
(moltiplicatore * volatilita);
strend = 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];
strend = 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
strend = bandaup;
endif;

//******************************************************************************
//Colora il Supertrend a seconda che il trend sia positivo (1) o negativo (-1)

if trend = 1 then
colore= green;
else
colore= red;
endif;

//******************************************************************************
//Disegno il Supertrend
PlotChart(strend, 0, colore, solid, 3);
 
Ultima modifica:

100pezzi

Nuovo forumer
CHANDELIERSTOP

Codice:
Var: Stop1, Stop2, StopLong, StopShort, PREV, Chandelier(0),OscAtr3, OscAtr25,colore;


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(c > StopLong[1]) > BarSince(c < StopShort[1]) then
Chandelier = StopLong;colore= lime;
else
Chandelier = StopShort;colore= red;
endif;

PlotChart(Chandelier, 0, colore, solid, 2);
 
Ultima modifica:

100pezzi

Nuovo forumer
TRENDLINE

Codice:
Var: idx(0),numiniz(1),numfine(50),lin1,lin2,minimo,pminimo,dminimo,massimo,dmassimo,pmassimo,
     idx1(0),numiniz1(1),numfine1(10),minoggi,pminoggi,dminoggi,incrmin,incrmax,valmin,valmax,maxoggi,pmaxoggi,dmaxoggi,numerobarre(50),
     contabarregiorno(5),conta(0);
if isfirstbarday then
                  //CERCO IL MINIMO E IL MASSIMO DI IERI SULLE ULTIME X BARRE (NUMFINE)

                  minimo=l[1];
                  beginfor(idx,numiniz,numfine);
                  if l[idx]<minimo then
                                    pminimo=idx;
                                    minimo=l[idx];
                                    dminimo=d[idx];
                  endif;
                  endfor;
                  massimo=h[1];
                  beginfor(idx,numiniz,numfine);
                  if h[idx]>massimo then
                                    pmassimo=idx;
                                    massimo=h[idx];
                                    dmassimo=d[idx];
                  endif;
                  endfor;
                  conta=0;
endif;
//CONTEGGIO LE BARRE GIORNALIERE
conta=conta+1;
//CALCOLO LA TRENDLINE DI OGGI DOPO X BARRE (CONTABARREGIORNO)
if conta=contabarregiorno then
                  incrmin=0;
                  incrmax=0;
                  valmin=0;
                  valmax=0;
                  minoggi=0;
                  maxoggi=0;
                  dminoggi=0;
                  dmaxoggi=0;
                  pminoggi=0;
                  pmaxoggi=0;
                  //MINIMO OGGI
                  minoggi=l;
                  beginfor(idx1,numiniz1,contabarregiorno-1);
                  if l[idx1]<minoggi then
                                    pminoggi=idx1;
                                    minoggi=l[idx1];
                                    dminoggi=d[idx1];
                  endif;
                  endfor;
                  //MASSIMO OGGI
                  maxoggi=h;
                  beginfor(idx1,numiniz1,contabarregiorno-1);
                  if h[idx1]>maxoggi then
                                    pmaxoggi=idx1;
                                    maxoggi=h[idx1];
                                    dmaxoggi=d[idx1];
                  endif;
                  endfor;

                  //CALCOLO FATTORE INCREMENTO MIN
                  if minoggi>0 and minimo>0 then

                  if minoggi<minimo then
                                    incrmin=(minimo-minoggi)/(pminimo+(conta-pminoggi)-1);
                                    valmin=minoggi-(incrmin*(contabarregiorno-pminoggi));
                  endif;

                  if minoggi=minimo then
                                    incrmin=0;
                                    valmin=minoggi;
                  endif;
                  if minoggi>minimo then
                                    incrmin=(minoggi-minimo)/(pminimo+(conta-pminoggi)-1);
                                    valmin=minoggi+(incrmin*(contabarregiorno-pminoggi));
                  endif;
                  endif;

                  //CALCOLO FATTORE INCREMENTO MAX
                  if maxoggi>0 and massimo>0 then

                  if maxoggi<massimo then
                                    incrmax=(massimo-maxoggi)/(pmassimo+(conta-pmaxoggi)-1);
                                    valmax=maxoggi-(incrmax*(contabarregiorno-pmaxoggi));
                  endif;
                  if maxoggi=minimo then
                                    incrmax=0;
                                    valmax=maxoggi;
                  endif;
                  if maxoggi>massimo then
                                    incrmax=(maxoggi-massimo)/(pmassimo+(conta-pmaxoggi)-1);
                                    valmax=maxoggi+(incrmax*(contabarregiorno-pmaxoggi));
                  endif;
                  endif;
                  //GENERO LE 2 TREND
                  lin1 = CREATEOGG;
                  lin2 = CREATEOGG;
endif;
                  //TRACCIO LE TRENDLINE INCREMENTALI
if conta>contabarregiorno then
                  if maxoggi>0 and massimo>0 then
                  if maxoggi>massimo then
                                          valmax=valmax+incrmax;
                                          lin1 = DrawLine(lin1, 0, D[0], valmax, dmassimo, massimo, red, 3, 0);
                  endif;
                  if maxoggi=massimo then
                                          valmax=valmax;
                                          lin1 = DrawLine(lin1, 0, D[0], valmax, dmassimo, massimo, red, 3,0);
                  endif;
                  if maxoggi<massimo then
                                          valmax=valmax-incrmax;
                                          lin1 = DrawLine(lin1, 0, D[0], valmax, dmassimo, massimo, red, 3, 0);
                  endif;
                  endif;
                  //MINIMO

                  if minoggi>0 and minimo>0 then

                  if minoggi>minimo then
                                          lin2 = DrawLine(lin2, 0, D[0], valmin, dminimo, minimo, green, 3, 0);
                                          valmin=valmin+incrmin;
                  endif;
                  if minoggi=minimo then
                                          lin2 = DrawLine(lin2, 0, D[0], valmin, dminimo, minimo, green, 3, 0);
                                          valmin=valmin;
                  endif;
                  if minoggi<minimo then
                                          lin2 = DrawLine(lin2, 0, D[0], valmin, dminimo, minimo, green, 3, 0);
                                          valmin=valmin-incrmin;
                  endif;
                  endif;
endif;
 
Ultima modifica:

100pezzi

Nuovo forumer
AMA

Codice:
Input:Periodkf(9);
Var:Noise(0),Signal(0),VAL1(0),EfRatio(0),Smooth(1),Fastest(0.6667),Slowest(0.0645),AdaptMA(0),Ama;

VAL1 = valore_assoluto(op(c,ref(c,1),sub) );
If CurrentBar<=Periodkf then AdaptMA=C;
endif;
If CurrentBar>Periodkf then
Signal = valore_assoluto(op(c,ref(c,Periodkf),sub)) ;
Noise=Sumval(Val1,Periodkf);
efRatio=op(signal,noise,divis);
Smooth=power(op(op(op(constval(Fastest), constval(Slowest),sub),EfRatio,mul),constval(Slowest),add),2);
AdaptMA=AdaptMA[1]+Smooth*(C-AdaptMA[1]);
Endif;
Ama = AdaptMa;

PlotChart(AMA,0,red,solid,2);
 

100pezzi

Nuovo forumer
AROON ASCILLATOR

Codice:
Var: Indzona1,ArUp,ArDw,ArrowUp,ArrowDw,P(14),ArronOscillator ;
//////////////////////////////////
if L[1]=LLV(L,p)then ArDw=1;endif;
if L[2]=LLV(L,p)then ArDw=2;endif;
if L[3]=LLV(L,p)then ArDw=3;endif;
if L[4]=LLV(L,p)then ArDw=4;endif;
if L[5]=LLV(L,p)then ArDw=5;endif;
if L[6]=LLV(L,p)then ArDw=6;endif;
if L[7]=LLV(L,p)then ArDw=7;endif;
if L[8]=LLV(L,p)then ArDw=8;endif;
if L[9]=LLV(L,p)then ArDw=9;endif;
if L[10]=LLV(L,p)then ArDw=10;endif;
if L[11]=LLV(L,p)then ArDw=11;endif;
if L[12]=LLV(L,p)then ArDw=12;endif;
if L[13]=LLV(L,p)then ArDw=13;endif;
if L[14]=LLV(L,p)then ArDw=14;endif;
ArrowDw=100*(p-ArDw)/p;

if H[1]=HHV(H,p)then ArUp=1;endif;
if H[2]=HHV(H,p)then ArUp=2;endif;
if H[3]=HHV(H,p)then ArUp=3;endif;
if H[4]=HHV(H,p)then ArUp=4;endif;
if H[5]=HHV(H,p)then ArUp=5;endif;
if H[6]=HHV(H,p)then ArUp=6;endif;
if H[7]=HHV(H,p)then ArUp=7;endif;
if H[8]=HHV(H,p)then ArUp=8;endif;
if H[9]=HHV(H,p)then ArUp=9;endif;
if H[10]=HHV(H,p)then ArUp=10;endif;
if H[11]=HHV(H,p)then ArUp=11;endif;
if H[12]=HHV(H,p)then ArUp=12;endif;
if H[13]=HHV(H,p)then ArUp=13;endif;
if H[14]=HHV(H,p)then ArUp=14;endif;
ArrowUp=100*(p-ArUp)/p;
ArronOscillator=(ArrowUp-ArrowDw) ;
Indzona1=CreateViewport(300,0,true);
PlotChart( ArrowUp,INDZONA1,green,solid,2 );
PlotChart( ArrowDw,INDZONA1,red,solid,2);
PlotChart( ArronOscillator,INDZONA1,black,solid,1);
 
Ultima modifica:

100pezzi

Nuovo forumer
Parabolic Sar tradotto da amibroker

Codice:
VAR: PSAR,HP,LP,AF,reverse,inizio,long;
Input: MaxAF(0.2),IAF(0.02);

if CURRENTBAR<2 then
PSAR = l;
LONG = 1;
AF = IAF;
HP = H;
LP = L;
ENDIF;

IF CURRENTBAR>2 THEN
if LONG = 1 then
PSAR = PSAR + af * (hp - PSAR);
ELSE
PSAR = PSAR + af * (lp - PSAR);
ENDIF;

reverse = 0;
IF LONG = 1 THEN
IF L < PSAR THEN
LONG = 0;REVERSE = 1;
PSAR = HP;
LP = L;
AF = IAF;
ENDIF;
ELSE
IF H > PSAR THEN
LONG = 1;REVERSE = 1;
PSAR = LP;
HP = H;
AF = IAF;
ENDIF;
ENDIF;

IF reverse=0 THEN
IF LONG=1 THEN
IF H > HP THEN
HP = H;
AF = AF+ IAF;
if af>MaxAF THEN AF = MaxAF;ENDIF;
if (L[1] < psar) then psar = L[1];endif;
if (L[2] < psar) then psar = L[2];endif;
ENDIF;
ELSE
IF L < LP THEN
LP = L;
AF = AF + IAF;
if af>MaxAF THEN AF = MaxAF;ENDIF;
if (H[1] > psar) then psar = H[1];endif;
if (H[2] > psar) then psar = H[2];endif;
ENDIF;
ENDIF;
ENDIF;

plotchart(PSAR, 0, red, solid,2);
ENDIF;
 
Ultima modifica:

100pezzi

Nuovo forumer
Coppock Curve

Codice:
var:roc1,roc2,coppock,zona;
//11 mesi = circa a 240 periodi
roc1=roc(c,240);
//14 mesi = circa a 300 periodi
roc2=roc(c,300);
//media a 10 mesi = circa a 200 periodi
coppock=mov( op(roc1,roc2,add),200,s);
zona=CreateViewport(200,0,true);
plotchart(coppock,zona,gray, solid, 2);
 

100pezzi

Nuovo forumer
Swing Gann - robom1

Codice:
  {******************************************************************************
  * Swing Gann - robom1
  ******************************************************************************}
  Var:  opeA(0), opeB(0), opeC(0),
        higA(0), higB(0), higC(0),
        lowA(0), lowB(0), lowC(0),
        cloA(0), cloB(0), cloC(0),
        barrainside(0), confronto(0),
        swing(0), swingattivo(0),
        indzona1, indzona2;
  indzona1=CreateViewport(200, true, True);
  indzona2=CreateViewport(200, true, True);
  //******************************************************************************
  //VERIFICA DELLE BARRE INSIDE
  //le barre inside non vengono considerate; il confronto viene effettuato su
  //high e min dell'ultima barra validata (per barra validata vedi success.)
  if H <= higC and L >= lowC then barrainside = 1; else barrainside = 0; endif;
  //******************************************************************************
  //SHIFT DEI VALORI E DETERMINAZIONE DEI VALORI DELLE TRE BARRE DI CONFRONTO
  //Se la barra non è inside occorre verificare che, nelle fasi preliminari vi
  //siano almeno tre valori positivi su cui effettuare il confronto.
  //Si possono avere pertanto i seguenti casi:
  if barrainside = 0 then
  //Caso A
  //Esistono già tutte le serie dei tre valori di confronto; allora in questo
  //caso si procede allo shift dei valori precedenti e il valore della barra
  //corrente diventa il valore della barra C; in questo caso quindi si è
  //proceduto allo shift dei valori precedenti e si potrà procedere al confronto
  //per la verifica/determinazione di eventuali swing
                   if
                   opeA <> 0 and opeB <> 0 and opeC <> 0
                   then
                   opeA = opeB; higA = higB; lowA = lowB; cloA = cloB;
                   opeB = opeC; higB = higC; lowB = lowC; cloB = cloC;
                   opeC =    C; higC =    H; lowC =    L; cloC =    C;
                   confronto = 1;
                   endif;
   
  //Caso B
  //Esistono due delle tre serie di valori e manca la barra C; si procede quindi
  //al solo inserimento della barra C senza procedere allo shift ed inoltre si
  //procederà al confronto per la verifica/determinazione di eventuali swing.
                   if
                   opeA <> 0 and opeB <> 0 and opeC = 0
                   then
                   opeC =    C; higC =    H; lowC =    L; cloC =    C;
                   confronto = 1;
                   endif;
                   
  //Caso C
  //Esiste solo la serie relativa alla barra A mentre ancora mancano quelli della
  //barra B; la barra B assumerà pertanto i valori correnti e non si potrà
  //procedere al confronto in quanto mancano ancora i valori della barra C.
                   if
                   opeA <> 0 and opeB = 0
                   then
                   opeB = C; higB = H; lowB = L; cloB = C;
                   confronto = 0;
                   endif;
   
  //Caso D
  //Manca ancora il valore della barra A (siamo alla prima barra); la barra A
  //assumerà pertanto i valori correnti e non si potrà procedere al confronto
  //in quanto mancano ancora i valori della barra B e C.
                   if
                   opeA = 0
                   then
                   opeA =    C; higA =    H; lowA =    L; cloA =    C;
                   confronto = 0;
                   endif;
                   
  endif;
   
  //******************************************************************************
  //DETERMINAZIONE DEGLI SWING DI MAX E SWING DI MIN
  //Se la barra non è inside e puo' essere effettuato il confronto viene
  //verificato se si tratta di uno swing di max
   
  //Prima di iniziare il ciclo pongo lo swing uguale a zero
  swing = 0;
  //Faccio il ciclo solo se la barra non è inside e posso effettuare il confronto
  if barrainside = 0 and confronto = 1 then
   
  //Caso A. SWING DI MAX
  //
  //Confronto tra barra B e barra A:
  // - la barra B deve avere un max maggiore di quello della barra A e un minimo
  //   maggiore o uguale a quello della barra A
  //
  //Confronto tra la barra B e la barra C:
  // - la barra B deve avere un massimo maggiore o uguale a quello della barra C
  //   ed inoltre il minimo della barra C deve essere inferiore a quello della
  //   barra B.
  //La segnalazione dello swing di max viene effettuato sulla barra C
                   if
                   higB >  higA and
                   lowB >= lowA and
                   higB >= higC and
                   lowB >  lowC
                   then
                   swing = -1;
                   endif;
                   
   
  //Caso B. SWING DI MIN
  //
  //Confronto tra barra B e barra A:
  // - la barra B deve avere un massimo inferiore o uguale al massimo di A e
  //   inoltre un minimo inferiore a quello di A.
  //
  //Confronto tra la barra B e la barra C:
  // - la barra B deve avere un massimo inferiore al massimo di C ed inoltre
  // un minimo inferiore o uguale al minimo di C
  //La segnalazione dello swing di min viene effettuato sulla barra C
                   if
                   higB <= higA and
                   lowB <  lowA and
                   higB <  higC and
                   lowB <= lowC
                   then
                   swing = 1;
                   endif;
                   
  endif;
  //******************************************************************************
  //COLORO LE INSIDE DI GIALLO
  if barrainside = 1 then colorbar(yellow); endif;
   
  //******************************************************************************
  //DETERMINAZIONE DELLO SWING ATTIVO IN OGNI BARRA
  //Se lo swing è diverso da zero chiaramente lo swing attivo sarà quello rilevato
  //altrimenti sarà lo swing precedentemente determinato
  if swing <> 0 then swingattivo = swing; else swingattivo = swingattivo[1]; endif;
  PlotChart(swingattivo, indzona1, blue, istogramma, 3);
  PlotChart(swing, indzona2, blue, solid, 3);
 
Ultima modifica:

100pezzi

Nuovo forumer
GRAZIE AL NS AMICO BORG72 X L'INDICATORE FXFISH

Codice:
Var: MaxH(0),MinL(0),Fish(0), Value1,FISHER_View,COLOR_FISH,PRICE;
Input: p(10);

SETCALCOSCARRAY(true);

price = (h+l)/2;
MaxH = HHV(price, p);
MinL = LLV(price, p);
Value1 = 0.33*2*((price - MinL)/(MaxH - MinL) - 0.5) + 0.67*Value1[1];
If Value1 > 0.99 then
   Value1 = 0.999;
endif;
If Value1 < -0.99 then
   Value1 = -0.999;
endif;
Fish = 0.5*OSC_LN ((1 + Value1)/(1 - Value1)) + 0.5*Fish[1];

IF fish>0 then COLOR_FISH=GREEN;ELSE COLOR_FISH=RED;endif;

FISHER_View=CreateViewport(200,0,true);
plotchart(Fish,FISHER_View,COLOR_FISH, ISTOGRAMMA, 2);


PS.: FUNZIONA COL LA VERS 5.4 O SUP.
 

Users who are viewing this thread

Alto