PureBytes Links
Trading Reference Links
|
No future quotes are used. I build my own Peaks & Trofs..
I bias the porfolio BUYS with the lowest RSI.
My code for calculating SPX VIX trend (I used 2 out of 3 days). I'm
sure there is a better way. But it works here. <G>
/* Calculate the smoothed S&P and VIX */
Val1 = Optimize("AMAsmooth", 0.790, 0.73, 0.84, 0.005);
amaSPX = AMA(Foreign("^spx", "Close"), Val1);
amaVIX = AMA(Foreign("^VIX", "Close"), Val1);
/* Calculate the SPX Slope, Peaks and Trofs */
SPXPeak = IIf(amaSPX < Ref(amaSPX, -1) AND
Ref(amaSPX, -1) > Ref(amaSPX, -2),
1, 0);
SPXTrof = IIf(amaSPX > Ref(amaSPX, -1) AND
Ref(amaSPX, -1) < Ref(amaSPX, -2),
1, 0);
posSPXSlope1 = IIf(amaSPX > Ref(amaSPX, -1), 1, 0);
posSPXSlope2 = IIf(Ref(amaSPX, -1) > Ref(amaSPX, -2), 1, 0);
posSPXSlope3 = IIf(Ref(amaSPX, -2) > Ref(amaSPX, -3), 1, 0);
posSPXSlope4 = IIf(Ref(amaSPX, -3) > Ref(amaSPX, -4), 1, 0);
posSPXsum1 = posSPXSlope1 + posSPXSlope2 + posSPXSlope3;
posSPX2of3 = IIf(posSPXsum1 > 1, 1, 0);
posSPXsum2 = posSPXSlope1 + posSPXSlope2 + posSPXSlope3 + posSPXSlope4;
posSPX3of4 = IIf(posSPXsum2 > 2, 1, 0);
negSPXSlope1 = IIf(amaSPX < Ref(amaSPX, -1), 1, 0);
negSPXSlope2 = IIf(Ref(amaSPX, -1) < Ref(amaSPX, -2), 1, 0);
negSPXSlope3 = IIf(Ref(amaSPX, -2) < Ref(amaSPX, -3), 1, 0);
negSPXSlope4 = IIf(Ref(amaSPX, -3) < Ref(amaSPX, -4), 1, 0);
negSPXsum1 = negSPXSlope1 + negSPXSlope2 + negSPXSlope3;
negSPX2of3 = IIf(negSPXsum1 > 1, 1, 0);
negSPXsum2 = negSPXSlope1 + negSPXSlope2 + negSPXSlope3 + negSPXSlope4;
negSPX3of4 = IIf(negSPXsum2 > 1, 1, 0);
/* Calculate the VIX Slope, Peaks and Trofs */
VIXPeak = IIf(amaVIX < Ref(amaVIX, -1) AND
Ref(amaVIX, -1) > Ref(amaVIX, -2),
1, 0);
VIXTrof = IIf(amaVIX > Ref(amaVIX, -1) AND
Ref(amaVIX, -1) < Ref(amaVIX, -2),
1, 0);
negVIXSlope1 = IIf(amaVIX < Ref(amaVIX, -1), 1, 0);
negVIXSlope2 = IIf(Ref(amaVIX, -1) < Ref(amaVIX, -2), 1, 0);
negVIXSlope3 = IIf(Ref(amaVIX, -2) < Ref(amaVIX, -3), 1, 0);
negVIXSlope4 = IIf(Ref(amaVIX, -3) < Ref(amaVIX, -4), 1, 0);
negVIXsum1 = negVIXSlope1 + negVIXSlope2 + negVIXSlope3;
negVIX2of3 = IIf(negVIXsum1 > 1, 1, 0);
negVIXsum2 = negVIXSlope1 + negVIXSlope2 + negVIXSlope3 + negVIXSlope4;
negVIX3of4 = IIf(negVIXsum2 > 2, 1, 0);
posVIXSlope1 = IIf(amaVIX > Ref(amaVIX, -1), 1, 0);
posVIXSlope2 = IIf(Ref(amaVIX, -1) > Ref(amaVIX, -2), 1, 0);
posVIXSlope3 = IIf(Ref(amaVIX, -2) > Ref(amaVIX, -3), 1, 0);
posVIXSlope4 = IIf(Ref(amaVIX, -3) > Ref(amaVIX, -4), 1, 0);
posVIXsum1 = posVIXSlope1 + posVIXSlope2 + posVIXSlope3;
posVIX2of3 = IIf(posVIXsum1 > 1, 1, 0);
posVIXsum2 = posVIXSlope1 + posVIXSlope2 + posVIXSlope3 + posVIXSlope4;
posVIX3of4 = IIf(posVIXsum1 > 2, 1, 0);
// Then later in my code I iinclude these mktBUY - SELL conditions
with my BUY SELL indicator .
/* Calculate BUYs & SELLs */
mktBUY = IIf((SPXTrof OR posSPX2of3) AND (VIXPeak OR negVIX2of3), 1, 0 );
//Plot(mktBUY *50, "mktBUY", colorDarkGreen, 1);
mktSELL = IIf((SPXPeak OR negSPX2of3 ) AND (VIXTrof OR posVIX2of3),
1, 0 );
//Plot(mktSELL *50, "mktSELL", colorDarkRed, 1);
--- Wong <insidearb@xxxxxxxxx> wrote:
> Hi,
>
> did you check the system and make sure no future
> quotes are required? you probably have some
> portfolio
> bias in your backtest results.
>
> do you have an example of how you used the sp and
> vix
> as filter? did you use foreign()?
------------------------ Yahoo! Groups Sponsor --------------------~-->
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|