Chartbreaker
    Preparing search index...

    Pivotpoints Generator

    The Pivotpoints generator calculates and displays pivot point levels (R3, R2, R1, PP, S1, S2, S3) on the chart. Pivot points are widely used technical indicators that help identify potential support and resistance levels.

    Use a Controller object to add the generator to a chart:

    const pivotpoints = controller.addGenerator('Pivotpoints');
    
    type Pivotpoint = {
    r3: number,
    r2: number,
    r1: number,
    pp: number,
    s1: number,
    s2: number,
    s3: number
    };
    • r3, r2, r1: Resistance levels (R3 being the highest)
    • pp: The central pivot point
    • s1, s2, s3: Support levels (S3 being the lowest)

    The generator provides extensive configuration options organized into groups.

    • Type: boolean

    • Default: false

    • Details

      When enabled, historic pivot values are shown for all visible periods. When disabled, only the latest pivot values are displayed.

    • Type: enum

    • Default: 'D' (Daily)

    • Values: 'MIN' | 'FIVE_MIN' | 'FIFTEEN_MIN' | 'THIRTY_MIN' | 'H' | 'FOUR_H' | 'D' | 'W' | 'M' | 'Y'

    • Details

      The timeframe used for calculating pivot points. For example, 'D' uses the previous day's OHLC to calculate today's pivots. Available periods are dynamically filtered based on the data range in the chart. When adaptPeriodToInterval is enabled, this option is disabled.

    • Type: boolean

    • Default: false

    • Details

      When enabled, the pivot period automatically adapts to the current chart interval. This disables the manual period selection.

    • Type: enum

    • Default: 'hlc3'

    • Values: 'hlc3' | 'ohlc4' | 'hlcc4'

    • Details

      The calculation method for the central pivot point:

      • hlc3: (High + Low + Close) / 3
      • ohlc4: (Open + High + Low + Close) / 4
      • hlcc4: (High + Low + Close + Close) / 4
    • Type: boolean

    • Default: false

    • Details

      When enabled, dotted lines are drawn between each pivot level, marking the midpoints.

    • Type: boolean

    • Default: false

    • Details

      When enabled, the next period's pivot values are projected forward on the chart.

    • Type: boolean

    • Default: true

    • Details

      When enabled, labels (R3, R2, R1, PP, S1, S2, S3) are displayed alongside the pivot lines. Disabling this also hides the per-pivot marker text options (textColor, textStyle, textSize, and all individual {Pivot}ShowMarkerText options).

    • Type: integer

    • Default: 200

    • Details

      Limits the maximum number of historic pivot point sets displayed simultaneously. This is an ephemeral option (and also not shown in the UI) intended for performance optimization on lower-end devices. Can be set via constructor params or programmatically.

      // via constructor params
      const pivotpoints = controller.addGenerator('Pivotpoints', [50]);

      // or programmatically
      pivotpoints.set('limitHistoricAmount', 50);
    • Type: color

    • Details

      Shared text color for all marker labels. Overrides all individual {Pivot}TextColor values.

    • Type: enum

    • Values: 'normal' | 'italic' | 'bold' | 'boldItalic'

    • Default: 'normal'

    • Details

      Shared text style for all marker labels. Overrides all individual {Pivot}TextStyle values.

    • Type: TextSize

    • Default: 12

    • Details

      Shared text size in pixels for all marker labels. Overrides all individual {Pivot}TextSize values.

    • Type: color

    • Default: '#444444'

    • Details

      Color of the PP (central pivot) line.

    • Type: color

    • Default: '#cccccc'

    • Details

      Color of all resistance and support lines (R3, R2, R1, S1, S2, S3). Does not affect the PP line.

    • Type: LineWidth

    • Default: 1

    • Details

      Line width for all resistance and support lines. Does not affect the PP line.

    • Type: color

    • Default: 'rgba(0,255,0,1)'

    • Details

      Base color for the background fill above the PP line. Rendered at different opacities for each zone: R3-R2 (5%), R2-R1 (10%), R1-PP (15%).

    • Type: color

    • Default: 'rgba(255,0,0,1)'

    • Details

      Base color for the background fill below the PP line. Rendered at different opacities for each zone: PP-S1 (15%), S1-S2 (10%), S2-S3 (5%).

    Each pivot level (R3, R2, R1, PP, S1, S2, S3) exposes its own styling options that override the shared settings. The option names follow the pattern {Pivot}{Option}:

    Option Type Details
    {Pivot}ShowMarkerText boolean Show/hide the marker label for this level. Only visible when the shared showMarkerText is enabled.
    {Pivot}TextColor color Text color for this level's marker label.
    {Pivot}TextStyle TextStyle Text style for this level's marker label.
    {Pivot}TextSize TextSize Text size for this level's marker label.
    Option Type Details
    {Pivot}ColorLine color Line color for this level.
    {Pivot}LineWidth LineWidth Line width for this level.
    Option Type Details
    {Pivot}ColorBackground color Background color for the zone adjacent to this level. Not available for PP (the PP zone has no background).
    // customize R1 specifically
    pivotpoints.set('R1ShowMarkerText', true);
    pivotpoints.set('R1TextColor', '#ff0000');
    pivotpoints.set('R1TextStyle', 'bold');
    pivotpoints.set('R1TextSize', 14);
    pivotpoints.set('R1ColorLine', '#00ff00');
    pivotpoints.set('R1LineWidth', 2);
    pivotpoints.set('R1ColorBackground', 'rgba(0,255,0,0.2)');

    The generator exposes the following public methods.

    • Type

      interface Pivotpoints {
      getLatestPivotValues(): Pivotpoint;
      }
    • Details

      getLatestPivotValues returns the pivot point values. If the historic option is toggled on, it will return the latest (most recent) set of values.

    • Example

      // example usage:
      const values = pivotpoints.getLatestPivotValues();
      console.log(values);
      /* {
      * r3: 155.20,
      * r2: 152.10,
      * r1: 149.60,
      * pp: 146.50,
      * s1: 144.00,
      * s2: 140.90,
      * s3: 138.40,
      * }
      */