Technical Indicators

6 Dec 201812 minutes to read

EjChart control supports 10 types of technical indicators.

Bind data to render the indicator

You can bind the series dataSource to the indicator by setting the specific series name to the indicator by using the indicators.seriesName property.

  • TS
  • this.chartIndicators = [{
        //Set HiLo series dataSource to indicator using seriesName
        seriesName: "Hilo"
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series type="hiloopenclose" name="Hilo" [dataSource]="chartData" 
                 xName= "xDate" high="High" low="Low" open="Open" close="Close">
    	    </e-series>
      </e-seriescollection>
    </ej-chart>

    Also, you can add data to the indicator directly by using the dataSource option of the indicator.

  • TS
  • this.chartIndicators = [{
        //Add dataSource to indicator directly
        dataSource: chartData,
        xName: "xDate",
        high: "High",
        low: "Low",
        open: "Open",
        close: "Close",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
    </ej-chart>

    Indicator Types

    Accumulation Distribution

    To create an Accumulation Distribution indicator, set the indicators.type as “accumulationDistribution”. Accumulation Distribution require ‘volume’ field additionally with the dataSource to calculate the signal line.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "accumulationDistribution",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                high="High"  low="Low" open="Open" close="Close" volume="Volume">
    	    </e-series>
       </e-seriescollection>
       
    </ej-chart>

    Accumulation Distribution

    Average True Range (ATR)

    You can create an ATR indicator by setting the indicators.type as “ATR” in the indicators.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "ATR",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                           high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    ATR

    Bollinger Band

    Bollinger Band indicator is created by setting the indicators.type as “bollingerBand”. It contains three lines, namely upper band, lower band and signal line. Bollinger Band default value of the period is 14 and standardDeviations is 2.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "bollingerBand",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
             high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    Bollinger Band

    Exponential Moving Average (EMA)

    To render an EMA indicator, you have to set the indicators.type as “EMA”.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "EMA",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
             high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    EMA

    Momentum

    Momentum Technical indicator is created by setting the indicators.type as “momentum”. The momentum indicator renders two lines, namely upper band and signal line. Upper band always rendered at the value 100 and the signal line is calculated based on the momentum of the data.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "momentum",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
             high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    Momentum

    Moving Average Convergence Divergence (MACD)

    To render an MACD indicator, you have to set the indicators.type as “macd”. MACD indicator contains MACD line, Signal line and Histogram column. Histogram is used to differentiate MACD and signal line.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "macd",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                        high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    MACD

    macdType

    By using the macdType enumeration property, you can change the MACD rendering as line, histogram or both.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        type: "macd",
        //Set macd draw type
        macdType: "histogram",
        //  ...
    }];

    MACD Type

    Relative Strength Index (RSI)

    To render the RSI indicator, set the indicators.type as “RSI”. It contains three lines, namely upper band, lower band and signal line. Upper and lower band always render at value 70 and 30 respectively and signal line is calculated based on the RSI formula.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "RSI",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                       high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    RSI

    Simple Moving Average (SMA)

    To render the SMA indicator, you should specify the indicators.type as “SMA”.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "SMA",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                       high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    SMA

    Stochastic

    For the Stochastic indicator, you need to set the indicators.type as “stochastic”. The Stochastic indicator renders four lines namely, upper line, lower line, stochastic line and the signal line. Upper line always rendered at value 80 and the lower line is rendered at value 20. Stochastic and Signal Lines are calculated based on the stochastic formula.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "stochastic",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                         high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    Stochastic

    Triangular Moving Average (TMA)

    To render the TMA indicator, you should specify the indicators.type as “TMA”.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        seriesName: "Hilo",
        //Set indicator type
        type: "TMA",
        //  ...
    }];
  • HTML
  • <ej-chart id="chartcontainer" [indicators]="chartIndicators">
        <e-seriescollection>
            <e-series name="Hilo" [dataSource]="chartData" xName= "xDate"
                         high="High" low="Low" open="Open" close="Close">
    	    </e-series>
       </e-seriescollection>   
    </ej-chart>

    TMA

    Enable Tooltip

    To display the indicator tooltip, use visible option of the indicators.tooltip. Also, you can change and customize the tooltip color, border, format and font properties similar to the series tooltip.

  • TS
  • //Initializing Indicators    
    this.chartIndicators = [{
        //  ...
        tooltip: {
            //Enable tooltip for indicator
            visible: true
        },
    }];

    Indicator Tooltip