;	fubar5x7.ini
;	Tom Tsao
;	12/03/05

;tweaked 7 parameters..05/01/06..dab
;added NewLow NoSell..01/19/07 
;ADDED BTCOMBO NO SELL - JOEL WILLIAMS

;	//IO:	Fitness: (car*.99^trades)/mdd
;	//IO:	SenOptGoalPct: 85
;	//IO:	FitnessTime: 900
;	dates:  01/05/96 to 11/07/05
;	trading dfscx
;
;	result #1: Ann: 31.7 Cdd: 18.3; generations: 204; fitness: 2.951 (trading mmcfx)
;	result #2: Ann: 32.9 Cdd: 16.4; generations: 219; fitness: 2.948 (trading mmcfx)

[Expression]

;create FNU of Ema19 of nsnlq+$nynl  
WriteFile(Ema(nsnlq+$nynl, 19), NL19)

PcntChg = 1.4

;;mmcfx = Edit(Shift(mmcfx, -1), 12/31/10, Last(mmcfx) * (1 + PcntChg/100))

chartdays       = 500
mday 		= Sum(Irate(0)/Irate(0))
editday 	= Last(mday - 1 - chartdays)

RsiFund         = RUT-I  ;or mmcfx
RsiStop         = 33 ;33; 32                  ;dab chg
RsiDays         = 14 ;29; 21                  ;dab chg

bt_level        = 85 ;83; 90.0                ;dab chg  same 83 to 85
bt_period       = 10 ;42; 31                  ;dab chg

;bearx used for buys only.

;Compute ema crossovers

fastma1         = 30 ;33; 35;                 ;dab chg
deltama1        = 37 ;37; 29;                 
slowma1		= fastma1 + deltama1

fastma2         = 04; 04;
deltama2        = 08; 05;
slowma2	= 	fastma2 + deltama2

fastma3         = 29; 31;              
deltama3        = 212; 176;            
slowma3		= fastma3 + deltama3

SumNL            = 58  ;NoSell Ema19 of nsnl+nynl ;same 48 or 55 to 58.5..dab
;SumNL           = 0   ;use this if you want to eliminate NoSell = 58
                                     
fusema.Buy 	= Signal(Ema(mmcfx,fastma1) - Ema(mmcfx,slowma1)) 
fusemc.Sell 	= Signal(Ema(mmcfx,fastma2) - Ema(mmcfx,slowma2)) 

fuseme.Buy 	= Signal(Ema(mmcfx,fastma3) - Ema(mmcfx,slowma3))

;WriteFile(fusema, fusema)
;WriteFile(fusemc, fusemc)
WriteFile(fuseme, fuseme)

;Compute mmcfx macd histogram 
fund 		= mmcfx
shortma         = 20; 27
longma          = 82; 48
signalma        = 22; 27
buylevel 	= 0
selllevel 	= 0
macd 		= Ema(fund, shortma) - Ema(fund, longma)
signalline 	= Ema(macd, signalma)
macdhisto 	= macd - signalline
mhf 		= macdhisto
macdsig.Buy 	= Signal(macdhisto - buylevel)
macdsig.Sell 	= Signal(macdhisto - selllevel)

emamacd.Buy	= macdsig Or (fusemc And macdsig) ; added by TT on 7/14/05
emamacd.Sell	= fusemc Or macdsig
;WriteFile(macdsig, macdsig)
;WriteFile(emamacd, emamacd)

;Compute mmcfx stochastic histogram
fund 		= mmcfx
Average         = 66; 69
Smooth          = 9 ;8  ;09; 14                  ;dab chg  1/23
Trigger         = 96; 88
Buyvalue 	= 0
Sellvalue 	= 0
stoch 		= 100 * (fund - Min(fund, Average)) / (Max(fund, Average) - Min(fund, Average))
stoch 		= Ema(stoch, Smooth) 
average 	= Ema(stoch, Trigger)  
histogram 	= stoch - average   
histof 		= histogram
buystate 	= (histogram - Buyvalue) And (Buyvalue - Shift(histogram, 1))
sellstate 	= (Sellvalue - histogram) And (Shift(histogram, 1) - Sellvalue)

stochsig.Buy 	= Signal(buystate)
stochsig.Sell 	= Signal(-sellstate)

;Compute bearx stochastic histogram
fund            = Warp(bearx, 1, 0) ;bearx  rut-i, -1, 0
Average         = 80 ;16; 68
Smooth          = 13 ;14; 22
Trigger         = 20 ;19 ;55; 27       ;same 8 to 21       ;dab chg
Buyvalue 	= 0
Sellvalue 	= 0
stoch 		= 100 * (fund - Min(fund, Average)) / (Max(fund, Average) - Min(fund, Average))
stoch 		= Ema(stoch, Smooth) 
average 	= Ema(stoch, Trigger)  
histogram	= stoch - average   
histob 		= histogram
buystate 	= (histogram - Buyvalue) And (Buyvalue - Shift(histogram, 1))
sellstate 	= (Sellvalue - histogram) And (Shift(histogram, 1) - Sellvalue)

