Hammers & Stars Strategy
Hammers & Stars Strategy
This script trades basic hammer and shooting star candlestick patterns.
It’s an extremely simple strategy with minimal filters, and according to my personal
manual backtesting and automated trading results, performs best on the Daily chart on
certain forex pairs.
It is intended to be traded on the forex markets but theoretically should work on all
markets (especially if you optimize the settings).
The script also comes with complete AutoView automation for Oanda.
Table of Contents
How It Works
According to the default settings, the script defines a hammer candle as a candle which
closes in the upper 33% of the entire bar, and does not close equal to its open (ie. is not
a doji).
The same is true for shooting star candles – the candle must close in the lower third of
the entire bar including the top and bottom wick in order to be considered valid.
This strategy is based on the definitions provided by Investopedia, and was inspired by
a YouTube video created by my trading mentor Steven Hart.
It also includes full inbuilt automation through both AutoView and PineConnector.
If you’re unfamiliar with these services, I have an AutoView YouTube Guide and
a PineConnector YouTube Guide which you might find helpful.
These guides are designed for coders, so if you’re a coder you will find them particularly
interesting – but even if you’re not a coder, the first lesson in both series teaches you
how to set up these services.
Settings
Updated 30th July 2021:
Strategy Settings:
R:R:
Risk:Reward profile
Fib Level:
Used to calculate upper/lower third of candle. (For example, setting it to 0.5 will mean
hammers must close >= 50% mark of the total candle size)
Use AutoView:
If turned on then the script will format its alerts to be compatible with AutoView.
Account Balance:
Your account balance (used for calculating position size)
Account Currency:
Your account balance currency (used for calculating position size)
PineConnector Settings
Use PineConnector:
If turned on then the script will format its alerts to be compatible with PineConnector.
License ID:
This is your PineConnector license ID which you can find by clicking here.
MetaTrader Prefix:
This is the prefix for your MetaTrader symbols. Some brokers have a prefix before the
symbol name (eg. m-EURUSD). Only input this if your symbols have one – leave blank
otherwise.
MetaTrader Suffix:
This is the suffix for your MetaTrader symbols. Some brokers have a suffix after the
symbol name (eg. EURUSD-f). Only input this if your symbols have one – leave blank
otherwise.
Spread:
This is used to offset your limit orders if you’re using them. (Eg. 0.5 means set your buy
limit half a pip below current price).
// @version=4
// Filter Settings
// ATR Filter
// EMA Filter
// Date Filter
// Time Filter
riskPerTrade = input(title="Risk Per Trade %", type=input.float, defval=2.0, step=0.5, tooltip="Your risk
per trade as a % of your account balance", group=g_av)
// PineConnector Settings
pc_id + "," + direction + limit + "," + symbol + "," + price + "sl=" + tostring(sl) + ",tp=" + tostring(tp) +
",risk=" + tostring(pc_risk)
// Get ATR
atr = atr(14)
emaTouchFilterLong = (low <= ema and emaTouchFilter and close[1] > ema) or not emaTouchFilter
emaTouchFilterShort = (high >= ema and emaTouchFilter and close[1] < ema) or not emaTouchFilter
// Merge Filters
longFilters = atrFilter and emaLongFilter and dateFilter and timeFilter and emaTouchFilterLong
shortFilters = atrFilter and emaShortFilter and dateFilter and timeFilter and emaTouchFilterShort
validHammer = lowestBody >= bullFib and close != open and not na(atr) and longFilters
validStar = highestBody <= bearFib and close != open and not na(atr) and shortFilters
// Check if we have confirmation for our setup
// Check if our account currency is the same as the base or quote currency (for risk $ conversion
purposes)
// Check if our account currency is neither the base or quote currency (for risk $ conversion purposes)
getPositionSize(stopLossSizePoints) =>
round(positionSize)
toWhole(number) =>
return := atr(14) >= 1.0 and atr(14) < 100.0 and syminfo.currency == "JPY" ? return * 100 : return
gtdYear = year(gtdTime)
gtdMonth = month(gtdTime)
gtdDay = dayofmonth(gtdTime)
if validLong
tradeStopPrice := longStopPrice
tradeTargetPrice := longTargetPrice
tradePositionSize := temp_positionSize
if validShort
tradeStopPrice := shortStopPrice
tradeTargetPrice := shortTargetPrice
tradePositionSize := temp_positionSize