Miscellaneous
0
Views
0
Downloads
0
Favorites
Pattern_Hammer_Shooting Star1
//+------------------------------------------------------------------+
//| Pattern Recognition v1.0 |
//| (complete rewrite and name change of pattern alert) |
//| |
//| Copyright © 2005, Jason Robinson |
//| (jasonrobinsonuk, jnrtrading) |
//| http://www.jnrtrading.co.uk |
//| |
//| This is still work in progress and needs LOTS of testing |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)."
#property link "http://www.jnrtrading.co.uk"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Yellow
extern bool Show_Alert = true;
extern int Pointer_Offset = 9;
extern int High_Offset = 10;
extern bool Display_ShootStar = true;
extern bool Show_ShootStar_Alert = true;
extern int Offset_ShootStar = 12;
extern color Color_ShootStar = Green;
extern int Text_ShootStar = 8;
extern bool Display_Hammer = true;
extern bool Show_Hammer_Alert = true;
extern int Offset_Hammer = 6;
extern color Color_Hammer = Green;
extern int Text_Hammer = 8;
extern double Candle_WickBody_Percent=0.90;
extern int CandleLength=12;
//---- buffers
double upArrow[];
double downArrow[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
//---- indicators
SetIndexStyle(0,DRAW_ARROW, EMPTY);
SetIndexArrow(0,72);
SetIndexBuffer(0, downArrow);
SetIndexStyle(1,DRAW_ARROW, EMPTY);
SetIndexArrow(1,71);
SetIndexBuffer(1, upArrow);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
ObjectsDeleteAll(0, OBJ_TEXT);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start(){
double Range, AvgRange;
int counter, setalert;
static datetime prevtime = 0;
int shift;
int shift1;
int shift2;
int shift3;
int shift4;
string pattern, period;
int setPattern = 0;
int alert = 0;
int arrowShift;
int textShift;
double O, O1, O2, C, C1, C2, C3, L, L1, L2, L3, H, H1, H2, H3;
double CL, CLmin, CL1, CL2, BL, BLa, BL90, BL1, BL2, UW, UWa, UW1, UW2, LW, LWa, LW1, LW2, BodyHigh, BodyLow;
BodyHigh = 0;
BodyLow = 0;
if(prevtime == Time[0]) {
return(0);
}
prevtime = Time[0];
switch (Period()) {
case 1:
period = "M1";
break;
case 5:
period = "M5";
break;
case 15:
period = "M15";
break;
case 30:
period = "M30";
break;
case 60:
period = "H1";
break;
case 240:
period = "H4";
break;
case 1440:
period = "D1";
break;
case 10080:
period = "W1";
break;
case 43200:
period = "MN";
break;
}
for (shift = 0; shift < Bars; shift++) {
setalert = 0;
counter=shift;
Range=0;
AvgRange=0;
for (counter=shift ;counter<=shift+9;counter++) {
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
shift1 = shift + 1;
shift2 = shift + 2;
shift3 = shift + 3;
shift4 = shift + 4;
O = Open[shift1];
O1 = Open[shift2];
O2 = Open[shift3];
H = High[shift1];
H1 = High[shift2];
H2 = High[shift3];
H3 = High[shift4];
L = Low[shift1];
L1 = Low[shift2];
L2 = Low[shift3];
L3 = Low[shift4];
C = Close[shift1];
C1 = Close[shift2];
C2 = Close[shift3];
C3 = Close[shift4];
if (O>C) {
BodyHigh = O;
BodyLow = C; }
else {
BodyHigh = C;
BodyLow = O; }
CL = High[shift1]-Low[shift1];
CL1 = High[shift2]-Low[shift2];
CL2 = High[shift3]-Low[shift3];
BL = Open[shift1]-Close[shift1];
UW = High[shift1]-BodyHigh;
LW = BodyLow-Low[shift1];
BLa = MathAbs(BL);
BL90 = BLa*Candle_WickBody_Percent;
// Bearish Patterns
// Check for Bearish Shooting Star
if ((H>=H1)&&(H>H2)&&(H>H3)) {
if (((UW/2)>LW)&&(UW>(2*BL90))&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(L>L1)&&(L>L2)*/) {
if (Display_ShootStar == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], High[shift1] + (Pointer_Offset+Offset_ShootStar+High_Offset)*Point);
ObjectSetText(GetName(shift), "SS 2", Text_ShootStar, "Times New Roman", Color_ShootStar);
downArrow[shift1] = High[shift1] + (Pointer_Offset*Point);
}
}
if (Show_ShootStar_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Shooting Star 2";
setalert = 1;
}
}
}
// Check for Bearish Shooting Star
if ((H>=H1)&&(H>H2)&&(H>H3)) {
if (((UW/3)>LW)&&(UW>(2*BL90))&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(L>L1)&&(L>L2)*/) {
if (Display_ShootStar == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], High[shift1] + (Pointer_Offset+Offset_ShootStar+High_Offset)*Point);
ObjectSetText(GetName(shift), "SS 3", Text_ShootStar, "Times New Roman", Color_ShootStar);
downArrow[shift1] = High[shift1] + (Pointer_Offset*Point);
}
}
if (Show_ShootStar_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Shooting Star 3";
setalert = 1;
}
}
}
// Check for Bearish Shooting Star
if ((H>=H1)&&(H>H2)&&(H>H3)) {
if (((UW/4)>LW)&&(UW>(2*BL90))&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(L>L1)&&(L>L2)*/) {
if (Display_ShootStar == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], High[shift1] + (Pointer_Offset+Offset_ShootStar+High_Offset)*Point);
ObjectSetText(GetName(shift), "SS 4", Text_ShootStar, "Times New Roman", Color_ShootStar);
downArrow[shift1] = High[shift1] + (Pointer_Offset*Point);
}
}
if (Show_ShootStar_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Shooting Star 4";
setalert = 1;
}
}
}
// End of Bearish Patterns
// Bullish Patterns
// Check for Bullish Hammer
if ((L<=L1)&&(L<L2)&&(L<L3)) {
if (((LW/2)>UW)&&(LW>BL90)&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(H<H1)&&(H<H2)*/) {
if (Display_Hammer == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], Low[shift1] - (Pointer_Offset+Offset_Hammer)*Point);
ObjectSetText(GetName(shift), "HMR 2", Text_Hammer, "Times New Roman", Color_Hammer);
upArrow[shift1] = Low[shift1] - (Pointer_Offset*Point);
}
}
if (Show_Hammer_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Bullish Hammer 2";
setalert = 1;
}
}
}
// Check for Bullish Hammer
if ((L<=L1)&&(L<L2)&&(L<L3)) {
if (((LW/3)>UW)&&(LW>BL90)&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(H<H1)&&(H<H2)*/) {
if (Display_Hammer == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], Low[shift1] - (Pointer_Offset+Offset_Hammer)*Point);
ObjectSetText(GetName(shift), "HMR 3", Text_Hammer, "Times New Roman", Color_Hammer);
upArrow[shift1] = Low[shift1] - (Pointer_Offset*Point);
}
}
if (Show_Hammer_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Bullish Hammer 3";
setalert = 1;
}
}
}
// Check for Bullish Hammer
if ((L<=L1)&&(L<L2)&&(L<L3)) {
if (((LW/4)>UW)&&(LW>BL90)&&(CL>=(CandleLength*Point))&&(O!=C)/*&&(H<H1)&&(H<H2)*/) {
if (Display_Hammer == true) {
ObjectCreate(GetName(shift), OBJ_TEXT, 0, Time[shift1], Low[shift1] - (Pointer_Offset+Offset_Hammer)*Point);
ObjectSetText(GetName(shift), "HMR 4", Text_Hammer, "Times New Roman", Color_Hammer);
upArrow[shift1] = Low[shift1] - (Pointer_Offset*Point);
}
}
if (Show_Hammer_Alert) {
if (setalert == 0 && Show_Alert == true) {
pattern = "Bullish Hammer 4";
setalert = 1;
}
}
}
// End of Bullish Patterns
if (setalert == 1 && shift == 0) {
Alert(Symbol(), " ", period, " ", pattern);
setalert = 0;
}
} // End of for loop
return(0);
}
//+------------------------------------------------------------------+
string GetName(int shift)
{
return(DoubleToStr(Time[shift],0));
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---