brxsto.Buy 	= Signal(buystate)
brxsto.Sell 	= Signal(-sellstate)

;CONSTRUCT THE BASIC SIG
;--------------------
                                      
FUB.Buy	= emamacd And Not(brxsto)  Or (fusema And fuseme)

FUB.Sell	= fusemc And stochsig

FUB.Sell 	= FUB And Signal(Ema(100*nsnhq/(nsnhq+nsnlq), bt_period) - bt_level)

FUB.Sell 	= FUB Or Signal(Rsi(rsifund,rsidays) - rsistop)

WriteFile (FUB, FUB, "BASIC FUBAR SIGNAL")

;NOW THE DIFFERENT VERSIONS

;FUB1 = FUBAR WITH NEW LOW NO SELL

FUB1.Buy = FUB
FUB1.Sell = FUB And Signal(SumNL - Ema(nsnlq+$nynl, 19)) ;...dab..1/20

;FUB2 = FUBAR WITH BTCOMBO NO SELL

FUB2.Buy = FUB
FUB2.Sell = FUB And BTCOMBO

;FUB3 = FUBAR WITH NSNH0 NO SELL CONDITIONS

FUB3.Buy = FUB 
FUB3.Sell = FUB And NSNH0

FUB4.BUY = FUB
FUB4.Sell = FUB1 And BTCOMBO
FUB4.Sell = FUB4 And NSNH0	

Print (FUB, "Original FUBAR")
Print (FUB1, "FUB1:  FUB with New Low No Sell")
Print (FUB2, "FUB2:  FUB with BTCOMBO No Sell")
Print (FUB3, "FUB3:  FUB with NSNH0 No Sell")
Print (FUB4, "FUB4:  FUB with all No Sell Conditions")


WriteFile (FUB1, FUB1, "FUB WITH NEW LOW NO SELL")
WriteFile (FUB2, FUB2, "FUB WITH BTCOMBO NO SELL")
WriteFile (FUB3, FUB3, "FUB with NSNH0 No Sell")
WriteFile (FUB4, FUB4, "FUB with all No Sell Conditions")


Print(
        emamacd,                "           mmcfx EmaMacd ",
        brxsto,                 "           Bearx StochSig",
        stochsig,               "           mmcfx StochSig")

Print(NL19, "Ema19 NSNL+NYNL\nNoSell < 58",
     nl19 - Shift(nl19, 1), "1d PtChg\n",6)

Print(
"	**********************************************************************	 
	 Buy on: emamacd (mmcfx macdH) and Not(brxsto) Or (fusema And fuseme)\n
        Sell on: fusemc and mmcfx Stoch Histo And NSNH<85 Or Rsi14 of rut-i<33
	**********************************************************************"
)

Print(
	mmcfx, 						"mmcfx Price",
     	mmcfx - Shift(mmcfx, 1), 			"mmcfx PtChg\n",
     	bearx, 						"BEARX Price",
     	bearx - Shift(bearx, 1), 			"BEARX PtChg\n",
     	mhf, 						"mmcfx Macd Histogram",
	histob, 					"BEARX Stoch Histogram",
	Ema(mmcfx,fastma1) - Ema(mmcfx,slowma1), 	"FUSEMA",
	Ema(mmcfx,fastma3) - Ema(mmcfx,slowma3),	"FUSEME\n",
     	Ema(mmcfx,fastma2) - Ema(mmcfx,slowma2), 	"FUSEMC",
     	histof, 					"mmcfx Stoch Histogram\n",
        Ema(100*nsnhq/(nsnhq+nsnlq),bt_period),         "NSNHOsc, NoSell > 85\n",
        Rsi(rsifund, rsidays),                          "RUT Rsi14\nStoploss < 33\n")

[Expression]

Print ("Test with New Low No Sell")
      
[SignalPairTrade]

Delay           = 1            
Fund            = RYOTX        ;DFSCX ;FKASX ;RCMCX ;gssmx ;tavfx ;dfscx
Index           = FDRXX
Signal          = FUB1
StartDate       = 1/26/95 
FnuFile         = f01


[Expression]

Print ("Test with BTCOMBO No Sell")

[SignalPairTrade]

Delay           = 1            
Fund            = RYOTX        ;DFSCX ;FKASX ;RCMCX ;gssmx ;tavfx ;dfscx
Index           = FDRXX
Signal          = FUB2
StartDate       = 1/26/95 
FnuFile         = f02

[Expression]

Print ("Test with NSNH0 No Sell")

[SignalPairTrade]

Delay           = 1            
Fund            = RYOTX        ;DFSCX ;FKASX ;RCMCX ;gssmx ;tavfx ;dfscx
Index           = FDRXX
Signal          = FUB3
StartDate       = 1/26/95 
FnuFile         = f03


[Expression]

Print ("Test with All No Sell")

[SignalPairTrade]

Delay           = 1            
Fund            = RYOTX        ;DFSCX ;FKASX ;RCMCX ;gssmx ;tavfx ;dfscx
Index           = FDRXX
Signal          = FUB4
StartDate       = 1/26/95 
FnuFile         = f04