# Introduction to Functions, Indicators and Strategies

The hub of all analysis methods in Tradesignal is the available functions, indicators and strategies.

All three tools are written in Equilla Code. This is a Tradesignal-specific programming language similar to Algol or Visual Basic. No programming knowledge is necessary as long as you use the delivered functions, indicators or strategies. However, if you are interested in programming, see the Equilla Basics chapters for details.

## Tool Characteristics

### Functions

• Functions are subordinate portions of the code in which regularly used calculations and subroutines are sourced out. For example, instead of writing the code for the standard deviation again and again, the calculation is put into a function. By calling up the function by its name - and passing the relevant parameter(s) for calculation - the user receives the return value as a result.
• A function cannot be applied to a chart directly.
You can find more information in the chapter Equilla Functions.

### Indicators

• Indicators are mathematical calculations that can be applied to symbol data for technical analysis.
• Indicators can be applied to charts or other indicators, watchlists, portfolios etc.
You can find more information in the chapter Using Indicators.

### Strategies

• Strategies combine the results of indicators with certain rules and conditions for signal generation, to help setting up a sophisticated trading system.
• Strategies can be applied to charts, indicators, watchlists, portfolios etc.
You can find more information in the chapter Using Strategies.

## Example Volatility

• The function "Volatility" calculates the standard deviation from the moving average of the close price.
• The indicator "Volatility Ratio" uses the Volatility function over two different periods and then calculates the ratio of the two results. A Volatility Ratio above 0.5 signals a breakout.
• The strategy "Volatility Ratio Breakout - Exit" combines the indicator with an Ehlers filter, so that long or short positions are closed depending on the development of the volatility.

## Example Bollinger Bands

• The function "BollingerBands" calculates a simple moving average and an upper and lower standard deviation as bands.
• The indicator "Bollinger Bands" calculates and draws the resulting bands. In the property inspector of the toolbox, the parameters price (close, high...), period, and standard deviation can be edited.
• The strategy "Bollinger Lower Band - Entry" combines the results of the indicator with entry signal generation.

### Equilla Code of the BollingerBands Function

Meta:
Synopsis( "[Bollinger Bands] Calculates the Bollinger band values for the upper and lower deviation bands and the simple moving average and returns them as output parameters. Bollinger Bands are an indicator that allows users to compare volatility and relative price levels over a period time. The three calculated values are designed to encompass the majority of a security's price action. Sharp price increases or decreases (volatility) will lead to a widening of the band. Consolidation will result to a thinning of the bands." );

Inputs:
Price( NumericSeries ),
Period( NumericSimple ),
StdDevs( NumericSimple ),
RefMidBand( NumericRef ),
RefUpperBand( NumericRef ),
RefLowerBand( NumericRef );

Variables:
distance, sumSqr, i;

RefMidBand = AverageFC( Price, Period );

sumSqr = 0;
For i = 0 To Period - 1 Do
sumSqr = sumSqr + Sqr( Price[i] - RefMidBand );

If sumSqr > 0 And Period > 0 Then
distance = Sqrt( sumSqr / Period ) * StdDevs
Else
distance = 0;

RefUpperBand = RefMidBand + distance;
RefLowerBand = RefMidBand - distance;

BollingerBands = 1;

// *** www.tradesignal.com ***

### Equilla Code of the BollingerBands Indicator

Meta:
Synopsis( "Bollinger Bands are an indicator that allows users to compare volatility and relative price levels over a period time. The indicator consists of a moving average and two bands drawn two standard deviations from the average. These three bands are designed to encompass the majority of a security's price action. Sharp price increases or decreases (volatility) will lead to a widening of the band. Consolidation will result to a thinning of the bands." ),
ShortCode( "BBD" ),
SubChart( False );

Inputs:
Price( Close ),
Period( 20, 1 ),
StdDevs( 2.0, 0.0 );

Variables:
avg, lowerBand, upperBand;

BollingerBands( Price, Period, StdDevs, avg, upperBand, lowerBand );

DrawLine( avg, "Mid Line", StyleDot );
DrawArea( upperBand, lowerBand, "Upper Band", "Lower Band" );

// *** www.tradesignal.com ***

### Equilla Code of the "Bollinger Lower Band - Entry" Strategy

Meta:
Synopsis( "Generates a long entry signal when the Close crosses over the Bollinger Lower Band value, and/or generates a short entry signal when the Close crosses under the Bollinger Lower Band value. Bollinger Bands are an indicator that allows users to compare volatility and relative price levels over a period time. The indicator consists of a moving average and two bands drawn two standard deviations from the average. These three bands are designed to encompass the majority of a security's price action. Sharp price increases or decreases (volatility) will lead to a widening of the band. Consolidation will result to a thinning of the bands." );

Inputs:
Price( Close ),
Period( 20, 1 ),
StdDevs( 2.0, 0.0 ),
EntryMethod ( LongEntry, ShortEntry, Both ) = Both,
Visuals( False );

Variables:
longSig, shortSig, avg, upperBand, lowerBand;

BollingerBands( Price, Period, StdDevs, avg, upperBand, lowerBand );

longSig = ( Close Crosses Over lowerBand ) And ( EntryMethod <> ShortEntry );
shortSig = ( Close Crosses Under lowerBand ) And ( EntryMethod <> LongEntry );

If longSig Then
Buy( "BollingerLWR" ) Next Bar at Market
Else If shortSig Then
Short( "BollingerLWR" ) Next Bar at Market;

If Visuals Then
DrawLine( lowerBand, "BollingerLowerBand", StyleSolid, 2 );