 |
|
08-08-2011, 12:03
|
#1 (permalink)
|
|
Almost Jazz Pianist
Data registrazione: Aug 2004
Località: Fiji
Messaggi: 11,613
|
Schaff trend cycle visualtrader
qualcuno è in grado di trasformare la formula per amibroker in formula per visualtrader?
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Repo...9f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation
//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;
//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2[i] > 0) {
frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
}
else {
frac1[i]= frac1[i-1];
}
}
//Smoothed calculation for %FastD of MACD
PF[0]=frac1[0];
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));
}
//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/
frac2[0]=0;
for (i = 1; i < BarCount; i++) {
if (Value4[i] > 0 ) {
frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
}
else {
frac2[i]=frac2[i-1];
}
}
//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));
}
Plot(pff,"STLC",colorRed,styleLine);
Plot(75,"",colorBlue,styleLine|styleDashed);
Plot(25,"",colorYellow,styleLine|styleDashed);
|
|
|
| Avviso pubblicitario - i seguenti Banner Pubblicitari permettono al sito di offrirvi il consueto, alto standard qualitativo. |
| |
|
08-08-2011, 12:07
|
#2 (permalink)
|
|
Almost Jazz Pianist
Data registrazione: Aug 2004
Località: Fiji
Messaggi: 11,613
|
metastock
Schaff Trend Cycle Oscillator
{ Schaff Trend Cycle Oscillator v1.0 }{ Automatic trigger levels }{ Also see: "MACD oscillator - Schaff Trend Cycle" }{ josesilva22@yahoo.com }{ With thanks to Tim Straiton, www.stoploss.ch }
{ variables input }
pdsCy:=Input("Schaff cycle periods",2,252,10);
pdsSh:=Input("Short periods",1,252,10);
pdsLg:=Input("Long periods",2,2520,21);
{ Schaff Trend Cycle }
MCD:=Wilders(MP(),pdsSh)-Wilders(MP(),pdsLg);
ST:=(MCD-LLV(MCD,pdsCy))
/(HHV(MCD,pdsCy)-LLV(MCD,pdsCy))*100;
STC:=Wilders(ST,pdsCy/2);
{ automatic trigger levels }
pk:=Ref(STC,-1)>STC AND Ref(STC,-1)>Ref(STC,-2);
pkVal:=If(pk,Ref(STC,-1),0);
pkAvg:=Cum(pkVal)/(Cum(pk)+.000001);
pkAvg:=If(pkAvg=0,100,pkAvg);
tr:=Ref(STC,-1)<STC AND Ref(STC,-1)<Ref(STC,-2);
trVal:=If(tr,Ref(STC,-1),0);
trAvg:=Cum(trVal)/(Cum(tr)+.000001);
{ plot on own window }
pkAvg;trAvg;STC
Schaff Trend Cycle Indicator
{ Schaff Trend Cycle Indicator v1.0 }{ Automatic trigger levels }{ Also see: "MACD oscillator - Schaff Trend Cycle" }{ josesilva22@yahoo.com }{ With thanks to Tim Straiton, www.stoploss.ch }
{ variables input }
buffer:=Input("Long/Short buffer zone %",
0,100,0)/100;
pdsCy:=Input("Schaff cycle periods",2,252,10);
pdsSh:=Input("Short periods",1,252,10);
pdsLg:=Input("Long periods",2,2520,21);
{ Schaff Trend Cycle }
MCD:=Wilders(MP(),pdsSh)-Wilders(MP(),pdsLg);
ST:=(MCD-LLV(MCD,pdsCy))
/(HHV(MCD,pdsCy)-LLV(MCD,pdsCy))*100;
STC:=Wilders(ST,pdsCy/2);
{ Schaff Trend Cycle }
MCD:=Wilders(MP(),pdsSh)-Wilders(MP(),pdsLg);
ST:=(MCD-LLV(MCD,pdsCy))
/(HHV(MCD,pdsCy)-LLV(MCD,pdsCy))*100;
STC:=Wilders(ST,pdsCy/2);
{ automatic trigger levels }
pk:=Ref(STC,-1)>STC AND Ref(STC,-1)>Ref(STC,-2);
pkVal:=If(pk,Ref(STC,-1),0);
pkAvg:=Cum(pkVal)/(Cum(pk)+.000001);
pkAvg:=If(pkAvg=0,100,pkAvg);
tr:=Ref(STC,-1)<STC AND Ref(STC,-1)<Ref(STC,-2);
trVal:=If(tr,Ref(STC,-1),0);
trAvg:=Cum(trVal)/(Cum(tr)+.000001);
{ STC crossover signals }
In:=Cross(pkAvg,STC);
Out:=Cross(STC,trAvg);
InInit:=Cum(In)=1;
Init:=Cum(In+Out>-1)=1;
flag:=BarsSince(Init OR In)
< BarsSince(Init OR Out)+InInit;
signals:=(InInit AND Alert(InInit=0,2)
OR flag AND Alert(flag=0,2))
-(flag=0 AND Alert(flag,2));
{ trend support/resistance levels }
STCI:=If(flag,ValueWhen(1,signals,L*(1-buffer)),
ValueWhen(1,signals=-1 OR Init,H*(1+buffer)));
{ alternative STC crossover signals method}
{bb:=BarsSince(Cross(STC,trAvg));
bs:=BarsSince(Cross(pkAvg,STC));
tb:=ValueWhen(1,Cross(STC,trAvg),H*(1+buffer));
ts:=ValueWhen(1,Cross(pkAvg,STC),L*(1-buffer));
STCI:=If(bb<bs,tb,ts);}
{ plot on price chart }
STCI
(Go Top...)
|
|
|
11-08-2011, 00:50
|
#3 (permalink)
|
|
Forumer attivo
Data registrazione: Jul 2010
Località: torino
Messaggi: 93
|
Cercavo esattamente la stessa cosa!
|
|
|
16-08-2011, 23:15
|
#4 (permalink)
|
|
Utente Senior
Data registrazione: Apr 2009
Messaggi: 116
|
ci ho lavorato un pochino prendendo la formula MT e sono arrivato qui, ma da errore sulla riga :
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
perche' al posto di PF si aspetta un oscillatore, ma non so come risolvere la faccenda.
Lascio qui perce' qualcuno possa prendere il testimone e portalo al traguardo!
Input: TCLen(10), MA1(23), MA2(50);
//Input: TCLen(NumericSimple), MA1(NumericSimple), MA2(NumericSimple);
Var: XMac(0), Frac1(0), PF(0), PFF(0), Frac2(0), Factor(.5),
value1, value2, value3, value4, SchaffTC;
{Calculate a MACD Line}
XMac = MACD(c,MA1,MA2) ;
{1st Stochastic: Calculate Stochastic of a MACD}
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;
{%FastK of MACD}
Frac1 = IIF(Value2 > 0, ((XMac - Value1) / Value2) * 100, Frac1[1]);
{Smoothed calculation for %FastD of MACD}
PF = IIF(CurrentBar<=1, Frac1, PF[1] + (Factor * (Frac1 - PF[1])) );
{2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, ‘PF’, above.}
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
{%FastK of PF}
Frac2 = IIF(Value4 > 0, ((PF - Value3) / Value4) * 100, Frac2[1]);
{Smoothed calculation for %FastD of PF}
PFF = IIF(CurrentBar<=1, Frac2, PFF[1] + (Factor * (Frac2 - PFF[1])));
{The STC function is the %FastD of PF}
//SchaffTC= PFF;
__________________
Se i fatti e la teoria non concordano, lo stupido cambia i fatti.
A.Einstein
|
|
|
17-08-2011, 08:12
|
#5 (permalink)
|
|
Utente Senior
Data registrazione: Feb 2011
Messaggi: 109
|
nella beta 5.4 basta mettere
Codice:
Input: TCLen(10), MA1(23), MA2(50);
//Input: TCLen(NumericSimple), MA1(NumericSimple), MA2(NumericSimple);
Var: XMac(0), Frac1(0), PF(0), PFF(0), Frac2(0), Factor(.5),
value1, value2, value3, value4, SchaffTC;
SETCALCOSCARRAY(true);
{Calculate a MACD Line}
XMac = MACD(c,MA1,MA2) ;
{1st Stochastic: Calculate Stochastic of a MACD}
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;
{%FastK of MACD}
Frac1 = IIF(Value2 > 0, ((XMac - Value1) / Value2) * 100, Frac1[1]);
{Smoothed calculation for %FastD of MACD}
PF = IIF(CurrentBar<=1, Frac1, PF[1] + (Factor * (Frac1 - PF[1])) );
{2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, ‘PF’, above.}
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;
{%FastK of PF}
Frac2 = IIF(Value4 > 0, ((PF - Value3) / Value4) * 100, Frac2[1]);
{Smoothed calculation for %FastD of PF}
PFF = IIF(CurrentBar<=1, Frac2, PFF[1] + (Factor * (Frac2 - PFF[1])));
plotchartNoZero(PFF, 1, red, solid, 1);
|
|
|
17-08-2011, 08:54
|
#6 (permalink)
|
|
Utente Senior
Data registrazione: Apr 2009
Messaggi: 116
|
grazie 100pezzi!
allora devo installare la 5.4.
Ho provato dalla sezione info di VT ma non mi fa' vedere nulla.
Dove l'hai trovata?
__________________
Se i fatti e la teoria non concordano, lo stupido cambia i fatti.
A.Einstein
|
|
|
17-08-2011, 12:39
|
#7 (permalink)
|
|
Utente Senior
Data registrazione: Feb 2011
Messaggi: 109
|
ho chiesto nella sezione betatest direttamente dal menu INFO di vt
ciao
|
|
|
17-08-2011, 21:42
|
#8 (permalink)
|
|
Utente Senior
Data registrazione: Apr 2009
Messaggi: 116
|
esatto come avevo fatto io, probabilmente in questi gionri non e' disponbile,
riprovero' nei giorni prossimi
grazie
__________________
Se i fatti e la teoria non concordano, lo stupido cambia i fatti.
A.Einstein
|
|
|
17-08-2011, 21:46
|
#9 (permalink)
|
|
Utente Senior
Data registrazione: Apr 2009
Messaggi: 116
|
per chi e' interessato allo Schaff Trend Cylcle sara' anche interessato alla media mobile di Hull.
Allora copio il codice VT che uso io:
input:P(15);
Var:demip,temp,racineP,mmhull,demipp;
Var:indzona, lin1, data1, data2, valore1;
demiP=round(p/2,0);
temp=op(op(mov(c,demip,a),constval(2),mul),mov(c,p ,a),sub);
racinep=round(sqrt(p),0);
mmhull=mov(temp,racinep,a);
plotchart(mmhull,0,gray,solid,1);
// per colorare la mm
if mmhull >= mmhull[1] then
DrawCircle (createogg, indzona, GetDate, mmhull , lime, 1, 3);
endif;
if mmhull < mmhull[1] then
DrawCircle (createogg, indzona, GetDate, mmhull , red, 1, 3);
endif;
Che sia utile a qualcuno.
Ciao.
__________________
Se i fatti e la teoria non concordano, lo stupido cambia i fatti.
A.Einstein
|
|
|
25-08-2011, 17:50
|
#10 (permalink)
|
|
Almost Jazz Pianist
Data registrazione: Aug 2004
Località: Fiji
Messaggi: 11,613
|
grazie ragazzi nella beta fuziona ma si impalla spesso qualcuno è riuscito a farla girare nella 5.3?
|
|
|
|