Charlton, thanks so much for your help. Is there any way to code Bollinger Bands around 2 of the codes above, the spread differential + SMA at the top of the page, and the ADX + SMA ( the 2nd one with different lengths)? I'm pretty sure the upper and lower bands would be plotted on plot 3 and 4, or 3, 4 & 5, and most of the input and variables from the Bollinger Bands code could remain the same? Here is TS's BB code:
inputs:
BollingerPrice( Close ),
TestPriceUBand( Close ),
TestPriceLBand( Close ),
Length( 20 ),
NumDevsUp( 2 ),
NumDevsDn( -2 ),
Displace( 0 ) ;
variables:
Avg( 0 ),
SDev( 0 ),
LowerBand( 0 ),
UpperBand( 0 ) ;
Avg = AverageFC( BollingerPrice, Length ) ;
SDev = StandardDev( BollingerPrice, Length, 1 ) ;
UpperBand = Avg + NumDevsUp * SDev ;
LowerBand = Avg + NumDevsDn * SDev ;
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace]( UpperBand, "UpperBand" ) ;
Plot2[Displace]( LowerBand, "LowerBand" ) ;
Plot3[Displace]( Avg, "MidLine" ) ;
end;
Thanks again for your help, everything has verified perfectly in TS.
Hello clbradley17,
Based on your request, please find the code you are requesting below. It would be best to use two pieces of code in order to differentiate the inputs of the Bollinger Bands. If you need the two indicators as one code set, please contact us and we will go ahead and provide it to you. In addition, the alerts have been set to notify you when either the ADX moving average or spread differential moving average is crossing back into the Bollinger Bands. If you need another setting, please let us know.
Bollinger Bands around spread differential moving average:
Inputs: DataSeries1( Close of data1 ), DataSeries2( Close of data2 ) ,
AvgLength( 9 ), Displace( 0 ), SDLength( 20 ), NumDevsUp( 2 ),NumDevsDn( -2 );
Vars: sprdiff(0), AvgSpread(0), LoBandSpreadSMA( 0 ), UpBandSpreadSMA( 0 ), SDev(0);
sprdiff = DataSeries1 - DataSeries2;
AvgSpread = AverageFC( sprdiff, AvgLength ) ;
SDev = StandardDev( AvgSpread, SDLength, 1 ) ;
UpBandSpreadSMA = AvgSpread + NumDevsUp * SDev ;
LoBandSpreadSMA = AvgSpread + NumDevsDn * SDev ;
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1[Displace](AvgSpread, "AvgSprd");
Plot2[Displace](UpBandSpreadSMA, "UpBandSprd");
Plot3[Displace](LoBandSpreadSMA, "LoBandSprd");
end;
{ Alert criteria }
if Displace <= 0 then
begin
if Sprdiff crosses over LoBandSpreadSMA then
Alert( "Price crossing over lower price band" )
else if SprDiff crosses under UpBandSpreadSMA then
Alert( "Price crossing under upper price band" );
end ;
Bollinger Bands around ADX moving average:
Inputs: Displace( 0 ), ADX_LEN( 14 ), SMA_LEN(9), SDLength( 20 ),
NumDevsUp( 2 ),NumDevsDn( -2 );
Vars: ADXValue(0), SMA(0), AvgSpread( 0 ),
SDev( 0 ), UpBandADXSMA(0), LoBandADXSMA(0);
ADXValue = ADX( ADX_Len ) ;
SMA = AverageFC(ADXValue, SMA_LEN);
SDev = StandardDev(SMA, SDLength, 1 ) ;
UpBandADXSMA = SMA + NumDevsUp * SDev ;
LoBandADXSMA = SMA + NumDevsDn * SDev;
if Displace >= 0 or CurrentBar > AbsValue( Displace ) then
begin
Plot1(SMA, "SMAADX");
Plot2[Displace](UpBandADXSMA, "UpBandADX");
Plot3[Displace](LoBandADXSMA, "LoBandADX");
{ Alert criteria }
if Displace <= 0 then
begin
if ADXValue crosses over LoBandADXSMA then
Alert( "Price crossing over lower price band" )
else if ADXValue crosses under UpBandADXSMA then
Alert( "Price crossing under upper price band" ) ;
end ;
end ;
I encourage you to visit the TradeStation EasyLanguage Support Forums if you have any additional EasyLanguage questions in the future. The forum is located at:
https://www.tradestation.com/Discussions/Forum.aspx?Forum_ID=213
Regards,
Alexandra Guevara
Market Technician
TradeStation Securities, Inc.
A Wholly-owned subsidiary of
TradeStation Group, Inc. (Nasdaq: TRAD)
http://www.tradestation.com