FMP

FMP

Enter

candlesticks

patterns

technical

analysis

candles

stock analysis

trend changes

The Candlestick Trading Bible: Mastering Candlestick Patterns for Spotting Trend Changes

- (Last modified: Feb 10, 2025 1:37 PM)

twitterlinkedinfacebook
blog post cover photo

Image credit: Candlestick Trading Bible

Welcome to the Candlestick Trading Bible, your ultimate guide to understanding and utilizing candlestick patterns in the stock market. Whether you're a beginner or an experienced trader, mastering candlestick patterns can significantly enhance your trading strategy. Here, we'll decode how to read these patterns and highlight some of the most crucial ones. Plus, we'll walk you through creating a simple app to visualize these patterns using JavaScript.

Understanding Candlestick Patterns

Candlestick charts are one of the most popular tools in technical analysis, originating from Japan in the 18th century. Each "candle" on the chart represents price movements within a specific timeframe, giving traders insights into market sentiment.

Basic Structure of a Candlestick:

  • Body: The wide part of the candle shows the opening and closing prices. If the close is higher than the open, the body is typically white or green (bullish). If the close is lower, it's usually black or red (bearish).
  • Wicks (or Shadows): The thin lines above and below the body represent the highest and lowest prices during that period.

candlestick chart

Key Candlestick Patterns

Here are some essential candlestick patterns you should know:

Doji - Indicates indecision in the market. The open and close prices are virtually the same, creating a cross or plus sign shape.

the doji candlestick

Hammer - A bullish reversal pattern that forms after a decline. It has a small body with a long lower wick, suggesting that after significant selling, buyers step in to drive the price up.

the hammer candlestick pattern

Shooting Star - This bearish reversal pattern appears after an uptrend. It's characterized by a small body at the lower end of the trading range with a long upper wick, signaling that sellers might take control.

a shooting star candlestick pattern

Engulfing Patterns:

    • Bullish Engulfing: A small bearish candle is followed by a larger bullish one, completely enveloping the first candle.
    • Bearish Engulfing: Opposite of bullish engulfing, where a small bullish candle is followed by a larger bearish one.

candlestick patterns

Morning Star and Evening Star

    • Morning Star: A bullish reversal pattern with three candles: a long bearish, a small-bodied candle (can be bullish or bearish), and a long bullish candle.
    • Evening Star: Its bearish counterpart, suggesting a downturn after an uptrend.

morning star and evening star candlestick patterns

Building Your Own Candlestick Chart App

Step 1: Setting Up Your Development Environment

Download and Install Visual Studio Code (VSCode):

  1. Visit the VSCode Website: Go to code.visualstudio.com in your browser.
  2. Download for Your OS: Click on the download button for your operating system (Windows, macOS, or Linux).
  3. Open VSCode: Once installed, open VSCode.

Step 2: Preparing Your Project

  1. Create a New Folder for Your Project:
    • Use the file explorer to create a new folder named CandlestickChartApp on your desktop or preferred location.
  1. Open the Folder in VSCode:
    • In VSCode, go to File > Open Folder and select your CandlestickChartApp folder.
  1. Create Project Files:
    • index.html: This will contain the HTML structure.
    • script.js: Where you'll write your JavaScript.
    • styles.css: For styling your chart.

copy the below code inside your index.html file:

candlestick analytics

copy the below code inside your styles.css file:

Step 3: Writing the JavaScript Code

copy the below code inside your script.js file:

const apiKey = 'YOUR_API_KEY';
const symbol = 'AAPL';
const url = `https://financialmodelingprep.com/api/v3/historical-chart/5min/${symbol}?apikey=${apiKey}`;

function fetchStockData() {
fetch(url)
.then(response => response.json())
.then(data => {
drawCandlestickChart(data.slice(0, 13));
})
.catch(error => console.error('Error fetching data:', error));
}

function drawCandlestickChart(data) {
constcanvas=document.getElementById('chartCanvas');
constctx=canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
constcandleWidth=canvas.width/15;
let x =10;
let highestPrice =Math.max(...data.map(candle =>candle.high));
let lowestPrice =Math.min(...data.map(candle =>candle.low));
data.forEach(candle => {
consthigh=candle.high;
constlow=candle.low;
constopen=candle.open;
constclose=candle.close;
constpriceToY= price =>canvas.height- (price - lowestPrice) *canvas.height/ (highestPrice - lowestPrice);
constisBullish= close > open;
ctx.beginPath();
ctx.moveTo(x + candleWidth /2, priceToY(high));
ctx.lineTo(x + candleWidth /2, priceToY(low));
ctx.strokeStyle='black';
ctx.stroke();
ctx.fillStyle= isBullish ?'green':'red';
ctx.fillRect(x, priceToY(Math.max(open, close)), candleWidth *0.8, Math.abs(priceToY(open) -priceToY(close)));
x += candleWidth + 5;
});
}

fetchStockData();

Step 4: Running Your App

  • Open index.html in a Browser: Right-click index.html in VSCode, choose "Open with Live Server" if you have the Live Server extension, or directly open it with your web browser.

After dragging the file to the browser you will see a graph that should look like this.

Now you can analyze the graph to spot patterns that we discussed earlier.

Notes:

  • API Key: You need to replace 'YOUR_API_KEY' with an actual API key from Financial Modeling Prep.
  • Stock symbol: In this line "const symbol = 'AAPL';" you should replace AAPL with your decired stock symbol

This guide should give you a good start in creating your candlestick chart application. Remember, this is a basic implementation; you might want to add more features like zooming, panning, or real-time updates for a more sophisticated tool. I hope it was helpful. Now you know about important candlestick patterns that can change the direction of the trend and know how to draw candlestick graph using stock prices. The Candlestick Trading Bible is here to help you navigate the complex world of candlestick patterns. By understanding these patterns, you can make more informed decisions in trading. Moreover, building your own tools, like the simple JavaScript app we've outlined, can give you a practical edge in visualizing market trends. Remember, while candlestick patterns offer valuable insights, they should be one part of a broader trading strategy. Happy trading, and may your charts always show green candles!

Other Blogs

May 27, 2024 3:30 PM - Rajnish Katharotiya

The best 5 GPU stocks other than NVDA

In the ever-evolving world of technology, certain sectors have consistently demonstrated exceptional growth and innovation. The graphics processing units (GPUs) industry is one such sector, offering investors a golden opportunity for potentially high returns. In this blog, we'll delve into why inves...

blog post title

Jun 6, 2024 2:57 AM - Parth Sanghvi

DCF vs NPV: Which Valuation Method Should You Use?

When it comes to valuing an investment or a business, two of the most commonly used methods are Discounted Cash Flow (DCF) and Net Present Value (NPV). Both methods are essential tools in finance, but they serve slightly different purposes and are used in different contexts. This guide will explore ...

blog post title

Jun 10, 2024 3:46 AM - Parth Sanghvi

Fixed Costs vs Variable Costs: Understanding Cost Structures

Understanding the difference between fixed and variable costs is essential for managing a business’s finances. These costs form the foundation of any cost structure and play a critical role in pricing, budgeting, and profit margin analysis. In this guide, we will explore what fixed and variable cost...

blog post title
FMP

FMP

Financial Modeling Prep API provides real time stock price, company financial statements, major index prices, stock historical data, forex real time rate and cryptocurrencies. Financial Modeling Prep stock price API is in real time, the company reports can be found in quarter or annual format, and goes back 30 years in history.
twitterlinkedinfacebookinstagram
2017-2024 © Financial Modeling Prep