Trade Smarter with Automation

Charts and Indicators

This document will cover using charts and indicators in Alta5. It assumes the reader has basic programming skills and has reviewed the Strategy Basics guide.

Chart Workers

All charts used by strategies in Alta5 are created and maintained by a chart worker. There are two types of chart workers available in Alta5, historical and intraday.

Historical

Historical charts are available to perform technical analysis on a security's past performance. Historical charts are created using a chart worker. The chart worker is responsible for creating the Chart and loading/synchronizing any required historical data.

Settings

The following settings are available to setup the chart worker:

id
String
The id of the chart worker. The chart created by the worker is available in the strategy as data.id. Also used with this.workers.get(id) to get a reference to the chart worker in your Trader.
indicators
Array
An array of objects with indicator configurations for this chart.

See Indicators below for more information.

interval
String= DAILY
The duration of the bars in the Chart. Chart.Interval.MINUTE Chart.Interval.MINUTE_5 Chart.Interval.MINUTE_10 Chart.Interval.MINUTE_15 Chart.Interval.MINUTE_30 Chart.Interval.DAILY Chart.Interval.DAILY
periodCount
Number
The number of periodType to include in this chart. For example, periodCount:30 and periodType:Chart.Period.DAY would include 30 days of data.

The maximum period count for a chart with a minute interval is 5 days.

If periodType is: Chart.Period.DAY:  1, 2, 3, 4, 5 or 10 Chart.Period.MONTH:  1, 2, 3 or 6
periodType
String
Used with periodCount to determine the period the chart will include. For example, periodCount:30 and periodType:Chart.Period.DAY would include 30 days of data. Chart.Period.DAY Chart.Period.MONTH
security
String
The symbol of the security for this chart. By default, bound to the target symbol. $target

Example


workers: [{
    type: 'chart',
    id: 'dailyChart',               // unique id
    security: '$target',
    member: 'dailyChart',           // access as this.dailyChart

    periodType: Chart.Period.DAY,   // 30 days
    periodCount: 30,

    interval: Chart.Interval.DAILY  // daily bars
}]

Intraday

Intraday streaming charts are available to perform intraday technical analysis on a security. Intraday charts are created using a ichart worker. The ichart worker is responsible for creating the Chart and keeping it updated as new bars are available. Intraday charts are only available for the current day.

Settings

The following settings are available to setup the ichart worker:

id
String
The id of the ichart worker. The chart created by the worker is available in the strategy as data.id. Also used with this.workers.get(id) to get a reference to the ichart worker in your Trader.
indicators
Array
An array of objects with indicator configurations for this chart.

See Indicators below for more information.

interval
String= MINUTE
The duration of the bars in the Chart. Chart.Interval.MINUTE Chart.Interval.MINUTE_5 Chart.Interval.MINUTE_10 Chart.Interval.MINUTE_15 Chart.Interval.MINUTE_30 Chart.Interval.MINUTE
manageOnNewBar
boolean= true
If true, the onManage function of the strategy will only be called 1 time for each new bar in the chart. true
minBars
Number= 0
The minimum number of bars the chart must have before this chart is ready and indicators are ready to be calculated. For example, if you had a chart with a MACD indicator that had a slowPeriod of 26 bars, then minBars should be set to 26. 0
security
String= '$target'
The symbol of the security for this chart. By default, bound to the target symbol for the Trader using the strategy. $target
seekOnNewBar
boolean= true
If true, the onSeek function of the strategy will only be called 1 time for each new bar in the chart. true

Example


workers: [{
    id: 'ichart',                       // unique id
    type: 'ichart',
    security: '$target',                // use the "symbol" parameter

    interval: Chart.Interval.MINUTE,    // minute bars
    minBars: 26,                        // 26 bars before it's "ready"

    indicators: [{
        type: 'macd',                   // macd indicator
        fastPeriod: 12,
        slowPeriod: 26,
        signalPeriod: 9
    },{
        type: 'rsi',                    // rsi indicator
        timePeriod: 14
    }]
}]

Indicators

Reference

Over 200 technical analysis indicators are bundled with Alta5.

