Skip to content

Implement ZigZag Technical Indicator #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Implement ZigZag Technical Indicator #804

wants to merge 8 commits into from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 22, 2025

This PR implements the ZigZag technical indicator which helps identify price trends and reversals by filtering out small price movements. The ZigZag implementation:

  • Identifies significant price swings based on a percentage threshold
  • Tracks high and low swing points to create zigzag lines between important price extremes
  • Helps traders identify meaningful price movements by filtering market noise
  • Can be customized with different percentage thresholds for various sensitivity levels

The implementation includes:

  • ZigZag class (using Big.js for precision)
  • FasterZigZag class (using native JavaScript numbers for performance)
  • Comprehensive test suite covering various edge cases

Technical Notes

  • The implementation tracks "confirmed extremes" that meet the percentage threshold requirement
  • Returns null until at least one extreme point is confirmed
  • Always returns the last confirmed extreme as the result to ensure continuity

Usage Example

import {ZigZag} from 'trading-signals';

// Create a new ZigZag with 5% threshold
const zigzag = new ZigZag({percentage: 5});

// Add price data
zigzag.update({high: 100, low: 98}, false); // Initial point
zigzag.update({high: 105, low: 103}, false); // Not significant yet
zigzag.update({high: 93, low: 90}, false);   // Significant drop, confirms the previous high

// Get the current ZigZag value
console.log(zigzag.getResult()?.toString()); // Will output the confirmed extreme

Fixes #803.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Feature request: ZigZag indicator Implement ZigZag Technical Indicator May 22, 2025
@Copilot Copilot AI requested a review from bennycode May 22, 2025 17:40
Copilot finished work on behalf of bennycode May 22, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: ZigZag indicator
2 participants