This scanner will go through my watch list and find a hammer or a reverse hammer on the chart. It helps me find a daily bias for the symbols I want to trade.
It is a similar concept as the previous post.
Everybody knows how a hammer candle looks like.
But how do we express it mathematically?
Mathematical Description of a Hammer Candle (with the 30% rule):
Real Body (Small, less than 30% of the total candle length): The body (i.e., the difference between the open O and close C) should be less than 30% of the entire range of the candle (high H to low L).
This ensures that the body is relatively small compared to the total candle length.
Lower Shadow (At least twice the body length): The lower shadow (the difference between the low price L and the lower of the open or close min(O,C) should be at least twice the length of the real body:
Upper Shadow (Very small or non-existent): The upper shadow (the difference between the high price H and the higher of the open or close max(O,C) should be minimal:
This means the upper shadow is less than 10% of the total range of the candle.
Prerequisites
DAS Trader version (5.8.0.1) with advanced hotkeys enabled
Named chart window where we want to find the hammer. For my needs, I use the daily chart window named MYDAILY
Named watch list window. I use MYMKTVIEWER name
Named montage window. I use MONTAGE1
Linked chart window to your montage
Named hammer finder and reverse hammer finder hotkeys
Hammer finder hotkey
To put this into DAS Trader hotkey syntax, we can do a following hotkey/hot button
//tune which candle to check 0 being current candle -1 previous candle
$COUNTER=0;
$FOUNDHAMMER=0;
$Bar=GetWindowObj("MYDAILY").Getbar($COUNTER);
//tune the top shadow size sensitivity
$TSS=0.10;
//determine bar size
$HmL=$Bar.Hi-$Bar.Lo;
//determina 1/3 of the bar
$Hml3=$HmL/3;
//determine open and close of the candle
if ($Bar.OPEN<=$Bar.CLOSE)
{
$SMALLER=$Bar.OPEN;
$BIGGER=$Bar.CLOSE;
$CDL="Green ";
}
else
{
$SMALLER=$Bar.CLOSE;
$BIGGER=$Bar.OPEN;
$CDL="Red ";
}
//determine candle body size if it is smaller than 1/3 of the daily candle range
$OmC=$Bar.OPEN-$Bar.CLOSE;
if($Omc/$HmL<=0.3)
{
$COND1=1;
//calculate wick size from the candle low
$SmL=abs($SMALLER-$Bar.Lo);
//determine if wick is twice the size of the body
$CmO=abs($Bar.CLOSE-$Bar.OPEN);
if($SmL>=2*$CmO)
{
$COND2=1;
//determine upper shadow small or none
$HmB=$Bar.Hi-$BIGGER;
if($HmB<=$TSS*$HmL)
{
$COND3=1;
SPEAK($CDL +"Hammer");
MsgBox($CDL+"Hammer");
//return;
return;
$FOUNDHAMMER=0;
}
else
{
$COND3=0;
}
}
else
{
$COND2=0;
}
}
else
{
$COND1=0;
}
I put notes into the code so that you can better understand the steps.
I do some variable settings, explained later
then read the chart last candle (tunable)
determine the candle color and range
run the 3 conditions tests
return a pop-up window with a voice read
Reverse hammer finder hotkey
for a reverse hammer it needs just a few changes as we look for top and bottom wicks in reverse.
//tune which candle to check 0 being current candle -1 previous candle
$COUNTER=0;
$FOUNDHAMMER=0;
$Bar=GetWindowObj("MYDAILY").Getbar($COUNTER);
//tune the bottom shadow size
$BSS=0.10;
//determine bar size
$HmL=$Bar.Hi-$Bar.Lo;
//determina 1/3 of the bar
$Hml3=$HmL/3;
//determine open and close of the candle
if ($Bar.OPEN<=$Bar.CLOSE)
{
$SMALLER=$Bar.OPEN;
$BIGGER=$Bar.CLOSE;
$CDL="Green ";
}
else
{
$SMALLER=$Bar.CLOSE;
$BIGGER=$Bar.OPEN;
$CDL="Red ";
}
//determine candle body size if it is smaller than 1/3 of the daily candle range
$OmC=$Bar.OPEN-$Bar.CLOSE;
if($Omc/$HmL<=0.33)
{
$COND1=1;
//calculate wick size from the candle hi
$SmL=abs($BIGGER-$Bar.Hi);
//determine if wick is twice the size of the body
$CmO=abs($Bar.CLOSE-$Bar.OPEN);
if($SmL>=2*$CmO)
{
$COND2=1;
//determine lower shadow small or none
$LmLwr=abs($Bar.Lo-$SMALLER);
if($LmLwr<=$BSS*$HmL)
{
$COND3=1;
SPEAK($CDL +"Reverse Hammer");
MsgBox($CDL+"Reverse Hammer");
//return;
return;
$FOUNDHAMMER=0;
}
else
{
$COND3=0;
}
}
else
{
$COND2=0;
}
}
else
{
$COND1=0;
}
You can use these hotkeys, and it will run the tests for you against the current chart. But we need to change the symbols on our chart to have a working scanner.
How to scroll through the watch list
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.