You can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply "select" the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose "copy" from the browser menu. The copied text can then be "pasted" into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open Web page, data can be transferred with ease.
This month's tips include formulas and programs for:
TRADESTATION: IMPLIED VOLATILITY AND VOLUMEor return to June 2003 Contents
TRADESTATION: REVERSE ENGINEERING RSI
METASTOCK: IMPLIED VOLATILITY AND VOLUME
AMIBROKER: IMPLIED VOLATILITY AND VOLUME
AMIBROKER: REVERSE ENGINEERING RSI
eSIGNAL: REVERSE ENGINEERING RSI
Wealth-Lab: IMPLIED VOLATILITY AND VOLUME
Wealth-Lab: REVERSE ENGINEERING RSI
NEUROSHELL TRADER: IMPLIED VOLATILITY AND VOLUME
NEUROSHELL TRADER: REVERSE ENGINEERING RSI
NeoTicker: IMPLIED VOLATILITY AND VOLUME
NeoTicker: REVERSE ENGINEERING RSI
TradingSolutions: IMPLIED VOLATILITY AND VOLUME
TradingSolutions: REVERSE ENGINEERING RSI
Investor/RT: REVERSE ENGINEERING RSI
SMARTrader: REVERSE ENGINEERING RSI
TRADESTATION: IMPLIED VOLALITY AND VOLUME
Scott Castleman's article in this issue, "Using Implied Volatility And Volume," describes a market-adaptive channel breakout system in which the channel lookback period is a function of implied volatility and volume. The core strategy's EasyLanguage code can be found in the sidebar of the article itself.
We have elaborated on Castleman's code by creating two new indicators. The first displays the "LookBack" calculations producing his trading "thresholds." The second plots the thresholds themselves. We have named them "Ivv Lookback" and Ivv Thresholds."
The Ivv Thresholds indicator is fairly straightforward, looking something
like a Bollinger Band or Keltner channel. The Ivv LookBack is probably
most useful as an aid for understanding how the implied volatility and
volume scheme works. The thresholds are based on a lookback window of variable
length (displayed as a magenta line; see Figure 1). The length is
a function of the Vix range (cyan line) and data1 volume range (yellow
line). The higher the Vix and volume range, the shorter the lookback for
determining the breakout threshold.
FIGURE 1: TRADESTATION, IMPLIED VOLATILITY AND VOLUME. Here's a sample TradeStation chart demonstrating the IVV Thresholds indicators. The thresholds look like channel lines. The thresholds are based on a lookback window of variable length (displayed as magenta line). The length is a function of the Vix range (cyan line) and data1 volume range (yellow line).
Indicator: IVV Lookback: inputs: RefLength1( 29 ), RefLength2( 25 ), LookBackIV( 252 ), LookBackVolume( 50 ) ; variables: DayLengthLong( 0 ), DayLengthShort( 0 ), CurrentIV( 0 ), LowestIV( 0 ), HighestIV( 0 ), AvgVolume( 0 ), LowestVolume( 0 ), HighestVolume( 0 ), NextTrade( 0 ) ; CurrentIV = Close of Data2 ; LowestIV = Lowest( Close of Data2, LookBackIV ) ; HighestIV = Highest( Close of Data2, LookBackIV ) ; AvgVolume = Average( Volume, 10 ) ; LowestVolume = Lowest( Volume, LookBackVolume ) ; HighestVolume = Highest( Volume, LookBackVolume ) ; { Perform core 'DayLengthLong' calculation for a Buy setup } If ( HighestIV - LowestIV ) <> 0 and ( HighestVolume - LowestVolume ) <> 0 then DayLengthLong = Intportion( RefLength1 - 0.5 * RefLength2 * ( ( CurrentIV - LowestIV ) / ( HighestIV - LowestIV ) + ( AvgVolume - LowestVolume ) / ( HighestVolume - LowestVolume ) ) ); If ( HighestIV - LowestIV ) <> 0 and ( HighestVolume - LowestVolume ) <> 0 then DayLengthShort = Intportion( RefLength1 - 0.5 * RefLength2 * ( (HighestIV - CurrentIV ) / ( HighestIV - LowestIV ) + ( HighestVolume - AvgVolume ) / ( HighestVolume - LowestVolume ) ) ) ; Plot1(DayLengthShort,"DLS"); Plot2((HighestIV - CurrentIV ) / ( HighestIV - LowestIV )*10,"VixRng"); Plot3(( HighestVolume - AvgVolume ) / ( HighestVolume - LowestVolume )*10,"VolRng"); Indicator: IVV Thresholds: inputs: RefLength1( 29 ), RefLength2( 25 ), LookBackIV( 252 ), LookBackVolume( 50 ) ; variables: DayLengthLong( 0 ), DayLengthShort( 0 ), CurrentIV( 0 ), LowestIV( 0 ), HighestIV( 0 ), AvgVolume( 0 ), LowestVolume( 0 ), HighestVolume( 0 ), NextTrade( 0 ) ; CurrentIV = Close of Data2 ; LowestIV = Lowest( Close of Data2, LookBackIV ) ; HighestIV = Highest( Close of Data2, LookBackIV ) ; AvgVolume = Average( Volume, 10 ) ; LowestVolume = Lowest( Volume, LookBackVolume ) ; HighestVolume = Highest( Volume, LookBackVolume ) ; If ( HighestIV - LowestIV ) <> 0 and ( HighestVolume - LowestVolume ) <> 0 then DayLengthLong = IntPortion( RefLength1 - 0.5 * RefLength2 * ( ( CurrentIV - LowestIV ) / ( HighestIV - LowestIV ) + ( AvgVolume - LowestVolume ) / ( HighestVolume - LowestVolume ) ) ); If ( HighestIV - LowestIV ) <> 0 and ( HighestVolume - LowestVolume ) <> 0 then DayLengthShort = IntPortion( RefLength1 - 0.5 * RefLength2 * ( ( HighestIV - CurrentIV ) / ( HighestIV - LowestIV ) + ( HighestVolume - AvgVolume ) / ( HighestVolume - LowestVolume ) ) ) ; Plot1( Highest( High[1], DayLengthLong ), "BuySig" ); Plot2( Lowest( Low[1], DayLengthShort ), "ShortSig" );
This strategy code will be available for download from the EasyLanguage
Exchange at TradeStationWorld.com. Look for the file "Castleman
Ivv w_Stops.eld."
--Ian MacAuslan and Mark Mills
Ian@TSSec at www.TradeStationWorld.com
MarkM@TSSEC at www.TradeStationWorld.com
EasyLanguage Questions Forums
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
TRADESTATION: REVERSE ENGINEERING RSI
Giorgos Siligardos' article in this issue, "Reverse Engineering
RSI," describes the calculation and use of a translation process
to plot the "next bar" price required to produce any given
RSI value. Here, we present the equivalent EasyLanguage code, named "RevEngRSI-Flat,"
and a modest variation plotting the equivalent price to a diagonal Rsi
trend (RevEngRSI-Diag). These two new EasyLanguage indicators are designed
to be used in tandem with the built-in TradeStation Rsi indicator.
FIGURE 2: TRADESTATION, REVERSE RSI, WEEKLY SPY. Here's a sample TradeStation chart of the weekly SPY displaying the RevEngRSI-Flat and the RevEngRSI-Diag indicators. Use these indicators with the built-in TradeStation Rsi indicator.
To plot the EasyLanguage indicators, start with a chart of any given
security. My example is a weekly chart of the Spy (Figure 2). Then:
1. Insert the TradeStation Rsi indicator into subplot 2.
2. Select the drawing tool and create a horizontal line that seems to capture the RSI's range. While you are drawing the line, you should be able to see the RSI value displayed. When you have the right line, write down the RSI value. It will be used in the next step.
3. Insert the RevEngRsi-Flat indicator and immediately go to format "inputs." Make sure the RSI length matches the plotted Rsi length. Change the "RsiValue" to the value captured from your horizontal line drawn in step 2.
4. Repeat steps 2 and 3 as many times as you like. Each time, you will get a new price plot representing the "next bar" price required to reach the desired RSI level.
If you find the RSI seems to bounce off a diagonal trend, you can
use RevEngRSI-Diag to plot the price forecast. After you have gone through
steps 1 through 4:
5. Select the "TrendLine" tool and draw a trendline from the first extreme to the last extreme on your RSI subgraph.
6. Select and hold the resulting trendline. You will get a display describing the trendline's start and endpoints (date, time and Rsi values). Write these down.
7. Insert the indicator RevEngRSI-Diag and immediately format "inputs." Make sure the RSI length is the same as your standard Rsi. Enter the start and ending values.
8. Enter the number of bars you expect the trendline to be valid after the entered trendline endpoint.
9. Repeat steps 5 through 8 as many times as you like.
Indicator: RevEngRSI-Flat inputs: RSIValue( 50 ), WilderTimePeriod( 14 ) ; variables: ExpPer( 2 * WilderTimePeriod - 1 ), AUC( 0 ), ADC( 0 ), X( 0 ), RevEngRSI( 0 ) ; AUC = XAverage( IFF( C > C[1], C - C[1], 0), ExpPer ) ; ADC = XAverage( IFF( C[1] > C, C[1] - C, 0), ExpPer ) ; X = (WilderTimePeriod - 1 ) * ( ADC * RSIValue / ( 100 - RSIValue ) - AUC ) ; RevEngRSI = IFF( X >= 0, C + X, C + X * (100-RSIValue)/RSIValue) ; Plot1[-1]( RevEngRSI ) ; Indicator: RevEngRSI-Diag inputs: WilderTimePeriod( 14 ), RSI_TL_StartDate( 1020719 ), {default Jul 19, 2002} RSI_TL_StartTime( 1515 ), RSI_TL_StartValue( 21.93 ), RSI_TL_EndDate( 1030307 ), {default Mar 7, 2003} RSI_TL_EndTime ( 1515 ), RSI_TL_EndValue( 39.12 ), AdditionalBars( 20 ) ; variables: ExpPer( 2 * WilderTimePeriod - 1 ), AUC( 0 ), ADC( 0 ), X( 0 ), RevEngRSI( 0 ), Count( 0 ), TL_RSIValue( 0 ), TL_RevEngRSI( 0 ), Slope( 0 ), OldTL_RevEngRSI( 0 ), MaxCount( 0 ) ; AUC = XAverage( IFF( C > C[1], C - C[1], 0), ExpPer ) ; ADC = XAverage( IFF( C[1] > C, C[1] - C, 0), ExpPer ) ; if Date = RSI_TL_EndDate and Time = RSI_TL_EndTime then begin Count = 0 ; while Date[Count] >= RSI_TL_StartDate and Count <100 begin Count = Count + 1 ; end; Count = Count - 1 ; MaxCount = Count + AdditionalBars ; Slope = ( RSI_TL_EndValue - RSI_TL_StartValue ) / Count ; TL_RSIValue = RSI_TL_StartValue ; X = ( WilderTimePeriod - 1 ) * ( ADC[Count] * TL_RSIValue / ( 100 - TL_RSIValue ) - AUC[Count] ) ; TL_RevEngRSI = IFF( X >= 0, C[Count] + X, C[Count] + X * ( 100 - TL_RSIValue ) / TL_RSIValue ) ; For Value1 = 1 to Count begin OldTL_RevEngRSI = TL_RevEngRSI ; TL_RSIValue = Slope * Value1 + RSI_TL_StartValue ; Value2 = Count - Value1 ; X = ( WilderTimePeriod - 1 ) * ( ADC[Value2] * TL_RSIValue / ( 100 - TL_RSIValue ) - AUC[Value2] ) ; TL_RevEngRSI = IFF( X >= 0, C[Value2] + X, C[value2]+ X * ( 100 - TL_RSIValue ) / TL_RSIValue ) ; Value99 = TL_New( Date[Value2], Time[Value2], OldTL_RevEngRSI, Date[Value2-1], Time[Value2-1], TL_RevEngRSI ) ; end ; end else if ( Date > RSI_TL_EndDate ) or ( Date = RSI_TL_EndDate and Time > RSI_TL_EndTime) and Count < MaxCount then begin Count = Count + 1 ; OldTL_RevEngRSI = TL_RevEngRSI ; TL_RSIValue = Slope * Value1 + RSI_TL_StartValue ; Value2 = Count - Value1 ; X = ( WilderTimePeriod - 1 ) * ( ADC * TL_RSIValue / ( 100 - TL_RSIValue ) - AUC ) ; TL_RevEngRSI = IFF( X >= 0, C + X, C + X * ( 100 - TL_RSIValue ) / TL_RSIValue ) ; Value99 = TL_New( Date[1], Time[1], OldTL_RevEngRSI[1], Date, Time,OldTL_RevEngRSI); end ;
This indicator code will be available for download from the EasyLanguage
Exchange on TradeStationWorld.com. Look for the file "RegEngRSI.eld".
--Mark Mills
MarkM@TSSec at www.TradeStationWorld.com
EasyLanguage Questions Forum
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
METASTOCK: IMPLIED VOLATILITY AND VOLUME
In his article "Using Implied Volatility And Volume" in
this issue, author Scott Castleman includes a trading system. Here are
the MetaStock formulas for the buy and sell short orders:
Name: Buy Order Formula: rlen1:=29; rlen2:=25; lbIV:=252; lbVol:=50; curIV:=Security(".vix",C); lowIV:=Security(".vix",LLV(C,lbIV)); hiIV:=Security(".vix",HHV(C,lbIV)); avVol:=Mov(V,10,S); lowVol:=LLV(V,lbVol); hiVol:=HHV(V,lbVol); temp1:=If(hiIV-lowIV<>0,hiIV-lowIV, -1); temp2:=If(hiVol-lowVol<>0,hiVol-lowVol, -1); dllong:=If(temp1<>-1 AND temp2<>-1, Int(rlen1-(.5*rlen2*(curIV-lowIV)/temp1)+(avVol-lowVol)/temp2),PREV); H>HHV(Ref(H,-1),LastValue(dllong+PREV-PREV)) Name: Sell Short Order Formula: rlen1:=29; rlen2:=25; lbIV:=252; lbVol:=50; curIV:=Security(".vix",C); lowIV:=Security(".vix",LLV(C,lbIV)); hiIV:=Security(".vix",HHV(C,lbIV)); avVol:=Mov(V,10,S); lowVol:=LLV(V,lbVol); hiVol:=HHV(V,lbVol); temp1:=If(hiIV-lowIV<>0,hiIV-lowIV, -1); temp2:=If(hiVol-lowVol<>0,hiVol-lowVol, -1); dlshort:=If(temp1<>-1 AND temp2<>-1, Int(rlen1-(.5*rlen2*(hiIV-curIV)/temp1)+(hiVol-avVol)/temp2),PREV); L<LLV(Ref(L,-1),LastValue(dlshort+PREV-PREV));
--William Golson
Equis International
www.equis.com
AMIBROKER: IMPLIED VOLATILITY AND VOLUME
In "Using Implied Volatility And Volume," Scott Castleman presents an interesting trading system that blends option volatility index movement with price and volume data to produce more reliable signals.
Implementing such a system is relatively easy in Afl, the language for
AmiBroker. Listing 1 shows the code that should be entered in the Automatic
Analysis formula window. We use the "Foreign" function to
reference other symbols' data. Various data vendors use different
symbols for indices. For example, "!VIX" is a symbol used
by the QuotesPlus database for SP100 implied volatility, while Yahoo! Finance
uses "^VIX." You may need to adjust the code according to
the symbol used by your data vendor.
LISTING 1 ///////////////////////////////// // Implied volatility AND Volume ///////////////////////////////// RefLength1 = 29; RefLength2 = 25; LookBackIV=252; LookBackVolume=50; // the line below should be adjusted depending on // data source you are using // !VIX is for Quotes Plus database // ^VIX is for Yahoo (AmiQuote) CurrentIV = Foreign("!VIX", "C"); LowestIV = LLV( CurrentIV, LookbackIV ); HighestIV = HHV( CurrentIV, LookbackIV ); AvgVolume = MA( Volume, 10 ); LowestVolume = LLV( Volume, LookbackVolume ); HighestVolume = HHV( Volume, LookbackVolume ); RangeIV = HighestIV - LowestIV; RangeVolume = HighestVolume - LowestVolume; DayLengthLong = int( RefLength1 - 0.5 * RefLength2 * Nz( ( CurrentIV - LowestIV )/RangeIV + ( AvgVolume - LowestVolume )/RangeVolume, 1 ) ); DayLengthShort = int( RefLength1 - 0.5 * RefLength2 * Nz( ( HighestIV - CurrentIV )/RangeIV + ( HighestVolume - AvgVolume )/RangeVolume, 1 ) ); SetTradeDelays( 1, 1, 1, 1 ); BuyPrice = SellPrice = ShortPrice = CoverPrice = Open; Buy = High > HHV( Ref( High, -1 ), DayLengthLong ); Sell = Low < LLV( Ref( Low, -1 ), DayLengthShort ); Short = Sell; Cover = Buy;
A downloadable version of the formula is available from Amibroker.com
website.
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
AMIBROKER: REVERSE ENGINEERING RSI
In "Reverse Engineering RSI" in this issue, Giorgos Siligardos
presents the inverse RSI indicator that could be used to estimate tomorrow's
price. The formula for RevEngRsi can be easily reproduced in AmiBroker
using its native Afl language. Listing 1 shows the code that plots the
RevEngRsi, with parameters Rsi value and time period overlaid on the price
chart (Figure 3).
FIGURE 3: AMIBROKER, INVERSE RSI.This AmiBroker chart shows the weekly Dow Jones Industrials Average with RSI(14) and RevEngRSI (green line) that replicates the chart presented in Siligardos' article in this issue.
LISTING 1 //////////////////////////////// // Reverse Engineer RSI //////////////////////////////// Value = Param("RSI value", 39.82, 1, 100, 0.1 ); WildPer = Param("Time periods", 14, 1, 100 ); ExpPer = 2 * WildPer - 1; AUC = EMA( Max( C - Ref( C, -1 ), 0 ), ExpPer ); ADC = EMA( Max( Ref( C, -1 ) - C, 0 ), ExpPer ); x = (WildPer - 1) * ( ADC * Value / (100-Value) - AUC); RevEngRSI = IIf( x >= 0, C + x, C + x * (100-Value)/Value ); Plot( Close, Date()+", Close ", colorBlack, styleCandle ); Plot( RevEngRSI, "Reverse Eng. RSI( "+WriteVal(WildPer,1.0)+", "+ WriteVal(Value, 1.2)+" )", colorGreen );
A downloadable version of this formula is available from AmiBroker's
website.
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
eSIGNAL: REVERSE ENGINEERING RSI
This eSignal formula is based on "Reverse Engineering RSI"
by Giorgos Siligardos in this issue. A sample eSignal chart is shown in
Figure 4.
FIGURE 4: eSIGNAL, INVERSE RSI.This eSignal chart demonstrates the reverse engineered RSI as plotted in eSignal.
/******************************************************************* Description : This Indicator plots the Reverse Engineering RSI Provided By : TS Support, LLC for eSignal (c) Copyright 2003 ********************************************************************/ function preMain(){ setPriceStudy(true); setStudyTitle("Reverse Engineering RSI"); setCursorLabelName("RSI",0); setDefaultBarFgColor(Color.red,0); } var AUC_1 = 0; var ADC_1 = 0; function main(value,WildPer){ if(value == null) value = 50; if(WildPer == null) WildPer = 14; ExpPer = 2 * WildPer - 1; K = 2 / (ExpPer + 1); if(close() > close(-1)){ AUC = K * (close() - close(-1)) + (1 - K) * AUC_1; ADC = (1 - K) * ADC_1; } else { AUC = (1 - K) * AUC_1; ADC = K * (close(-1) - close()) + (1 - K) * ADC_1; } x = (WildPer - 1) * (ADC * value / (100 - value) - AUC); if(x >= 0) RevEngRSI = close() + x; else RevEngRSI = close + x * (100 - value) / value; if (getBarState() == BARSTATE_NEWBAR){ AUC_1 = AUC; ADC_1 = ADC; } return RevEngRSI; }
--eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignal.com
Wealth-Lab: IMPLIED VOLATILITY AND VOLUME
You can replicate the implied volatility system given in Scott Castleman's
article in this issue with the following Wealth-Lab script. The script
uses Vix as the volatility index, and a sample chart is plotted for the
OEX (S&P 100) index (Figure 5). The script also plots the 10-
and 50-bar moving average of volume in the lower pane, and the trading
system equity curve below that.
FIGURE 5: Wealth-Lab, IMPLIED VOLATILITY AND VOLUME. This sample Wealth-Lab chart plots the Oex (S&P 100) index with a 10- and 50-bar moving average of volume in the lower pane, and the trading system equity curve below that.
var CURRENTIV, LOWESTIV, HIGHESTIV, AVGVOLUME, LOWESTVOLUME, HIGHESTVOLUME: float; var REFLENGTH1, REFLENGTH2, LOOKBACKIV, LOOKBACKVOLUME, IV, BAR, DAYLENGTHLONG, DAYLENGTHSHORT, VIXPANE, VPANE: integer; { System Parameters, you could optimize these } refLength1 := 29; refLength2 := 25; lookBackIV := 252; lookBackVolume := 50; { Grab Volatility Index } IV := GetExternalSeries( '^VIX', #Close ); { Trading System Rules } for Bar := lookBackIV to BarCount - 1 do begin currentIV := @IV[Bar]; lowestIV := Lowest( Bar, IV, lookBackIV ); highestIV := Highest( Bar, IV, lookBackIV ); avgVolume := SMA( Bar, #Volume, 10 ); lowestVolume := Lowest( Bar, #Volume, lookBackVolume ); highestVolume := Highest( Bar, #Volume, lookBackVolume ); if ( highestIV - lowestIV <> 0 ) and ( highestVolume - lowestVolume <> 0 ) then dayLengthLong := Trunc( refLength1 - 0.5 * refLength2 * ( ( currentIV - lowestIV ) / ( highestIV - lowestIV ) + ( avgVolume - lowestVolume ) / ( highestVolume - lowestVolume ) ) ); if ( highestIV - lowestIV <> 0 ) and ( highestVolume - lowestVolume <> 0 ) then dayLengthShort := Trunc( refLength1 - 0.5 * refLength2 * ( ( highestIV - lowestIV ) / ( highestIV - lowestIV ) + ( avgVolume - lowestVolume ) / ( highestVolume - lowestVolume ) ) ); if PriceHigh( Bar ) = Highest( Bar, #High, dayLengthLong ) then begin if MarketPosition <> 1 then begin CoverAtMarket( Bar + 1, LastPosition, '' ); BuyAtMarket( Bar + 1, '' ); end; end else if PriceLow( Bar ) = Lowest( Bar, #Low, dayLengthShort ) then begin if MarketPosition <> -1 then begin SellAtMarket( Bar + 1, LastPosition, '' ); ShortAtMarket( Bar + 1, '' ); end; end; end; { Plot Volatility Index } VIXPane := CreatePane( 125, true, true ); PlotSymbol( '^VIX', VIXPane, 020, #Candle ); DrawLabel( '^VIX', VIXPane ); { Plot Average Volume } VPane := CreatePane( 75, false, true ); PlotSeriesLabel( SMASeries( #Volume, 10 ), VPane, #Red, #Thick, '10 day SMA of Volume' ); PlotSeriesLabel( SMASeries( #Volume, 50 ), VPane, #Blue, #Thick, '50 day SMA of Volume' ); {$I 'Profit Pane (Bottom)'}
--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com
Wealth-Lab: REVERSE ENGINEERING RSI
The RevEngRsi indicator as described by Giorgos Siligardos in this issue returns the price value required for the RSI to move to a certain level on the next bar.
We have made this new indicator available as a custom indicator in Wealth-Lab Developer and on the Wealth-Lab.com website. To download the latest custom indicators into Wealth-Lab Developer, select Community/Download ChartScripts from the product's main menu.
In Figure 6, we use the RevEngRsi indicator to plot trading bands
on the chart. The upper band is the price value required for RSI to be
at the 70 (overbought) level. The lower band corresponds to an RSI value
of 30 (oversold), and the gray center line is the price level for an RSI
value of 50 (baseline).
FIGURE 6: Wealth-Lab, REVERSE RSI. The RevEngRsi indicator plots the trading bands on this sample Wealth-Lab chart. The upper band is the price value required for Rsi to be at the 70 (overbought) level. The lower band corresponds to an RSI value of 30 (oversold), and the gray center line is the price level for an RSI value of 50 (baseline). Our sample system goes long when closing prices cross below the lower band, and exits the long position when high prices touch the center band.
You can use these bands in a variety of ways. The sample script
given here goes long when closing prices cross below the lower band, and
exits the long position when high prices touch the center band.
{$I 'RevEngRSI'} var Bar: integer; { Trading System Rules} for Bar := 20 to BarCount - 1 do begin if CrossOver( Bar, #High, RevEngRSISeries( #Close, 14, 70 ) ) then SellAtMarket( Bar + 1, #All, '' ) else if CrossUnder( Bar, #Close, RevEngRSISeries( #Close, 14, 30 ) ) then BuyAtMarket( Bar + 1, '' ); end; { Plot RevEngRSI Trading Bands } PlotSeries( RevEngRSISeries( #Close, 14, 50 ), 0, #Gray, #Thick ); PlotSeries( RevEngRSISeries( #Close, 14, 70 ), 0, #Green, #Thick ); PlotSeries( RevEngRSISeries( #Close, 14, 30 ), 0, #Red, #Thick );
--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com
NEUROSHELL TRADER: IMPLIED VOLATILITY AND VOLUME
To implement in NeuroShell Trader the trading system described by Scott
Castleman in this issue, you should first create the day length indicators
in a chart, and then create a NeuroShell Trading Strategy based on those
indicators.
FIGURE 7: NEUROSHELL TRADER, Implied Volatility and Volume. Here's a sample NeuroShell Trader chart demonstrating the trading system described by Scott Castleman in this issue. We've used some custom indicators, PriceHighDynamic and PriceLowDynamic, to compute the maximum and minimum based on a dynamic lookback.
To create the day length indicators, select "New Indicator
..." from the Insert menu and use the Indicator Wizard to create
each of the following:
IV%K: Stochastic%K ( IVClose, IVClose, IVClose, 252 ) VOL%K: Stochastic%K ( Volume, Volume, Avg(Volume,10), 50) IV%K: Williams%R ( IVClose, IVClose, IVClose, 252 ) VOL%K: Williams%R ( Volume, Volume, Avg(Volume,10), 50) DAYLENGTHLONG: Subtract ( 29, Mult3 ( .005, 25, Add2 ( IV%K, VOL%K ) ) ) DAYLENGTHSHORT: Subtract ( 29, Mult3 ( .005, 25, Add2 ( IV%R, VOL%R ) ) )
To recreate the implied volatility and volume trading system, select
"New Trading Strategy ..." from the Insert menu and
enter the following long and short entry conditions in the appropriate
locations of the Trading Strategy Wizard:
Generate a buy long MARKET order if ALL of the following are true: A>B ( High, PriceHighDynamic( Lag(High,1), DAYLENGTHLONG ) Generate a sell long MARKET order if ONE of the following are true: A<B ( Low, PriceLowDynamic( Lag(Low,1), DAYLENGTHSHORT )
Note that the PriceHighDynamic and PriceLowDynamic are custom indicators
that compute the maximum and minimum based on a dynamic lookback instead
of a static lookback. If you have NeuroShell Trader Professional, you can
also choose whether the system parameters should be optimized. After backtesting
the trading strategy, use the "Detailed Analysis ..."
button to view the backtest and trade-by-trade statistics for the implied
volatility and volume system.
Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download the PriceHighDynamic and PriceLowDynamic custom indicators and a sample chart (Figure 7) that includes the implied volatility and volume trading system.
For more information on NeuroShell Trader, visit www.NeuroShell.com.
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com
NEUROSHELL TRADER: REVERSE ENGINEERING RSI
Giorgos Siligardos' reverse RSI can be easily implemented in NeuroShell Trader by combining a few of the indicators built into NeuroShell Trader. Alternatively, you may recreate it using the NeuroShell Trader's ability to call external programs. These programs may be written in C, C++, Power Basic (also Visual Basic using one of our add-on packages), and Delphi. We've recreated the reverse RSI custom indicator that you can download from the NeuroShell Trader free technical support website.
FIGURE 8: NEUROSHELL TRADER, REVERSE RSI. Here's how to add the reverse RSI to a chart using NeuroShell Trader's Indicator Wizard.
After downloading the custom indicator, you can insert it (Figure
8) by following the instructions below:
1. Select "New Indicator ..." from the Insert menu.The output from this indicator is representative of the next period's close, so if you're using daily charts, it represents tomorrow's close. (See Figure 9.)
2. Select the Custom Indicator category.
3. Select the Reverse RSI
4. Select the Future RSI Value and Wilder Time Periods as you desire.
FIGURE 9: NEUROSHELL TRADER, REVERSE RSI. Here's a sample NeuroShell Trader chart demonstrating the reverse RSI indicator using the exponential moving average and simple moving average as the future RSI value.
The NeuroShell Trader Prediction Wizard can guide you through creating
a prediction for the next value of the RSI using Ward Systems' proprietary
neural network. While using an exponential moving average or simple moving
average may be sufficient, a neural network may provide you with that extra
edge to beat the market.
After implementing the reverse RSI, you may combine it with any of our 800 built-in indicators into a chart, prediction, or trading strategy. In addition, if you decide to use this indicator in a prediction or a trading strategy, the coefficients may be optimized by the genetic algorithm built into NeuroShell Trader Professional. This can provide you with your own custom version of the reverse RSI indicator that best fits your data.
Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section
of the NeuroShell Trader free technical support website to download a copy
of the chart we built, including the reverse RSI indicator.
--Marge Sherald, Ward Systems Group, Inc.GO BACK
301 662-7950, sales@wardsystems.com
www.neuroshell.com
NeoTicker: IMPLIED VOLATILITY AND VOLUME
To implement in NeoTicker the concept presented in the article "Using
Implied Volatility And Volume" by Scott Castleman, first create
an indicator named "ivvsignal" with four integer parameters,
period 1, period 2, period Vix and period volume (Listing 1).
LISTING 1 refLength1 := param1; refLength2 := param2; lookBackIV := param3; lookBackVolume := param4; currentIV := data2.close; lowestIV := llv(data2.close, lookBackIV); highestIV := hhv(data2.close, lookBackIV); avgVolume := average(data1.v, 10); lowestVolume := llv(data1.v, lookBackVolume); highestVolume := hhv(data1.v, lookBackVolume); HLIVnonzero := (highestIV-lowestIV) <> 0; HLVolnonzero := (highestVolume-lowestVolume) <> 0; dayLengthLong := if ((HLIVnonzero > 0 and HLVolnonzero > 0), int(refLength1-0.5*refLength2*((currentIV-lowestIV)/ (highestIV-lowestIV))+ ((avgVolume-lowestVolume)/(highestVolume-lowestVolume))), 0); dayLengthShort := if ((HLIVnonzero > 0 and HLVolnonzero > 0), int(refLength1-0.5*refLength2*((highestIV-currentIV)/ (highestIV-lowestIV))+ ((highestVolume-avgVolume)/(highestVolume-lowestVolume))), 0); plot1 := dayLengthLong; plot2 := dayLengthShort;
The ivvsignal indicator returns the day long length and the day
short length. These results can be placed in the Backtest EZ indicator
to generate the trading system quickly. The long entry formula is in Listing
2 while the short entry formula is in Listing 3.
To adjust Backtest EZ to properly calculate the system performance,
change the price multiple to 500 and the minimum tick size to 0.05 to match
the Russell 2000 future contract specification.
LISTING 2 h > dhhv2(1,data1.h,data2,"ivvsignal.Plot1(0,data1,data2,29,25,252,50)") and ivvsignal.Plot1(data1,data2,29,25,252,50) > 0 LISTING 3 l < dllv2(1,data1.l,data2,"ivvsignal.plot2(0,data1,data2,29,25,252,50)") and ivvsignal.Plot2(data1,data2,29,25,252,50) > 0
Applying Backtest EZ against the daily data of the Vix and Russell
2000 continuous futures contract will generate an equity curve (Figure
10). Right-click on the Backtest EZ indicator from the popup menu,
then select Trading System> Open Performance Viewer. A new performance
viewer will open with the trading summary (Figure 11) and the annual
report (Figure 12).
FIGURE 10: NEOTICKER, IMPLIED VOLATILITY AND VOLUME. Applying Backtest EZ against the daily data of the VIX and Russell 2000 continuous future contract will generate an equity curve for the system.
FIGURE 11: NEOTICKER, IMPLIED VOLATILITY AND VOLUME. A new performance viewer will open with the trading summary for the system.
FIGURE 12: NEOTICKER, IMPLIED VOLATILITY AND VOLUME. You can display the annual report for the system in NeoTicker.
A downloadable version of this indicator is available from the Yahoo!
NeoTicker user group file area at https://groups.yahoo.com/group/neoticker/.
--Kenneth Yuen, TickQuest Inc.
www.tickquest.com
NeoTicker: REVERSE ENGINEERING RSI
To recreate in NeoTicker the RevEngRsi indicator presented in "Reverse
Engineering RSI" by Giorgos Siligardos, first use the script editor
to create a new script with the name "RevEngRsi" and two
integer parameters, Rsivalue and WildPer (Listing1).
LISTING 1 mycount := mycount+1; RSIvalue := param1; WildPer := param2; ExpPer := 2*WildPer-1; UC := if (C > C(1), (C-C(1)), 0); DC := if (C(1) > C, (C(1)-C), 0); AUC := qc_xaverage(UC, ExpPer); ADC := qc_xaverage(DC, ExpPer); x := (WildPer-1)*(ADC*(RSIvalue/(100-RSIvalue))-AUC); plot1 := if (x >= 0, C+x, C+x*((100-RSIvalue)/RSIvalue)); success1 := if (mycount > ExpPer, 1, 0);
To recreate the sample charts (Figure 13) from the article,
load the weekly chart, then add Reverse Engineering RSI onto the weekly
data. Next, add a 14-period RSI, then select the RSI as source and add
a 65-period exponential moving average onto the RSI.
FIGURE 13: NEOTICKER, REVERSE RSI. Here's a sample NeoTicker chart displaying the reverse RSI on weekly data with a 14-period RSI and a 65-period exponential moving average.
A downloadable version of the RevEngRsi is available from the Yahoo!
NeoTicker user group file area at https://groups.yahoo.com/group/neoticker/.
--Kenneth Yuen, TickQuest Inc.
www.tickquest.com
TradingSolutions: IMPLIED VOLATILITY AND VOLUME
In his article "Using Implied Volatility And Volume" in this issue, Scott Castleman presents an entry/exit system that generates entry signals based on a variable-length check of new highs/lows. The window size is based on an external volatility index and recent volume.
Using the variable-length highest and lowest functions in TradingSolutions,
this system can be implemented as follows:
Implied Volatility and Volume System Inputs: High, Low, Volume, Volatility Index, Window Maximum, Window Width, Volatility Lookback, Volume Lookback Enter Long: GT (High, HighestVL (Lag (High, 1), If (And (NE (Highest (Volatility Index, Volatility Lookback), Lowest (Volatility Index, Volatility Lookback)), NE (Highest (Volume, Volume Lookback), Lowest (Volume, Volume Lookback))), Floor (Sub (Window Maximum, Mult3 (0.5, Window Width, Add (Div (Sub (Volatility Index, Lowest (Volatility Index, Volatility Lookback)), Sub (Highest (Volatility Index, Volatility Lookback), Lowest (Volatility Index, Volatility Lookback)), Div (Sub (MA (Volume, 10), Lowest (Volume, Volume Lookback)), Sub (Highest (Volume, Volume Lookback) , Lowest (Volume, Volume Lookback))))))), 1), Window Maximum)) Enter Short: LT (Low, LowestVL (Lag (Low, 1), If (And (NE (Highest (Volatility Index, Volatility Lookback), Lowest (Volatility Index, Volatility Lookback)), NE (Highest (Volume, Volume Lookback), Lowest (Volume, Volume Lookback))), Floor (Sub (Window Maximum, Mult3 (0.5, Window Width, Add (Div (Sub (Highest (Volatility Index, Volatility Lookback), Volatility Index), Sub (Highest (Volatility Index, Volatility Lookback), Lowest (Volatility Index, Volatility Lookback)), Div (Sub (Highest (Volume, Volume Lookback), MA(Volume, 10)), Sub (Highest (Volume, Volume Lookback), Lowest (Volume, Volume Lookback))))))), 1), Window Maximum))
This system is available in a function file that can be downloaded
from the TradingSolutions website in the Solution Library section.
--Gary Geniesse, NeuroDimension, Inc.
800 634-3327, 352 377-5144
www.tradingsolutions.com
TradingSolutions: REVERSE ENGINEERING RSI
In his article "Reverse Engineering RSI" in this issue, Giorgos Siligardos presents a function that calculates the next closing price based on a prediction or approximation of the next value of the RSI. This formula can be implemented in TradingSolutions using two functions as follows:
Name: Reverse Engineered RSI Delta Short Name: RevEngRSIDelta Inputs: Close, Next RSI Value, EMA Time Periods Formula: Mult (Sub (Div (Add (EMA Time Periods,1),2),1),Sub (Div (Mult (EMA (Max (Negate (Change (Close,1)),0),EMA Time Periods),Next RSI Value),Sub (100,Next RSI Value)), EMA (Max (Change (Close,1),0),EMA Time Periods))) Name: Reverse Engineered RSI Short Name: RevEngRSI Inputs: Close, Next RSI Value, EMA Time Periods Formula: If (GE (RevEngRSIDelta (Close,Next RSI Value,EMA Time Periods),0),Add (Close, RevEngRSIDelta (Close,Next RSI Value,EMA Time Periods)),Add (Close,Mult (RevEngRSIDelta (Close,Next RSI Value,EMA Time Periods),Div (Sub (100,Next RSI Value),Next RSI Value))))
These functions are available in a function file that can be downloaded
from the TradingSolutions website in the Solution Library section. A sample
chart is in Figure 14.
FIGURE 14: TRADINGSOLUTIONS, REVERSE RSI. Here's a TradingSolutions chart displaying the RSI, a simple prediction of the RSI, the closing price, and the reverse engineered RSI value for the close.
The reverse engineered RSI also presents an alternative way to predict
the next closing price. Using the neural networks in TradingSolutions,
a prediction of the next value of the relative strength index (RSI) could
be created. That value could then be fed into the reverse engineered RSI
function to approximate the next value of the closing price. This prediction
of the closing price could then be used in entry/exit systems or as an
input to a model of the optimal signal.
--Gary Geniesse, NeuroDimension, Inc.GO BACK
800 634-3327, 352 377-5144
www.tradingsolutions.com
Investor/RT: REVERSE ENGINEERING RSI
The reverse engineered RSI can be calculated in Investor/RT using custom indicators. First, create custom indicators for both the AUC (average of up closes) and ADC (average of down closes). The syntax for these two indicators follows:
AUC:
MA((CL - CL.1) * (CL > CL.1))ADC:
MA((CL.1 - CL) * (CL < CL.1))
MA should be set up as an exponential 14-period average on the close
(the price is actually not relevant in this context, as it will be substituted
by the expression following the MA token in parenthesis). Boolean (true/false)
expressions such as (CL > CL.1) evaluate arithmetically to either 1 (true)
or zero (false) in the RTL language.
A method must now be decided on regarding how to project a value of RSI for the next bar into the future. For our example, we will predict that the RSI will be equal to the 65-period exponential moving average of the RSI. Creating a custom indicator to represent this value, we get:
RSI_PROJ:
MA(RSI)
where MA is set up as a 65-period exponential average (again, RSI
will be substituted as the price). Putting this all together, we get the
following custom indicator to represent X:
X:
13 * (ADC * (RSI_PROJ/(100 - RSI_PROJ)) - AUC)
In the previous expression and the coming expression that projects
the next closing price, the tokens ADC, RSI_PROJ, AUC, and X are all custom
indicator (CI) tokens that have been renamed to have more descriptive token
names. The expression that projects the next closing price can now be expressed
as the following custom indicator:
CL_PROJ:
((X >= 0) * (CL + X)) + ((X < 0) * (CL + (X * ((100 - RSI_PROJ) / (RSI_PROJ)))))
The resulting plot can be seen in Figure 15.
FIGURE 15: Investor/RT, REVERSE RSI. This Investor/RT daily candlestick chart shows INTC overlaid with the reverse engineered RSI line in blue. In the lower pane, the projected RSI value is drawn as a histogram.
--Chad Payne, Linn Software
800-546-6842, info@linnsoft.com
www.linnsoft.com
SMARTrader: REVERSE ENGINEERING RSI
Our approach to preparing a Traders' Tip based on "Reverse Engineering RSI" by Giorgos Siligardos was to begin as though we were going to create an RSI indicator the long way. Where practical, we have used labeling that matches the formulas in Siligardos' article.
The SmarTrader specsheet is shown in Figure 16. We started with a coef in row 9, WildPer, which will contain the period value for the calculation. Then we added another coef in row 10, value, which will contain our projected Rsi value.
FIGURE 16: SMARTRADER, REVERSE RSI SPECSHEET. Here's the SmarTrader specsheet for calculating the reverse engineered RSI.Row 11, UC, a user row, subtracts yesterday's close from today's close to derive the up-close values.
Row 12, DC, reverses the subtraction to derive the down-close values. Row 13, UpDayw, is an "if" statement to extract only the positive values from UC. Row 14, DnDayw, extracts only the positive values of DC.
Row 15, AUC, calculates the average up closes. Row 16, ADC, calculates the average down closes.
Row 17, RS, calculates the traditional RS component of Wilder's RSI. Row 18, RSI, is the traditional Wilder RSI. These two rows are not needed for the example, but since we needed RSI for the chart example, we did it the old way.
Row 19, x, is exactly the same as in the sidebar example given in Siligardos' article. Beginning in rows 20 and 21, we broke the RevEngRsi into its individual components for clarity. Finally, row 22, RevEngRsi, yields the price needed for the anticipated Rsi value.
A sample chart of the reverse engineered Rsi is shown in Figure 17.
FIGURE 17: SMARTRADER, REVERSE RSI CHART. Here is the reverse engineered RSI as described in Giorgos Siligardos' article plotted in SmarTrader.--Jim Ritter, Stratagem Software
504 885-7353, Stratagem1@aol.com
All rights reserved. © Copyright 2003, Technical Analysis, Inc.