Momentum IndicatorsadxAverage Directional Movement IndexLearn more about Average Directional Movement Index at tadoc.org.timePeriodadxrAverage Directional Movement Index RatingLearn more about Average Directional Movement Index Rating at tadoc.org.timePeriodapoAbsolute Price OscillatorLearn more about Absolute Price Oscillator at tadoc.org.fastPeriodslowPeriodmaTypearoonAroonLearn more about Aroon at tadoc.org.timePeriodaroonDownaroonUparoonDownaroonoscAroon OscillatorLearn more about Aroon Oscillator at tadoc.org.timePeriodbopBalance Of PowerLearn more about Balance Of Power at tadoc.org.cciCommodity Channel IndexLearn more about Commodity Channel Index at tadoc.org.timePeriodcmoChande Momentum OscillatorLearn more about Chande Momentum Oscillator at tadoc.org.timePerioddxDirectional Movement IndexLearn more about Directional Movement Index at tadoc.org.timePeriodimiIntraday Momentum IndexLearn more about Intraday Momentum Index at tadoc.org.timePeriodmacdMoving Average Convergence/DivergenceLearn more about Moving Average Convergence/Divergence at tadoc.org.fastPeriodslowPeriodsignalPeriodmacdsignalhistogrammacdmacdextMACD with controllable MA typeLearn more about MACD with controllable MA type at tadoc.org.fastPeriodfastMATypeslowPeriodslowMATypesignalPeriodsignalMATypemacdsignalhistogrammacdmacdfixMoving Average Convergence/Divergence Fix 12/26Learn more about Moving Average Convergence/Divergence Fix 12/26 at tadoc.org.signalPeriodmacdsignalhistogrammacdmfiMoney Flow IndexLearn more about Money Flow Index at tadoc.org.timePeriodminus_diMinus Directional IndicatorLearn more about Minus Directional Indicator at tadoc.org.timePeriodminus_dmMinus Directional MovementLearn more about Minus Directional Movement at tadoc.org.timePeriodmomMomentumLearn more about Momentum at tadoc.org.timePeriodplus_diPlus Directional IndicatorLearn more about Plus Directional Indicator at tadoc.org.timePeriodplus_dmPlus Directional MovementLearn more about Plus Directional Movement at tadoc.org.timePeriodppoPercentage Price OscillatorLearn more about Percentage Price Oscillator at tadoc.org.fastPeriodslowPeriodmaTyperocRate of change : ((price/prevPrice)-1)*100Learn more about Rate of change : ((price/prevPrice)-1)*100 at tadoc.org.timePeriodrocpRate of change Percentage: (price-prevPrice)/prevPriceLearn more about Rate of change Percentage: (price-prevPrice)/prevPrice at tadoc.org.timePeriodrocrRate of change ratio: (price/prevPrice)Learn more about Rate of change ratio: (price/prevPrice) at tadoc.org.timePeriodrocr100Rate of change ratio 100 scale: (price/prevPrice)*100Learn more about Rate of change ratio 100 scale: (price/prevPrice)*100 at tadoc.org.timePeriodrsiRelative Strength IndexLearn more about Relative Strength Index at tadoc.org.timePeriodstochStochasticLearn more about Stochastic at tadoc.org.fastKPeriodslowKPeriodslowKMATypeslowDPeriodslowDMATypeslowKslowDslowKstochfStochastic FastLearn more about Stochastic Fast at tadoc.org.fastKPeriodfastDPeriodfastDMATypefastKfastDfastKstochrsiStochastic Relative Strength IndexLearn more about Stochastic Relative Strength Index at tadoc.org.timePeriodfastKPeriodfastDPeriodfastDMATypefastKfastDfastKtrix1-day Rate-Of-Change (ROC) of a Triple Smooth EMALearn more about 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA at tadoc.org.timePeriodultoscUltimate OscillatorLearn more about Ultimate Oscillator at tadoc.org.timePeriod1timePeriod2timePeriod3willrWilliams' %RLearn more about Williams' %R at tadoc.org.timePeriodOverlap StudiesaccbandsAcceleration BandsLearn more about Acceleration Bands at tadoc.org.timePeriodupperBandmiddleBandlowerBandupperBandbbandsBollinger BandsLearn more about Bollinger Bands at tadoc.org.timePeriodnbDevUpnbDevDnmaTypeupperBandmiddleBandlowerBandupperBanddemaDouble Exponential Moving AverageLearn more about Double Exponential Moving Average at tadoc.org.timePeriodemaExponential Moving AverageLearn more about Exponential Moving Average at tadoc.org.timePeriodht_trendlineHilbert Transform - Instantaneous TrendlineLearn more about Hilbert Transform - Instantaneous Trendline at tadoc.org.kamaKaufman Adaptive Moving AverageLearn more about Kaufman Adaptive Moving Average at tadoc.org.timePeriodmaMoving averageLearn more about Moving average at tadoc.org.timePeriodmaTypemamaMESA Adaptive Moving AverageLearn more about MESA Adaptive Moving Average at tadoc.org.fastLimitslowLimitmamafamamamamavpMoving average with variable periodLearn more about Moving average with variable period at tadoc.org.minPeriodmaxPeriodmaTypemidpointMidPoint over periodLearn more about MidPoint over period at tadoc.org.timePeriodmidpriceMidpoint Price over periodLearn more about Midpoint Price over period at tadoc.org.timePeriodsarParabolic SARLearn more about Parabolic SAR at tadoc.org.accelerationmaximumsarextParabolic SAR - ExtendedLearn more about Parabolic SAR - Extended at tadoc.org.startValueoffsetOnReverseaccelerationInitLongaccelerationLongaccelerationMaxLongaccelerationInitShortaccelerationShortaccelerationMaxShortsmaSimple Moving AverageLearn more about Simple Moving Average at tadoc.org.timePeriodt3Triple Exponential Moving Average (T3)Learn more about Triple Exponential Moving Average (T3) at tadoc.org.timePeriodvFactortemaTriple Exponential Moving AverageLearn more about Triple Exponential Moving Average at tadoc.org.timePeriodtrimaTriangular Moving AverageLearn more about Triangular Moving Average at tadoc.org.timePeriodwmaWeighted Moving AverageLearn more about Weighted Moving Average at tadoc.org.timePeriodPattern Recognitioncdl2crowsTwo CrowsLearn more about Two Crows at tadoc.org.valuecdl3blackcrowsThree Black CrowsLearn more about Three Black Crows at tadoc.org.valuecdl3insideThree Inside Up/DownLearn more about Three Inside Up/Down at tadoc.org.valuecdl3linestrikeThree-Line Strike Learn more about Three-Line Strike at tadoc.org.valuecdl3outsideThree Outside Up/DownLearn more about Three Outside Up/Down at tadoc.org.valuecdl3starsinsouthThree Stars In The SouthLearn more about Three Stars In The South at tadoc.org.valuecdl3whitesoldiersThree Advancing White SoldiersLearn more about Three Advancing White Soldiers at tadoc.org.valuecdlabandonedbabyAbandoned BabyLearn more about Abandoned Baby at tadoc.org.penetrationvaluecdladvanceblockAdvance BlockLearn more about Advance Block at tadoc.org.valuecdlbeltholdBelt-holdLearn more about Belt-hold at tadoc.org.valuecdlbreakawayBreakawayLearn more about Breakaway at tadoc.org.valuecdlclosingmarubozuClosing MarubozuLearn more about Closing Marubozu at tadoc.org.valuecdlconcealbabyswallConcealing Baby SwallowLearn more about Concealing Baby Swallow at tadoc.org.valuecdlcounterattackCounterattackLearn more about Counterattack at tadoc.org.valuecdldarkcloudcoverDark Cloud CoverLearn more about Dark Cloud Cover at tadoc.org.penetrationvaluecdldojiDojiLearn more about Doji at tadoc.org.valuecdldojistarDoji StarLearn more about Doji Star at tadoc.org.valuecdldragonflydojiDragonfly DojiLearn more about Dragonfly Doji at tadoc.org.valuecdlengulfingEngulfing PatternLearn more about Engulfing Pattern at tadoc.org.valuecdleveningdojistarEvening Doji StarLearn more about Evening Doji Star at tadoc.org.penetrationvaluecdleveningstarEvening StarLearn more about Evening Star at tadoc.org.penetrationvaluecdlgapsidesidewhiteUp/Down-gap side-by-side white linesLearn more about Up/Down-gap side-by-side white lines at tadoc.org.valuecdlgravestonedojiGravestone DojiLearn more about Gravestone Doji at tadoc.org.valuecdlhammerHammerLearn more about Hammer at tadoc.org.valuecdlhangingmanHanging ManLearn more about Hanging Man at tadoc.org.valuecdlharamiHarami PatternLearn more about Harami Pattern at tadoc.org.valuecdlharamicrossHarami Cross PatternLearn more about Harami Cross Pattern at tadoc.org.valuecdlhighwaveHigh-Wave CandleLearn more about High-Wave Candle at tadoc.org.valuecdlhikkakeHikkake PatternLearn more about Hikkake Pattern at tadoc.org.valuecdlhikkakemodModified Hikkake PatternLearn more about Modified Hikkake Pattern at tadoc.org.valuecdlhomingpigeonHoming PigeonLearn more about Homing Pigeon at tadoc.org.valuecdlidentical3crowsIdentical Three CrowsLearn more about Identical Three Crows at tadoc.org.valuecdlinneckIn-Neck PatternLearn more about In-Neck Pattern at tadoc.org.valuecdlinvertedhammerInverted HammerLearn more about Inverted Hammer at tadoc.org.valuecdlkickingKickingLearn more about Kicking at tadoc.org.valuecdlkickingbylengthKicking - bull/bear determined by the longer marubozuLearn more about Kicking - bull/bear determined by the longer marubozu at tadoc.org.valuecdlladderbottomLadder BottomLearn more about Ladder Bottom at tadoc.org.valuecdllongleggeddojiLong Legged DojiLearn more about Long Legged Doji at tadoc.org.valuecdllonglineLong Line CandleLearn more about Long Line Candle at tadoc.org.valuecdlmarubozuMarubozuLearn more about Marubozu at tadoc.org.valuecdlmatchinglowMatching LowLearn more about Matching Low at tadoc.org.valuecdlmatholdMat HoldLearn more about Mat Hold at tadoc.org.penetrationvaluecdlmorningdojistarMorning Doji StarLearn more about Morning Doji Star at tadoc.org.penetrationvaluecdlmorningstarMorning StarLearn more about Morning Star at tadoc.org.penetrationvaluecdlonneckOn-Neck PatternLearn more about On-Neck Pattern at tadoc.org.valuecdlpiercingPiercing PatternLearn more about Piercing Pattern at tadoc.org.valuecdlrickshawmanRickshaw ManLearn more about Rickshaw Man at tadoc.org.valuecdlrisefall3methodsRising/Falling Three MethodsLearn more about Rising/Falling Three Methods at tadoc.org.valuecdlseparatinglinesSeparating LinesLearn more about Separating Lines at tadoc.org.valuecdlshootingstarShooting StarLearn more about Shooting Star at tadoc.org.valuecdlshortlineShort Line CandleLearn more about Short Line Candle at tadoc.org.valuecdlspinningtopSpinning TopLearn more about Spinning Top at tadoc.org.valuecdlstalledpatternStalled PatternLearn more about Stalled Pattern at tadoc.org.valuecdlsticksandwichStick SandwichLearn more about Stick Sandwich at tadoc.org.valuecdltakuriTakuri (Dragonfly Doji with very long lower shadow)Learn more about Takuri (Dragonfly Doji with very long lower shadow) at tadoc.org.valuecdltasukigapTasuki GapLearn more about Tasuki Gap at tadoc.org.valuecdlthrustingThrusting PatternLearn more about Thrusting Pattern at tadoc.org.valuecdltristarTristar PatternLearn more about Tristar Pattern at tadoc.org.valuecdlunique3riverUnique 3 RiverLearn more about Unique 3 River at tadoc.org.valuecdlupsidegap2crowsUpside Gap Two CrowsLearn more about Upside Gap Two Crows at tadoc.org.valuecdlxsidegap3methodsUpside/Downside Gap Three MethodsLearn more about Upside/Downside Gap Three Methods at tadoc.org.valuePrice TransformavgdevAverage DeviationLearn more about Average Deviation at tadoc.org.timePeriodavgpriceAverage PriceLearn more about Average Price at tadoc.org.medpriceMedian PriceLearn more about Median Price at tadoc.org.typpriceTypical PriceLearn more about Typical Price at tadoc.org.wclpriceWeighted Close PriceLearn more about Weighted Close Price at tadoc.org.Statistic FunctionsbetaBetaLearn more about Beta at tadoc.org.timePeriodcorrelPearson's Correlation Coefficient (r)Learn more about Pearson's Correlation Coefficient (r) at tadoc.org.timePeriodlinearregLinear RegressionLearn more about Linear Regression at tadoc.org.timePeriodlinearreg_angleLinear Regression AngleLearn more about Linear Regression Angle at tadoc.org.timePeriodlinearreg_interceptLinear Regression InterceptLearn more about Linear Regression Intercept at tadoc.org.timePeriodlinearreg_slopeLinear Regression SlopeLearn more about Linear Regression Slope at tadoc.org.timePeriodstddevStandard DeviationLearn more about Standard Deviation at tadoc.org.timePeriodnbDevtsfTime Series ForecastLearn more about Time Series Forecast at tadoc.org.timePeriodvarVarianceLearn more about Variance at tadoc.org.timePeriodnbDevVolatility IndicatorsatrAverage True RangeLearn more about Average True Range at tadoc.org.timePeriodnatrNormalized Average True RangeLearn more about Normalized Average True Range at tadoc.org.timePeriodtrangeTrue RangeLearn more about True Range at tadoc.org.Volume IndicatorsadChaikin A/D LineLearn more about Chaikin A/D Line at tadoc.org.adoscChaikin A/D OscillatorLearn more about Chaikin A/D Oscillator at tadoc.org.fastPeriodslowPeriodobvOn Balance VolumeLearn more about On Balance Volume at tadoc.org.

