0bps

Strategy vault / Scalping

Bollinger Bands Heiken Ashi Short term Trading Strategy

This strategy combines the Bollinger Bands indicator and the Heiken Ashi technique to identify trading opportunities by detecting the direction of Heiken Ashi candles and the width of Bollinger Bands. It adopts…

Author
ChaoZhang
Complexity
Starter · 60 lines
Parameters
4
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy combines the Bollinger Bands indicator and the Heiken Ashi technique to identify trading opportunities by detecting the direction of Heiken Ashi candles and the width of Bollinger Bands. It adopts 10-second K-line bars to determine the trend direction. As a high-frequency algorithmic trading strategy, it is suitable for quantitative trading on high-speed public chains such as Solana.

Strategy Logic

This strategy makes judgments mainly based on the following two indicators:

  1. Heiken Ashi Technique: Determine the price trend direction by calculating the open and close prices of Heiken Ashi candles. If there are N consecutive bullish Heiken Ashi candles, it is considered as a bullish signal. If there are N consecutive bearish Heiken Ashi candles, it is considered as a bearish signal.

  2. Bollinger Bands Indicator: Measure the volatility and overheat of prices by calculating the standard deviation range. If the width of Bollinger Bands is greater than a threshold, it means high price fluctuation and a significant trend.

The specific trading logic is:

  • Go long if there are consecutive N bullish Heiken Ashi signals and the Bollinger Bands width is greater than the volatility threshold.

  • Go short if there are consecutive N bearish Heiken Ashi signals and the Bollinger Bands width is greater than the volatility threshold.

By combining the Bollinger Bands and Heiken Ashi indicators, this strategy comprehensively judges the market volatility and the price trend direction, capturing short-term profit opportunities at high frequency time scales.

Advantages

This strategy has the following advantages:

  1. Improved signal accuracy by combining multiple indicators. Heiken Ashi determines the general trend while Bollinger Bands measures volatility. The combination enhances the reliability of trading signals.

  2. High-frequency algorithmic trading to capture short-term profits. 10-second bars combined with efficient exchanges like Solana enable high-frequency entry and exit suitable for short-term scalping.

  3. Great flexibility in adjustable parameters. The numbers of Heiken Ashi candles, Bollinger Bands parameters etc. can be adjusted to adapt to different market environments.

  4. Simple implementation and easily extensible. This strategy mainly employs basic indicators with concise code, facilitating future expansions of functionality.

Risks and Solutions

The main risks of this strategy include:

  1. Slippage risk from high-frequency trading. Adopt efficient exchanges, adjust trading frequency and other means to avoid.

  2. Failure when Bollinger Bands contract. Combine with other indicators like KDJ to determine trend.

  3. False signals from Heiken Ashi. Adjust candle numbers, confirm with other indicators when necessary.

  4. Great influence from news in high-frequency time frames. Pay attention to significant news events and pause trading when necessary.

Future Improvements

This strategy can be further improved in the following aspects:

  1. Leverage deep learning etc. to judge reliability of Heiken Ashi signals.

  2. Add stop loss mechanisms to control per trade risks.

  3. Form portfolio trading with more indicators to enhance stability.

  4. Adjust parameters for different coins and construct cross-coin portfolios.

  5. Utilize high-frequency data for trend prediction and early opportunity spotting.

Conclusion

This is a typical short-term high-frequency algorithmic trading strategy combining Heiken Ashi and Bollinger Bands. It has advantages like relatively high signal accuracy and capturing short-term profits at high frequency. It also has certain risks like slippage and false signals. Optimization methods like parameter tuning, risk control mechanisms and indicator combinations can help improve it. Overall it is a highly extensible short-term quantitative strategy idea.

Parameters

NameDefaultWhat it controls
v_input_1trueNumber of Consecutive Candles
v_input_24Bollinger Band Length
v_input_320Bollinger Band Multiplier
v_input_40.2Volatility Threshold

Source Pine Script

/*backtest
start: 2022-12-20 00:00:00
end: 2023-12-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("ANCIENT TECHNOLOGY", overlay=true)

// Input for the number of consecutive candles
consecutiveCandles = input(1, title="Number of Consecutive Candles", minval=1, maxval=6)

// Bollinger Band parameters
lengthBB = input(4, title="Bollinger Band Length")
multBB = input(20, title="Bollinger Band Multiplier")
volatilityThreshold = input(0.2, title="Volatility Threshold")

// Calculate Bollinger Bands
basisBB = sma(close, lengthBB)
devBB = multBB * stdev(close, lengthBB)
upperBB = basisBB + devBB
lowerBB = basisBB - devBB
bandWidth = upperBB - lowerBB

// Initialize Heiken Ashi variables
var float haOpen = na
var float haClose = na

// Update Heiken Ashi calculations
if (na(haOpen))
    haOpen := (open + close) / 2
else
    haOpen := (haOpen + haClose) / 2
haClose := (open + high + low + close) / 4

// Function to check for consecutive green or red Heiken Ashi candles
f_consecutive(dir, len) =>
    count = 0
    for i = 0 to len - 1
        if (dir == "green" and haClose[i] > haOpen[i]) or (dir == "red" and haClose[i] < haOpen[i])
            count := count + 1
    count == len

// Trading conditions based on Heiken Ashi and Bollinger Band width
longCondition = f_consecutive("green", consecutiveCandles) and bandWidth > volatilityThreshold
shortCondition = f_consecutive("red", consecutiveCandles) and bandWidth > volatilityThreshold

// Trading logic
if (longCondition)
    strategy.entry("Long", strategy.long)

if (shortCondition)
    strategy.entry("Short", strategy.short)

// Plot entry signals on the chart for visualization
plotshape(series=longCondition, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-27. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Bollinger-Bands-Heiken-Ashi-Short-term-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open