Add the Doji Star Candlestick Detector to Your AutoTrading Bot
Doji Star patterns are one of the most important tools for analyzing financial markets. Here’s how to add it to your AutoTrading Bot.
Doji Star patterns are one of the most important tools for analyzing financial markets. Here’s how to add it to your AutoTrading Bot.
Doji Star patterns are one of the most important tools for analyzing financial markets, especially for Forex and Crypto traders. By understanding these patterns, traders can better analyze and predict trends in the market — and even potentially identify profit opportunities.
But how can you implement this pattern detection into your trading bot? Here’s what you need to know.
A Doji Star candlestick pattern occurs when the open and close of the candlestick are close together, with relatively long wicks. Here’s an example I constructed using the AlgoQuant AutoTrading Bot and the code I’m about to demonstrate. This occurred on the USDJPY Raw pair, 30 Minute timeframe, February 18, 2023:
Many traders believe that a Doji Star candlestick indicates a potential reversal in a pricing direction. Specific types of Doji Stars, such as dragonfly, gravestone, and long-legged can be used to provide clearer indicators of price movements or consolidation.
Adding a Doji Star pattern detector to your trading bot provides you with a few options:
TA-Lib is the premier indicator analysis library for any kind of technical analysis. It’s blazingly fast, powerful, and used by many of the worlds top traders and platforms.
Installing it is pretty simple (if a little time-consuming). I’ve included the five basic steps below:
C:\
pip install TA-Lib
If you’re looking for a more in-depth tutorial, including common error messages, here’s a link to a post on the subject.
What would it take for Crypto, AI, and Cyber to truly change the world?
No spam. Unsubscribe anytime.
Filename: doji_star.py
import talib
def doji_star(dataframe):
"""
Function to calculate the doji star indicator. This is a candlestick pattern, more details can be found here:
:param data: dataframe object where the Doji Star patterns should be detected on
:return: dataframe with Doji Star patterns identified
"""
# Copy the dataframe
dataframe = dataframe.copy()
# Add doji star column to dataframe
dataframe['doji_star'] = 0
# Calculate doji star on dataframe
dataframe['doji_star'] = talib.CDLDOJISTAR(
dataframe['open'],
dataframe['high'],
dataframe['low'],
dataframe['close']
)
return dataframe
Here’s how the function works:
open
, high
, low
close
. These values are required to determine a Doji Star candlestick.doji_star
column. 0 = No Star. 100 = Green Star Candle, -100 = Red Star CandleIf you’d like to skip all these steps and simply get straight into it, head to the AlgoQuant AutoTrading Bot GitHub and download. Then, run one of the following commands:
python .\main.py --Exchange 'metatrader' --doji_star -timeframe "M30" --symbol "USDJPY.a"
python .\main.py --Exchange "metatrader" --Explore --doji_star --timeframe "M30" --symbol "USDJPY.a" --Display
If you run the second command, here’s an example of what you might get (options symbol=BTCUSD.a
, timeframe=M30
):