Parameter Settings

Indicator settings (i.e. timePeriod) can also reference a parameter value by using $ and the parameter name.

Example


params: [{
    id: 'rsiPeriod',                    // define rsiPeriod param
    type: 'enum',
    label: 'RSI Period',
    items: [5, 10, 14, 21, 30, 45, 90],
    defaultValue: 14
}],

workers: [{
    type: 'ichart',
    security: '$target',
    member: 'ichart',

    interval: Chart.Interval.MINUTE,
    minBars: '$rsiPeriod',              // bind to rsiPeriod

    indicators: [{
        type: 'rsi',
        timePeriod: '$rsiPeriod'        // bind to rsiPeriod
    }]
}]

Moving Averages

Indicators that take a moving average type (maType) input can accept one of the following values:

Chart.SMASimple Moving Average Chart.EMAExponential Moving Average Chart.WMAWeighted Moving Average Chart.T3Triple Exponential Moving Average

Example


workers: [{
    id: 'chart',
    type: 'ichart',
    security: '$target',
    interval: Chart.Interval.MINUTE,
    minBars: 20,

    indicators: [{
        type: 'bbands',      // Bollinger Bands
        timePeriod: 20,
        nbDevUp: 2,
        nbDevDn: 2,
        maType: Chart.SMA
    },{
        type: 'rsi',         // RSI indicator
        timePeriod: 14
    }]
}]

