TRADERS’ TIPS
For this month’s Traders’ Tips, the focus is Markos Katsanos’ article in this issue, “Trading The Fear Index.” Here, we present the August 2022 Traders’ Tips code with possible implementations in various software.
You can right-click on any chart to open it in a new tab or window and view it at it’s originally supplied size, often much larger than the version printed in the magazine.
The Traders’ Tips section is provided to help the reader implement a selected technique from an article in this issue or another recent issue. The entries here are contributed by software developers or programmers for software that is capable of customization.
In his article in this issue, “Trading The Fear Index,” author Markos Katsanos explains how the VIX (Cboe Volatility Index), often called the “fear index,” is used by traders as a measure of the 30-day expected volatility of the US stock market. While many traders use the index as a gauge of potential market movements, many ignore potential trading opportunities that the index offers. The VIX itself cannot be traded directly; however, there are instruments that offer exposure to the index, such as exchange-traded funds (ETFs). Markos Katsanos presents a set of rules for a long-short volatility trading system that attempts to capture a sizable part of the volatility spikes while also benefiting from the long-term time decay of the volatility ETFs. Two strategies are exhibited: one for long VIX ETFs and one for inverse (short) VIX ETFs.
Strategy: TASC AUG 2022 Long VIX ETF // TASC AUG 2022 // DAILY LONG-SHORT TRADING SYSTEM FOR // LONG VOLATILITY ETFs // To be applied on a daily chart // of long VIX ETFs: // VXX, VIXY, UVXY, VIXM, VXZ, SVOL // COPYRIGHT MARKOS KATSANOS 2022 inputs: VIXUPMAX( 50 ), // 40 to 60 by 5 VBARS( 6 ), // 5 to 10 by 1 STBARSL( 25 ), // 25 to 30 by 5 STBARSS( 10 ); // 10 to 15 by 5 variables: VIX( 0 ), VIXH( 0 ), VIXL( 0 ), SPY( 0 ), SPYH( 0 ), SPYL( 0 ), STOCHVS( 0 ), STVIXS( 0 ), STOCHSS( 0 ), STSPYS( 0 ), STOCHVL( 0 ), STVIXL( 0 ), STOCHSL( 0 ), STSPYL( 0 ), VIXDN( 0 ), VIXUP( 0 ), RCBARS( 0 ), RC( 0 ), BUYCONDITION( false ), SELLCONDITION( false ), SHORTCONDITION( false ), COVERCONDITION( false ); // Data2 = $VIX.X VIX = Close of Data2; VIXH = High of Data2; VIXL = Low of Data2; // Data3 = SPY SPY = Close of Data3; SPYH = High of Data3; SPYL = Low of Data3; if CurrentBar > STBARSS + 3 then begin //STOCHASTIC STOCHVS = (VIX - Lowest(VIXL, STBARSS)) / (Highest(VIXH, STBARSS) - Lowest(VIXL, STBARSS) + .0001) * 100; STVIXS = Average(STOCHVS, 3); STOCHSS = (SPY - Lowest(SPYL, STBARSS)) / (Highest(SPYH, STBARSS) - Lowest(SPYL, STBARSS) + .0001) * 100; STSPYS = Average(STOCHSS, 3); STOCHVL = (VIX - Lowest(VIXL, STBARSL)) / (Highest(VIXH, STBARSL) - Lowest(VIXL, STBARSL) + .0001) * 100; STVIXL = Average(STOCHVL, 3); STOCHSL = (SPY - Lowest(SPYL, STBARSL)) / (Highest(SPYH,STBARSL) - Lowest(SPYL, STBARSL) + .0001) * 100; STSPYL = Average(STOCHSL, 3); // VIX VIXDN = (VIX / Highest(VIX, VBARS)[1] - 1) * 100; VIXUP = (VIXH / Lowest(VIXL, VBARS)[1] - 1) * 100; // CORRELATION TREND RCBARS = VBARS - 1; RC = CoefficientR(VIX, Cum(1), RCBARS); BUYCONDITION = STVIXL > STSPYL and STVIXS > STSPYS and STVIXS> STVIXS[1] and VIXUP>VIXUPMAX and RC > .8 and RC > RC[1]; SELLCONDITION = STSPYS > STVIXS or STVIXS < STVIXS[1]; // OR VIX < Lowest(VIX, 3)[1]; // OR VIX <= Highest(VIXH, 3) - 15; SHORTCONDITION = VIX <= Lowest(VIX, 3) and VIXUP < VIXUPMAX and VIXDN < -20 and VIX > 15 and STSPYS > STVIXS and STSPYS > STSPYS[1]; COVERCONDITION = VIXUP > VIXUPMAX and STVIXS > STVIXS[1] and RC > .8; if BUYCONDITION then Buy Next Bar at Open; if SHORTCONDITION then Sell Short Next Bar at Open; if SELLCONDITION then Sell Next Bar at Open; if COVERCONDITION then Buy To Cover Next Bar at Open; end; Strategy: TASC AUG 2022 Short VIX ETF // TASC AUG 2022 // DAILY LONG-SHORT TRADING SYSTEM FOR THE // INVERSE ETF SVXY // To be applied on a daily chart of SVXY // COPYRIGHT MARKOS KATSANOS 2022 inputs: VIXUPMAX( 50 ), // 50 to 60 by 5 VBARS( 6 ), // 5 to 10 by 1 STBARSL( 25 ), // 25 to 30 by 5 STBARSS( 10 ); // 10 to 15 by 5 variables: VIX( 0 ), VIXH( 0 ), VIXL( 0 ), SPY( 0 ), SPYH( 0 ), SPYL( 0 ), STOCHVS( 0 ), STVIXS( 0 ), STOCHSS( 0 ), STSPYS( 0 ), STOCHVL( 0 ), STVIXL( 0 ), STOCHSL( 0 ), STSPYL( 0 ), VIXDN( 0 ), VIXUP( 0 ), RC( 0 ), BUYCONDITION( false ), SELLCONDITION( false ), SHORTCONDITION( false ), COVERCONDITION( false ); // Data2 = $VIX.X VIX = Close of Data2; VIXH = High of Data2; VIXL = Low of Data2; // Data3 = SPY SPY = Close of Data3; SPYH = High of Data3; SPYL = Low of Data3; if CurrentBar > STBARSS + 3 then begin //STOCHASTIC STOCHVS = (VIX - Lowest(VIXL, STBARSS)) / (Highest(VIXH, STBARSS) - Lowest(VIXL, STBARSS) + .0001) * 100; STVIXS = Average(STOCHVS, 3); STOCHSS = (SPY - Lowest(SPYL, STBARSS)) / (Highest(SPYH, STBARSS) - Lowest(SPYL, STBARSS) + .0001) * 100; STSPYS = Average(STOCHSS, 3); STOCHVL = (VIX - Lowest(VIXL, STBARSL)) / (Highest(VIXH, STBARSL) - Lowest(VIXL, STBARSL) + .0001) * 100; STVIXL = Average(STOCHVL, 3); STOCHSL = (SPY - Lowest(SPYL, STBARSL)) / (Highest(SPYH,STBARSL) - Lowest(SPYL, STBARSL) + .0001) * 100; STSPYL = Average(STOCHSL, 3); // VIX VIXDN = (VIX / Highest(VIX, VBARS)[1] - 1) * 100; VIXUP = (VIXH / Lowest(VIXL, VBARS)[1] - 1) * 100; // CORRELATION TREND RC = CoefficientR(VIX, Cum(1), VBARS - 1); SHORTCONDITION= STVIXL > STSPYL and STVIXS > STVIXS[1] and STVIXS > STSPYS and VIXUP > VIXUPMAX and RC > .8 and RC > RC[1] ; COVERCONDITION = STSPYS > STVIXS or STVIXS < STVIXS[1] ; // or VIX < Lowest(VIX, 3)[1]; // or VIX <= Highest(VIXH, 3) - 15; BUYCONDITION = VIXDN < -20 and VIX > 15 and VIX <= Lowest(VIX, 3) and STSPYS > STVIXS and STSPYS > STSPYS[1] and VIXUP < VIXUPMAX; SELLCONDITION = VIXUP > VIXUPMAX and STVIXS > STVIXS[1] and RC > .8; if BUYCONDITION then Buy Next Bar at Open; if SHORTCONDITION then Sell Short Next Bar at Open; if SELLCONDITION then Sell Next Bar at Open; if COVERCONDITION then Buy To Cover Next Bar at Open; end;
A sample chart is shown in Figure 1.
FIGURE 1: TRADESTATION. This shows an example of a TradeStation daily chart of SVXY with the short VIX ETF strategy applied. Data2 contains the VIX ($VIX.X) and Data3 contains the S&P 500 ETF SPY.
This article is for informational purposes. No type of trading or investment recommendation, advice, or strategy is being made, given, or in any manner provided by TradeStation Securities or its affiliates.
Markos Katsanos’ article in this issue, “Trading The Fear Index,” provides systems for trading VIX-based instruments. The MetaStock version of those systems are shown here. The formulas can be placed in an expert advisor, exploration, or system test in MetaStock. The suggested optimization values for a system test are in comments on the first four lines.
Buy Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); Buy:= StvixS > StspyS AND StvixF > StspyF AND StvixF > Ref(StvixF, -1) AND VixUp > VUpMax AND RC > .8 AND RC>Ref(RC, -1); sell:= StspyF > StvixF OR StvixF < Ref(StvixF,-1); ltrade:= If(buy, 1, If(sell, 0, PREV)); ltrade = 1 AND Ref(ltrade=0, -1) Sell Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); Buy:= StvixS > StspyS AND StvixF > StspyF AND StvixF > Ref(StvixF, -1) AND VixUp > VUpMax AND RC > .8 AND RC>Ref(RC, -1); sell:= StspyF > StvixF OR StvixF < Ref(StvixF,-1); ltrade:= If(buy, 1, If(sell, 0, PREV)); ltrade = 0 AND Ref(ltrade=1, -1) Sell Short Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); short:= vix<= LLV(vix,3) AND VixUp < VUpMax AND VixDn< -20 AND Vix > 15 AND StspyF>StvixF AND StspyF>Ref(StspyF, -1); cover:= VixUp > VUpMax AND StvixF > Ref(StvixF, -1) AND RC>.8; strade:= If(short, 1, If(cover, 0, PREV)); strade = 1 AND Ref(strade=0, -1) Buy to Cover Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); short:= vix<= LLV(vix,3) AND VixUp < VUpMax AND VixDn< -20 AND Vix > 15 AND StspyF>StvixF AND StspyF>Ref(StspyF, -1); cover:= VixUp > VUpMax AND StvixF > Ref(StvixF, -1) AND RC>.8; strade:= If(short, 1, If(cover, 0, PREV)); strade = 0 AND Ref(strade=1, -1)
Buy Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); Buy:= vix<= LLV(vix,3) AND VixUp < VUpMax AND VixDn< -20 AND Vix > 15 AND StspyF>StvixF AND StspyF>Ref(StspyF, -1); sell:= VixUp > VUpMax AND StvixF > Ref(StvixF, -1) AND RC>.8; ltrade:= If(buy, 1, If(sell, 0, PREV)); ltrade = 1 AND Ref(ltrade=0, -1) Sell Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); Buy:= vix<= LLV(vix,3) AND VixUp < VUpMax AND VixDn< -20 AND Vix > 15 AND StspyF>StvixF AND StspyF>Ref(StspyF, -1); sell:= VixUp > VUpMax AND StvixF > Ref(StvixF, -1) AND RC>.8; ltrade:= If(buy, 1, If(sell, 0, PREV)); ltrade = 0 AND Ref(ltrade=1, -1) Sell Short Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); short:= StvixS > StspyS AND StvixF > StspyF AND StvixF > Ref(StvixF, -1) AND VixUp > VUpMax AND RC > .8 AND RC>Ref(RC, -1); cover:= StspyF > StvixF OR StvixF < Ref(StvixF,-1); strade:= If(short, 1, If(cover, 0, PREV)); strade = 1 AND Ref(strade=0, -1) Buy to Cover Order: VUpMax:= 50; {min 40/max 60/step 5} Vbars:= 6; {min 5/max 10/step 1} StBarsSlow:= 25; {min 25/max 30/step 5} StBarsFast:= 10; {min 10/max 15/step 5} vix:= Security("ONLINE:.VIX", C); vixh:= Security("ONLINE:.VIX", H); vixl:= Security("ONLINE:.VIX", L); spy:= Security("ONLINE:SPY", C); spyh:= Security("ONLINE:SPY", H); spyl:= Security("ONLINE:SPY", L); StVixF:= Mov((vix-LLV(vixl,StBarsFast))/(HHV(vixh, StBarsFast)-LLV(vixl, StBarsFast)+.0001)*100, 3, S); StSpyF:= Mov((spy-LLV(spyl,StBarsFast))/(HHV(spyh, StBarsFast)-LLV(spyl, StBarsFast)+.0001)*100, 3, S); StVixS:= Mov((vix-LLV(vixl,StBarsSlow))/(HHV(vixh, StBarsSlow)-LLV(vixl, StBarsSlow)+.0001)*100, 3, S); StSpyS:= Mov((spy-LLV(spyl,StBarsSlow))/(HHV(spyh, StBarsSlow)-LLV(spyl, StBarsSlow)+.0001)*100, 3, S); VixDn:= (vix/Ref(HHV(vix,vbars),-1)-1)*100; VixUp:= (vixh/Ref(LLV(vixl,vbars),-1)-1)*100; RC:= Correl( vix, Cum(1), vbars-1, 0 ); short:= StvixS > StspyS AND StvixF > StspyF AND StvixF > Ref(StvixF, -1) AND VixUp > VUpMax AND RC > .8 AND RC>Ref(RC, -1); cover:= StspyF > StvixF OR StvixF < Ref(StvixF,-1); strade:= If(short, 1, If(cover, 0, PREV)); strade = 0 AND Ref(strade=1, -1)
We have prepared C# code for Markos Katsanos’ daily long-short trading system for long volatility ETFs and for his daily long-short trading system for the inverse ETF for the benefit of Wealth-Lab 8 users. For details and description of the author’s trading systems, see the article in this issue, “Trading The Fear Index.”
Long-Short trading system for long volatility ETFs using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Linq; using WealthLab.TASC; namespace WealthScript2 { public class LongShortVolaETF : UserStrategyBase { public LongShortVolaETF() : base() { AddParameter("VIX up max", ParameterType.Int32, 50, 40, 60, 5); AddParameter("Period for VIX Up/Down & RC", ParameterType.Int32, 6, 5, 10, 1); AddParameter("Slow Stoch period", ParameterType.Int32, 25, 25, 30, 5); AddParameter("Fast Stoch period", ParameterType.Int32, 10, 10, 15, 5); } public override void Initialize(BarHistory bars) { vixUpMax = Parameters[0].AsInt; vBars = Parameters[1].AsInt; stBarsL = Parameters[2].AsInt; stBarsS = Parameters[3].AsInt; /* obtain the external symbols data */ vix = GetHistory(bars, "^VIX"); spy = GetHistory(bars, "SPY"); /* Stochastic */ stochVs = StochK.Series(vix, stBarsS); stVixS = SMA.Series(stochVs, 3); stochSs = StochK.Series(spy, stBarsS); stSpyS = SMA.Series(stochSs, 3); stochVl = StochK.Series(vix, stBarsL); stVixL = SMA.Series(stochVl, 3); stochSl = StochK.Series(spy, stBarsL); stSpyL = SMA.Series(stochSl, 3); /* VIX */ vixDn = ((vix.Close / Highest.Series(vix.Close, vBars) >> 1) - 1) * 100; vixUp = ((vix.High / Lowest.Series(vix.Low, vBars) >> 1) - 1) * 100; /* Correlation Trend */ int RCBARS = vBars - 1; RC = CorrelationTrend.Series(vix.Close, RCBARS); RC1 = CorrelationTrend.Series(bars.Close, RCBARS); PlotBarHistoryStyle( vix, "^vix", "VIX"); PlotTimeSeriesLine( stochVs, "stochVs", "vix", WLColor.Red); PlotTimeSeriesLine( stochVl, "stochVl", "vix", WLColor.Blue); PlotTimeSeriesLine( stochSs, "stochSs", "spy", WLColor.Red); PlotTimeSeriesLine( stochSl, "stochSl", "spy", WLColor.Blue); } public override void Execute( BarHistory bars, int idx) { if (idx > 0) { /* LONG */ bool buy = stVixL[idx] > stSpyL[idx] && stVixS[idx] > stSpyS[idx] && stVixS[idx] > stVixS[idx - 1] && vixUp[idx] > vixUpMax && RC[idx] > 0.8 && RC[idx] > RC[idx -1]; bool sell = stSpyS[idx] > stVixS[idx] || stVixS[idx] < stVixS[idx - 1]; /* SHORT */ bool _short = vix.Close[idx] <= Lowest.Series( vix.Close, 3)[idx] && vixUp[idx] < vixUpMax && vixDn[idx] < -20 && vix.Close[idx] > 15 && stSpyS[idx] > stVixS[idx] && stSpyS[idx] > stSpyS[idx - 1]; bool cover = vixUp[idx] > vixUpMax && stVixS[idx] > stVixS[idx -1] && RC[idx] > 0.8; if (GetPositions().Where(p => p.IsOpen == true).Count() == 0) { if (buy) PlaceTrade( bars, TransactionType.Buy, OrderType.Market); else if (_short) PlaceTrade( bars, TransactionType.Short, OrderType.Market); } else { if( (sell && LastOpenPosition.PositionType == PositionType.Long) || (cover && LastOpenPosition.PositionType == PositionType.Short) ) ClosePosition( LastPosition, OrderType.Market); } } } BarHistory vix, spy; TimeSeries vixDn, vixUp, stochVs, stVixS, stochSs, stSpyS, stochVl, stVixL, stochSl, stSpyL, RC, RC1; int vBars = 6, vixUpMax = 25, stBarsS = 10, stBarsL = 25; } } Long-Short trading system for the inverse ETF SVXY using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Linq; using WealthLab.TASC; namespace WealthScript1 { public class InverseETF : UserStrategyBase { public InverseETF() : base() { AddParameter("VIX up max", ParameterType.Int32, 50, 50, 60, 5); AddParameter("Period for VIX Up/Down & RC", ParameterType.Int32, 6, 5, 10, 1); AddParameter("Slow Stoch period", ParameterType.Int32, 25, 25, 30, 5); AddParameter("Fast Stoch period", ParameterType.Int32, 10, 10, 10, 5); } public override void Initialize(BarHistory bars) { vixUpMax = Parameters[0].AsInt; vBars = Parameters[1].AsInt; stBarsL = Parameters[2].AsInt; stBarsS = Parameters[3].AsInt; /* obtain the external symbols data */ vix = GetHistory( bars, "^VIX"); spy = GetHistory( bars, "SPY"); /* Stochastic */ stochVs = StochK.Series(vix, stBarsS); stVixS = SMA.Series(stochVs, 3); stochSs = StochK.Series(spy, stBarsS); stSpyS = SMA.Series(stochSs, 3); stochVl = StochK.Series(vix, stBarsL); stVixL = SMA.Series(stochVl, 3); stochSl = StochK.Series(spy, stBarsL); stSpyL = SMA.Series(stochSl, 3); /* VIX */ vixDn = ((vix.Close / Highest.Series(vix.Close, vBars) >> 1) - 1) * 100; vixUp = ((vix.High / Lowest.Series(vix.Low, vBars) >> 1) - 1) * 100; /* Correlation Trend */ int RCBARS = vBars - 1; RC = CorrelationTrend.Series(vix.Close, RCBARS); PlotBarHistoryStyle( vix, "^vix", "VIX"); PlotTimeSeriesLine( stochVs, "stochVs", "vix", WLColor.Red); PlotTimeSeriesLine( stochVl, "stochVl", "vix", WLColor.Blue); PlotTimeSeriesLine( stochSs, "stochSs", "spy", WLColor.Red); PlotTimeSeriesLine( stochSl, "stochSl", "spy", WLColor.Blue); } public override void Execute( BarHistory bars, int idx) { if (idx > 0) { /* SHORT */ bool _short = stVixL[idx] > stSpyL[idx] && stVixS[idx] > stVixS[idx-1] && stVixS[idx] > stSpyS[idx] && vixUp[idx] > vixUpMax && RC[idx] > 0.8 && RC[idx] > RC[idx -1]; bool cover = stSpyS[idx] > stVixS[idx] || stVixS[idx] < stVixS[idx - 1]; /* LONG */ bool buy = vix.Close[idx] <= Lowest.Series( vix.Close, 3)[idx] && vixUp[idx] < vixUpMax && vixDn[idx] < -20 && vix.Close[idx] > 15 && stSpyS[idx] > stVixS[idx] && stSpyS[idx] > stSpyS[idx - 1]; bool sell = vixUp[idx] > vixUpMax && stVixS[idx] > stVixS[idx - 1] && RC[idx] > 0.8; if (GetPositions().Where(p => p.IsOpen == true).Count() == 0) { if (buy) PlaceTrade( bars, TransactionType.Buy, OrderType.Market); else if (_short) PlaceTrade( bars, TransactionType.Short, OrderType.Market); } else { if( (sell && LastOpenPosition.PositionType == PositionType.Long) || (cover && LastOpenPosition.PositionType == PositionType.Short) ) ClosePosition( LastPosition, OrderType.Market); } } } BarHistory vix, spy; TimeSeries vixDn, vixUp, stochVs, stVixS, stochSs, stSpyS, stochVl, stVixL, stochSl, stSpyL, RC, RC1; int vBars = 6, vixUpMax = 25, stBarsS = 10, stBarsL = 25; } }
FIGURE 2: WEALTH-LAB. This shows sample trades of the inverse ETF system on a chart of SVXY in Wealth-Lab 8.
The DailyVolatilityETF strategies, as detailed in Markos Katsanos’ article in this issue, “Trading The Fear Index,” are available for download at the following links for NinjaTrader 8 and for NinjaTrader 7:
Once the file is downloaded, you can import it into NinjaTader 8 from within the control center by selecting Tools → Import → NinjaScript Add-On and then selecting the downloaded file for NinjaTrader 8. To import into NinjaTrader 7, from within the control center window, select the menu File → Utilities → Import NinjaScript and select the downloaded file.
You can review the strategy’s source code in NinjaTrader 8 by selecting the menu New → NinjaScript Editor → Strategies from within the control center window and selecting the DailyVolatilityETFLong or DailyVolatilityETFShort file. You can review the strategy’s source code in NinjaTrader 7 by selecting the menu Tools → Edit NinjaScript → Strategy from within the control center window and selecting the DailyVolatilityETFLong or DailyVolatilityETFShort file.
A NinjaTrader chart displaying an example of the long strategy is shown in Figure 3.
FIGURE 3: NINJATRADER. The DailyVolatilityETFLong strategy is shown applied to a daily VIXY chart from January 2015 to June 2016.
NinjaScript uses compiled DLLs that run native, not interpreted, to provide you with the highest performance possible.
The VIX ETF trading systems presented in Markos Katsanos’ article in this issue, “Trading The Fear Index,” can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader’s 800+ indicators into two trading systems. To implement the VIX ETF trading system, select “New strategy…” from the insert menu and use NeuroShell’s trading strategy wizard to create the following strategy:
BUY LONG CONDITIONS: [All of which must be true] A>B(Avg(Stoch%K(High,Low,Close,25),3),Avg(Stoch%K(SPY High, SPY Low, SPY Close,25),3)) A>B(Avg(Stoch%K(High,Low,Close,10),3),Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3)) A>B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0) A>B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) A>B(LinTimeReg r(Close,5),0.8) A>B(Momentum(LinTimeReg r(Close,5),1),0) SELL LONG CONDITIONS: [1 of which must be true] A>B(Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3),Avg(Stoch%K(High,Low,Close,10),3)) A<B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0) SELL SHORT CONDITIONS: [All of which must be true] A<=B(Close,PriceLow(Low,3)) A<B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) A<B(Mul2(Sub(Divide(Close,Lag(PriceHigh(High,6),1)),1),100),-20) A>B(Close,15) A>B(Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3),Avg(Stoch%K(High,Low,Close,10),3)) A>B(Momentum(Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3),1),0) COVER SHORT CONDITIONS: [All of which must be true] A>B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) A>B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0) A>B(LinTimeReg r(Close,5),0.8)
To implement the short VIX trading system, select “New strategy…” from the insert menu and use NeuroShell’s trading strategy wizard to create the following strategy:
BUY LONG CONDITIONS: [All of which must be true] A<B(Mul2(Sub(Divide(Close,Lag(PriceHigh(High,6),1)),1),100),-20) A>B(Close,15) A<=B(Close,PriceLow(Low,3)) A>B(Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3),Avg(Stoch%K(High,Low,Close,10),3)) A<B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) SELL LONG CONDITIONS: [All of which must be true] A>B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) A>B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0) A>B(LinTimeReg r(Close,5),0.8) SELL SHORT CONDITIONS: [All of which must be true] A>B(Avg(Stoch%K(High,Low,Close,25),3),Avg(Stoch%K(SPY High, SPY Low, SPY Close,25),3)) A>B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0) A>B(Avg(Stoch%K(High,Low,Close,10),3),Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3)) A>B(Mul2(Sub(Divide(Close,Lag(PriceLow(Low,6),1)),1),100),50) A>B(LinTimeReg r(Close,5),0.8) A>B(Momentum(LinTimeReg r(Close,5),1),0) COVER SHORT CONDITIONS: [1 of which must be true] A>B(Avg(Stoch%K(SPY High, SPY Low, SPY Close,10),3),Avg(Stoch%K(High,Low,Close,10),3)) A<B(Momentum(Avg(Stoch%K(High,Low,Close,10),3),1),0)
Users of NeuroShell Trader can go to the Stocks & Commodities section of the NeuroShell Trader free technical support website to download a copy of this or any previous Traders’ Tips.
FIGURE 4: NEUROSHELL TRADER. This shows the VIX trading systems in NeuroShell Trader.
Here is Pine Script code for the TradingView platform that implements the trading strategies described in Markos Katsanos’s article in this issue, “Trading The Fear Index.”
// TASC Issue: August 2022 - Vol. 40, Issue 9 // Article: Trading The Fear Index // There Is Nothing To Fear But Fear Itself // Article By: Markos Katsanos // Language: TradingView's Pine Script v5 // Provided By: PineCoders, for tradingview.com // @version=5 strategy('TASC 2022.08 Trading The Fear Index', 'TTFI', false, default_qty_type= strategy.percent_of_equity, commission_type= strategy.commission.percent, currency=currency.USD, initial_capital=10000, default_qty_value=100, commission_value=0.01) chl() => [close, high, low] isntVixETF() => var VIX_ETFs = array.from('VXX', 'VIXY', 'UVXY', 'VIXM', 'VXZ', 'SVOL', 'SVXY') var notVETF = not array.includes(VIX_ETFs, syminfo.ticker) notVETF if isntVixETF() runtime.error('ERR: This is only intended for VIX ETFs '+ '(tickers: VXX, VIXY, UVXY, VIXM, VXZ, SVOL, and SVXY)') var SC = 'Strategy Configurations' directiv = input.string( 'Long/Short', 'Direction(s) Allowed', options=['Long Only', 'Long/Short', 'Short Only'], group=SC) strtTime = input.time(timestamp('2020-01-01'), 'Start Time:', inline='sTime', group=SC) startON = input(true, '', 'Start time of observation window.' +' The checkbox enables/disables the Start Time','sTime', SC) endTime = input.time(timestamp('2022-01-01'), ' End Time:', inline='eTime', group=SC) lapseON = input(true, '', 'Lapse Time of observation window.' +' The checkbox enables/disables the End Time', 'eTime', SC) showAlgo = input.string('STVIXS/STVIXL', 'Display Indicators', options= ['STVIXS/STVIXL', 'STSPYS/STSPYL', 'STVIXL/STSPYL', 'STVIXS/STSPYS', 'VIXUP/VIXDN', 'RC', 'VIX']) var SIA = 'Stochastic Indicator Adjustments' STBARSS = input.int(10, 'Fast Period', 10, 15, 5, group=SIA) STBARSL = input.int(25, 'Slow Period', 25, 30, 5, group=SIA) var VIA = 'Adjustments for VIX Indicators' vixIndex = input.string('CBOE:VIX', 'Select Volatility Index', options=['CBOE:VIX', 'TVC:VIX'], group=VIA) VBARS = input.int( 6, 'VIX Period', 5, 10, 1, group=VIA) VIXUPMAX = input.int(50, 'VIX Threshold',40, 60, 1, group=VIA) var TP = 'Table Preferences' showTable = input.bool(true, 'Display Data Table', group=TP) tableRegion = input.string( position.middle_center, group=TP, tooltip='Optimize Your View', title='Table Positioning', options=[ position.bottom_left, position.bottom_center, position.middle_left, position.middle_center, position.top_left, position.top_center ]) var TFP = timeframe.period [VIX, VIXH, VIXL] = request.security(vixIndex, TFP, chl()) [SPY, SPYH, SPYL] = request.security( 'SPY', TFP, chl()) STVIXS = ta.sma(ta.stoch(VIX, VIXH, VIXL, STBARSS), 3) STSPYS = ta.sma(ta.stoch(SPY, SPYH, SPYL, STBARSS), 3) STVIXL = ta.sma(ta.stoch(VIX, VIXH, VIXL, STBARSL), 3) STSPYL = ta.sma(ta.stoch(SPY, SPYH, SPYL, STBARSL), 3) VIXUP = (VIXH / ta.lowest(VIXL, VBARS)[1] - 1.0) * 100.0 VIXDN = ( VIX / ta.highest( VIX, VBARS)[1] - 1.0) * 100.0 RC = ta.correlation(VIX, bar_index, VBARS-1) plot(showAlgo=='STVIXS/STVIXL' ? STVIXS : na, '', #FF0000) plot(showAlgo=='STVIXS/STVIXL' ? STVIXL : na, '', #0080FF) plot(showAlgo=='STSPYS/STSPYL' ? STSPYS : na, '', #550000, 2) plot(showAlgo=='STSPYS/STSPYL' ? STSPYL : na, '', #003060, 2) plot(showAlgo=='STVIXS/STSPYS' ? STVIXS : na, '', #FF0000) plot(showAlgo=='STVIXS/STSPYS' ? STSPYS : na, '', #550000, 2) plot(showAlgo=='STVIXL/STSPYL' ? STVIXL : na, '', #0080FF) plot(showAlgo=='STVIXL/STSPYL' ? STSPYL : na, '', #003060, 2) plot( showAlgo=='VIXUP/VIXDN' ? VIXUP : na, '', #FF8000) plot( showAlgo=='VIXUP/VIXDN' ? VIXDN : na, '', #550055, 2) hline(showAlgo=='VIXUP/VIXDN' ? VIXUPMAX : na, '', #804000) hline(showAlgo=='VIXUP/VIXDN' ? -20 : na, '', #550055) plot( showAlgo=='RC' ? RC : na, '', #FF40FF) hline(showAlgo=='RC' ? 0.8 : na) plot( showAlgo=='VIX' ? VIX : na, '', #FFCC00, 2) hline(showAlgo=='VIX' ? 15 : na) BUY = VIXUP > VIXUPMAX and STVIXL > STSPYL and STVIXS > STVIXS[1] and STVIXS > STSPYS and bar_index > STBARSL + 3 and RC > RC[1] and RC > 0.8 SELL = STVIXS < STVIXS[1] or STSPYS > STVIXS COVER = STVIXS > STVIXS[1] and VIXUP > VIXUPMAX and RC > 0.8 SHORT = STSPYS > STSPYS[1] and VIXUP < VIXUPMAX and bar_index > STBARSS + 3 and STSPYS > STVIXS and VIX > 15 and VIXDN < -20 and VIX <= ta.lowest(VIX, 3) if syminfo.ticker == 'SVXY' temp = SHORT, SHORT := BUY, BUY := temp temp := COVER, COVER := SELL, SELL := temp strategyMode = switch directiv 'Long/Short' => strategy.direction.all 'Short Only' => strategy.direction.short => strategy.direction.long strategy.risk.allow_entry_in(strategyMode) withinStrategyObservationWindow = if startON time>=strtTime and (lapseON ? time<=endTime : true) else lapseON ? time<=endTime : true if withinStrategyObservationWindow and strategy.equity > 0.0 if strategy.opentrades == 0 if BUY strategy.entry('LONG\nENTRY', strategy.long) else if SHORT strategy.entry('SHORT\nENTRY', strategy.short) else if not (directiv == 'Long Only') if strategy.position_size > 0.0 and SHORT strategy.entry('SHORT', strategy.short) else if strategy.position_size < 0.0 and COVER strategy.entry('COVER', strategy.long) else if SELL strategy.close('ENTRY', comment='EXIT') else if strategy.opentrades > 0 strategy.close_all(comment='Strategy\nWindow\nElapsed') var string[] aLabels = array.from( 'Ticker ID:', 'Bar Index:', ' High:', 'Close:', 'Open:', 'Low:', 'VIX:', 'VIXH:', 'STVIXS:','STSPYS:', 'STVIXL:', 'STSPYL:', 'RC:', 'VIXUP%:', 'VIXDN%:', 'BUY:', 'SELL:','SHORT:', 'COVER:') var tDT = table.new(tableRegion, 2, 19, #000000DD, #4499FF, 1) if showTable and bar_index >= last_bar_index - 1 var TICKER_ID = syminfo.prefix + ':' + syminfo.ticker var color odd = #FFFFFF0b string[] aValues = array.from(TICKER_ID, str.tostring(bar_index), str.tostring(high ), str.tostring(close), str.tostring( open), str.tostring( low ), str.tostring( VIX ), str.tostring( VIXH), str.tostring(STVIXS, '.00'), str.tostring(STSPYS, '.00'), str.tostring(STVIXL, '.00'), str.tostring(STSPYL, '.00'), str.tostring( RC, '.00'), str.tostring( VIXUP, '.00'), str.tostring( VIXDN, '.00'), str.tostring( BUY ), str.tostring( SELL), str.tostring(SHORT), str.tostring(COVER)) for _i=0 to array.size(aLabels)-1 table.cell( tDT, 0, _i, array.get( aLabels, _i), 0, 0, #4499FF, text.align_right, bgcolor=_i % 2 ? na : odd) table.cell( tDT, 1, _i, array.get( aValues, _i), 0, 0, #FFFFFF, text.align_center,bgcolor=_i % 2 ? na : odd)
The code is available on TradingView in the PineCodersTASC account: https://www.tradingview.com/u/PineCodersTASC/#published-scripts
An example chart is shown in Figure 5.
FIGURE 5: TRADINGVIEW. This shows sample trading signals for Markos Katsanos’ VIX trading system in TradingView.
The importable AIQ EDS file based on Markos Katsanos’ article in this issue, “Trading The Fear Index” and the “CUM1.csv” file can be obtained on request via email to info@TradersEdgeSystems.com. Code for the author’s system is set up in the AIQ code file.
! VIX ETF SYSTEM ! This should be applied only to long VIX ETF. ! VIX ETF DAILY LONG-SHORT TRADING SYSTEM ! COPYRIGHT MARKOS KATSANOS 2022 ! To be applied on a daily chart of long VIX ETFs: ! VXX,VIXY,UVXY,VIXM,VXZ,SVOL ! INPUTS: C is [close]. H is [high]. L is [low]. VIXUPMAX is 50. ! VIX UP% MAX VBARS is 6. ! Number of bars to calculate VIXUP,VIXDN & RC STBARSL is 25. ! Number of bars to calculate slow stochastic STBARSS is 10. ! Number of bars to calculate fast stochastic ! COMPARISON INDEX VIXC is TickerUDF("VIX",C). VIXH is TickerUDF("VIX",H). VIXL is TickerUDF("VIX",L). SPYC is TickerUDF("SPY",C). SPYH is TickerUDF("SPY",H). SPYL is TickerUDF("SPY",L). ! STOCHASTIC STOCHVS is (VIXC-lowresult(VIXL,STBARSS))/(highresult(VIXH, STBARSS)-lowresult(VIXL, STBARSS)+0.0001)*100. STVIXS is simpleavg(STOCHVS,3). STOCHSS is (SPYC-lowresult(SPYL,STBARSS))/(highresult(SPYH,STBARSS)-lowresult(SPYL,STBARSS)+0.0001)*100. STSPYS is simpleavg(STOCHSS,3). STOCHVL is (VIXC-lowresult(VIXL,STBARSL))/(highresult(VIXH,STBARSL)-lowresult(VIXL,STBARSL)+0.0001)*100. STVIXL is simpleavg(STOCHVL,3). STOCHSL is (SPYC-lowresult(SPYL,STBARSL))/(highresult(SPYH,STBARSL)-lowresult(SPYL,STBARSL)+0.0001)*100. STSPYL is simpleavg(STOCHSL,3). !VIX VIXDN is (VIXC/valresult(highresult(VIXC,VBARS),1)-1)*100. VIXUP is (VIXH/valresult(lowresult(VIXL,VBARS),1)-1)*100. ! CORRELATION TREND PeriodToTest is VBARS-1. !****CUM1 is a custom ticker from DTU import of a CSV file*************** !*************CUM1 file is required for this system to work****************** ! PEARSON CORRELATION ValIndex is TickerUDF("VIX", [close]). ValTkr is TickerUDF("CUM1", [close]). SumXSquared is Sum(Power(ValIndex,2), PeriodToTest). SumX is Sum(ValIndex, PeriodToTest). SumYSquared is Sum(Power(ValTkr,2), PeriodToTest). SumY is Sum(ValTkr, PeriodToTest). SumXY is Sum(ValTkr*ValIndex, PeriodToTest). SP is SumXY - ( (SumX * SumY) / PeriodToTest ). SSx is SumXSquared - ( (SumX * SumX) / PeriodToTest ). SSy is SumYSquared - ( (SumY * SumY) / PeriodToTest ). RC is SP/SQRT(SSx*SSy). !LONG BR1 if HasDataFor(STBARSL+10)>STBARSL+3. BR2 if STVIXL>STSPYL . BR3 if STVIXS>STSPYS. BR4 if STVIXS>valresult(STVIXS,1). BR5 if VIXUP>VIXUPMAX. BR6 if RC>0.8. BR7 if RC>valresult(RC,1). BUY if BR1 and BR2 and BR3 and BR4 and BR5 and BR6 and BR7. SR1 is STSPYS>STVIXS. SR2 is STVIXS<valresult(STVIXS,1). SELL if SR1 or SR2. !SHORT SS1 if HasDataFor(STBARSS+10)>STBARSS+3. SS2 if VIXC<= lowresult(VIXC,3). SS3 if VIXUP<VIXUPMAX. SS4 if VIXDN<-20. SS5 if VIXC>15. SS6 if STSPYS>STVIXS. SS7 if STSPYS>valresult(STSPYS,1). SHORT if SS1 and SS2 and SS3 and SS4 and SS5 and SS6 and SS7. CR1 if VIXUP>VIXUPMAX. CR2 if STVIXS>valresult(STVIXS,1). CR3 if RC>0.8. COVER if CR1 and CR2 and CR3. TEST if 1=1.
Figure 6 shows the CUM1.csv file that must be created in Excel and then imported using the DTU utility to a new index ticker called “CUM1.” The file increments one unit, like an index, for each trading day starting on 10/1/2003 and continues to the current date. This file would have to be updated manually via the data manager function.
FIGURE 6: AIQ SYSTEMS. This shows the portion of the CUM1.csv file that must be created in Excel.
Figure 7 shows a summary EDS backtest of the system using the VXX and VXZ from 6/21/2018 to 6/21/2022.
FIGURE 7: AIQ SYSTEMS. This shows a summary EDS backtest of the system using the VXX and VXZ from 6/21/2018 to 6/21/2022.