;zrut8807.ini, adapted 03/18/2007 from
;prism.ini ( revised ) by Werner Gansz, 04/07/2001, 04/15/2001
;PRISM Chart - WWG 4/6/2001

;rut-i 09/01/1988 to 03/18/2007
;0start:  CFAEE   13 55 05 34 34
;1Rsi:    CFAEE   13 55 05 34 34
;2Price:  z0650   11 57 05 34 34
;3Relstr: z0448   11 57 04 33 34
;4Stoc:   z351307 11 57 04 33 34 35 14 08
;5Macd:   z391313 11 57 04 33 34 35 14 08 39 13 13
;6Rsi: no change
;7Price: z1657    16 57 04 33 34 35 14 08 39 13 13 
;8Reltr: no change
;9Stoc: no change




;=====================================================================
;Purpose
;=====================================================================
;This file creates a PRISM-type signal and fnu for your chosen fund.
;The signal is ztestsig.sig.
;The fnu is ztest.fnu.

;=====================================================================
;Input data
;(Enter your fund and trial PRISM parameters below.)
;=====================================================================

[Expression]
zfund = rut-i

;P = Price chart
shortema  = 16
longema   = 57

;R = Relative-strength chart
shortrsema = 4
longrsema = 33
30a = Irate(30)

;I = RSI chart
rsidays   = 34
rsilevel  = 50

;S = Stochastic chart
Average   = 35
Smooth    = 14
Trigger   = 8

;M = MACD chart
longma    = 39
shortma   = 13
signalma  = 13


;Combination-signal (number of signals for a buy or a sell)
;----------------------------------------------------------
buycount  = 4
sellcount = 4

;=====================================================================
;PRISM chart computations
;(Don't mess with the lines below.)
;=====================================================================


;P = Price chart
;---------------
PSig = Signal(Ema(zfund, shortema) - Ema(zfund, longema))


;R = Relative-strength chart
;---------------------------
;Create Yellow Relative Strength line
yellow = 10*(zfund/First(zfund))/(30a/First(30a))

;Create RelStr Moving Averages
cyan = Ema(yellow, shortrsema)
purple = Ema(yellow, longrsema)

;Buy and Sell Rules
RelStr.Buy = Signal(cyan - purple) And Signal(yellow - cyan)
RelStr.Sell = Signal(yellow - cyan)


;I = RSI chart
;-------------
RsiSig = Signal(Rsi(zfund, rsidays) - rsilevel)


;S = Stochastic chart
;--------------------
;%K calculation
Kstoch = 100 * (zfund - Min(zfund, Average)) /
 (Max(zfund, Average) - Min(zfund, Average))

;%D calculation
Dstoch = Ema(Kstoch, Smooth) 

;Signal Line
signalline = Ema(Dstoch, Trigger)  
StochSig = Signal(Dstoch - signalline)  

;M = MACD chart
;--------------
macd = Ema(zfund, shortma) - Ema(zfund, longma)
signalline = Ema(macd, signalma)
macdhisto = macd - signalline
MACDsig = Signal(macdhisto)


;=====================================================================
;Combination signal creation.
;Fnu creation.
;(Don't mess with the lines below.)
;=====================================================================


totalcount = 5
sigsum = Vector(relstr) + Vector(psig) + Vector(rsisig)
         + Vector(stochsig) + Vector(macdsig) + Totalcount / 2

;Create a vector that goes positive when sigsum increases.
bstate1 = (sigsum - Shift(sigsum, 1) - 0.5)

;Create a vector that is positive when sigsum >= buycount.
bstate2 = sigsum - buycount + 0.5

;Create a vector that goes positive when sigsum decreases.
sstate1 = Shift(sigsum, 1) - sigsum + 0.5

;Create a vector that is positive
;when #sells >= sellcount.
sstate2 = totalcount - sellcount - sigsum + 0.5

combo_sig.Buy = Signal(bstate1 And bstate2)
combo_sig.Sell = Not Signal(sstate1 And sstate2)
WriteFile(combo_sig, zrut8807, "zrut8807 090188-031807")

;=====================================================================
;=====================================================================
;=====================================================================
;=====================================================================
;=====================================================================

[SignalPairTrade]
StartDate = 09/01/1988
Delay     = 1
Fund      = rut-i
Index     = fgrxx
Signal    = zrut8807
FnuFile   = z8807