28/09/10

momc

Ogni promessa è debito e quindi.....

Si devono creare le variabili: pds(50,50,1), divi(3,3,1), pdsn(50,50,1), x(1,5,1)

////////////////////////////////////////////////////////////////
///////////////NORMALIZED MOMENTUM TS ///////////////
////////////////////////////////////////////////////////////////

if x=1 then
selprice=open
elsif x=2 then
selprice=high
elsif x=3 then
selprice=low
elsif x=4 then
selprice=close
elsif x=>5 then
selprice=volume
endif

ratio=min(selprice,selprice[pds])/max(selprice,selprice[pds])

if selprice>selprice[pds] then
mom=((2-ratio)*100)-100
else
mom=((ratio)*100)-100
endif

momnorm=(mom-lowest[pdsn](mom))/(highest[pdsn](mom)-lowest[pdsn](mom))*100


if pdsn=1 then
momnorm=mom
endif

pdsmm=round(pds/divi)
MM=TimeSeriesAverage[pdsmm](momnorm)

signal=((momnorm crosses over mm)-(mm crosses over momnorm))

if signal=1 then
if shortonmarket then
EXITSHORT at market nextbaropen
endif
buy 20%CAPITAL at market NextBarOpen
endif
if signal=-1 then
if longonmarket then
sell at market nextbaropen
endif
sellshort 20%CAPITAL at market NextBarOpen
endif
///////////////////////////FINE////////////////////////////////

Nessun commento:

Posta un commento

www.finanza.com
info.gif (242 byte)