Chart API

Chart Properties

bars

Array
An array of containing all the bars in this Chart. The first bar is at index 0.

var thirdBar = chart.bars[2];

close

Number
The close value of the last bar in this Chart.

firstBar

Bar
The first Bar in this Chart.

lastBar

Bar
The last Bar in this Chart.

length

Number
The number of bars in this Chart.

open

Number
The open value of the first bar in this Chart.

Chart Methods

each

function callback, Object scope
Calls the passed function with each bar in the Chart. Alias for chart.bars.forEach(). callbackfunction Should have the signature function(bar, index). scopeObject An object that will be used as this for the callback.

var chart = this.chart;
chart.each(function(bar, index){
    // do something with the bar
});

Bar Properties

close

Number
The close value for this Bar.

date

Date
A Date object containing the time and date for this Bar.

high

Number
The close value for this Bar.

index

Number
The index of this bar in the chart.

low

Number
The low value for this Bar.

nextBar

Bar
The Bar after this one in the chart.

open

Number
The open value for this Bar.

previousBar

Bar
The Bar before this one in the chart.

volume

Number
The volume value for this Bar.

Bar Methods

indicator

String id, String output
Used to access indicator values for this bar. idString The id of the indicator. outputString The name of the indicator output to get. If omitted, the default indicator output will be used. The available outputs for indicators are listed in the Indicators reference. Number The indicator value.

var chart = this.chart;
var bar = chart.lastBar;
var upper = bar.indicator('bbands', 'upperBand');

Chart Sample

Overview

In this sample we are going to create a simple Strategy that has an Intraday Chart with Bollinger Bands and RSI indicators for technical analysis.

We will be using the Strategy definition below as a base:


Strategy.define({
    name: 'Chart Sample',
    description: 'Demonstrates using a Chart in Alta5.',
    positionType: 'Option',

    params: [],

    // we will be modifying the code below
    workers: [],

    onSeek: function(target, data){

    }
});

Add a Chart Worker

A chart worker is responsible for creating and managing the Chart we will be using in our strategy. We want a real-time intraday Chart, so we will use an Intraday Chart Worker by setting type:'ichart' on the worker configuration.


workers: [{
    id: 'todayChart',
    type: 'ichart',         // intraday chart
    security: '$target',    // use target symbol
    interval: Chart.Interval.MINUTE  // minute bars
}]

Get the Chart

The Chart created by a chart worker is made available in our strategy with the id provided in the id setting on the chart worker.

We set id:'todayChart' on our worker, so we can get it with data.todayChart in our onSeek method.


workers: [{
    id: 'todayChart',  // here we set the id to use
    type: 'ichart',
    security: '$target',
    interval: Chart.Interval.MINUTE
}],

onSeek: function(target, data){
    // get the chart
    var chart = data.todayChart;

    // ...
}

Add Indicators

Indicators are added to the chart by adding an indicators:[] array to that chart worker configuration. The settings available for each type of Indicator can be found in the Indicators reference above.

In our strategy, we want to use Bollinger Bands and RSI indicators. We will set up the Bollinger Bands to use 20 bars for it's time period, so we set minBars:20 on our worker so it know that it has to wait for 20 bars before calculating the indicator values.


workers: [{
    id: 'todayChart',
    type: 'ichart',
    security: '$target',
    interval: Chart.Interval.MINUTE,

    minBars: 20,             // 20 bars before "ready"

    indicators: [{
        type: 'bbands',      // Bollinger Bands
        timePeriod: 20,      // uses 20 bars of data
        nbDevUp: 2,
        nbDevDn: 2,
        maType: Chart.SMA    // use simple moving average
    },{
        type: 'rsi',         // RSI indicator
        timePeriod: 14
    }]
}]

Using Parameters

We can also make worker and indicator properties configurable by a Trader using the strategy by adding a parameter and using $ and the parameter name.


params: [{
    id: 'timePeriod',                    // define param
    type: 'enum',
    label: 'Time Period',
    items: [5, 10, 15, 20, 30, 45, 90],
    defaultValue: 20
}],

workers: [{
    id: 'todayChart',
    type: 'ichart',
    security: '$target',
    interval: Chart.Interval.MINUTE,

    minBars: '$timePeriod',         // use our new parameter

    indicators: [{
        type: 'bbands',
        timePeriod: '$timePeriod',  // use our new parameter
        nbDevUp: 2,
        nbDevDn: 2,
        maType: Chart.SMA
    },{
        type: 'rsi',
        timePeriod: 14
    }]
}]

Read Indicators

Indicator values are available on each Bar in the Chart by calling the indicator(id, output) method with the id of the indicator and the name of the indicator output value you want to retrieve. To get the default output value for an indicator you can omit the 2nd argument, like RSI below. The default indicator outputs are listed for each indicator in the Indicators reference.


onSeek: function(target, data){
    // get the chart
    var chart = data.todayChart;

    // get the last bar in the chart
    var bar = chart.lastBar;

    // get the RSI value of the last bar
    var rsi = bar.indicator('rsi');

    // get the Bollinger Bands values
    var upper = bar.indicator('bbands', 'upperBand'),
        mid = bar.indicator('bbands', 'middleBand'),
        lower = bar.indicator('bbands', 'lowerBand');

    // ... do something useful with the values
}

Full Sample Code


Strategy.define({
    name: 'Chart Sample',
    description: 'Demonstrates using a Chart in Alta5.',
    positionType: 'Option',

    params: [{
        id: 'timePeriod',
        type: 'enum',
        label: 'Time Period',
        items: [5, 10, 15, 20, 30, 45, 90],
        defaultValue: 20
    }],

    workers: [{
        id: 'todayChart',
        type: 'ichart',
        security: '$target',
        interval: Chart.Interval.MINUTE,

        minBars: '$timePeriod',

        indicators: [{
            type: 'bbands',
            timePeriod: '$timePeriod',
            nbDevUp: 2,
            nbDevDn: 2,
            maType: Chart.SMA
        },{
            type: 'rsi',
            timePeriod: 14
        }]
    }],

    onSeek: function(target, data){
        var chart = data.todayChart;
        var bar = chart.lastBar;

        var rsi = bar.indicator('rsi');

        var upper = bar.indicator('bbands', 'upperBand'),
            mid = bar.indicator('bbands', 'middleBand'),
            lower = bar.indicator('bbands', 'lowerBand');

        // ... do something useful with the values
    }
});