Hi
I find an indicator that shows the Pin Bars of a symbol , and I modify it to show only the Bullish Pin Bars who is above an Up Ma and the Bearish Pin Bars who is below a down Ma .
And when I drop it to a chart with 4H timeframe or less it shows nothing , but with a D1 timeframe or bigger it works but only for the Bullish Pin Bars :( . Who's can help me , thanks .
#property copyright "Copyright © 2014, Test"
#property link "http://www.Test.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_color2 Lime
#property indicator_width2 2
extern bool UseAlerts = true;
extern bool UseEmailAlerts = false;
extern bool UseCustomSettings = false;
extern double CustomMaxNoseBodySize = 0.33;
extern double CustomNoseBodyPosition = 0.4;
extern bool CustomLeftEyeOppositeDirection = true;
extern bool CustomNoseSameDirection = false;
extern bool CustomNoseBodyInsideLeftEyeBody = false;
extern double CustomLeftEyeMinBodySize = 0.1;
extern double CustomNoseProtruding = 0.5;
extern double CustomNoseBodyToLeftEyeBody = 1;
extern double CustomNoseLengthToLeftEyeLength = 0;
extern double CustomLeftEyeDepth = 0.1;
double Down[];
double Up[];
int LastBars = 0;
double MaxNoseBodySize = 0.33;
double NoseBodyPosition = 0.4;
bool LeftEyeOppositeDirection = true;
bool NoseSameDirection = false;
bool NoseBodyInsideLeftEyeBody = false;
double LeftEyeMinBodySize = 0.1;
double NoseProtruding = 0.5;
double NoseBodyToLeftEyeBody = 1;
double NoseLengthToLeftEyeLength = 0;
double LeftEyeDepth = 0.2;
double pips;
int point;
int init()
{
SetIndexBuffer(0, Down);
SetIndexBuffer(1, Up);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 74);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 74);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexLabel(0, "Bearish Pinbar");
SetIndexLabel(1, "Bullish Pinbar");
if (UseCustomSettings)
{
MaxNoseBodySize = CustomMaxNoseBodySize;
NoseBodyPosition = CustomNoseBodyPosition;
LeftEyeOppositeDirection = CustomLeftEyeOppositeDirection;
NoseSameDirection = CustomNoseSameDirection;
LeftEyeMinBodySize = CustomLeftEyeMinBodySize;
NoseProtruding = CustomNoseProtruding;
NoseBodyToLeftEyeBody = CustomNoseBodyToLeftEyeBody;
NoseLengthToLeftEyeLength = CustomNoseLengthToLeftEyeLength;
LeftEyeDepth = CustomLeftEyeDepth;
}
return(0);
}
int deinit()
{
Comment( "" );
return(0);
}
int start()
{
point_multiplier();
double MaBar1=iMA( Symbol(), 0, 50,0,0,0,1 );
double MaBar2=iMA( Symbol(), 0,50,0,0,0,2 );
double inclination=(MaBar1 - MaBar2)*point;
Comment( inclination );
int NeedBarsCounted;
double NoseLength, NoseBody, LeftEyeBody, LeftEyeLength;
if (LastBars == Bars) return(0);
NeedBarsCounted = Bars - LastBars;
LastBars = Bars;
if (NeedBarsCounted == Bars) NeedBarsCounted--;
for (int i = NeedBarsCounted; i >= 1; i--)
{
if (i == Bars - 1) continue;
NoseLength = High[i] - Low[i];
if (NoseLength == 0) NoseLength = Point;
LeftEyeLength = High[i + 1] - Low[i + 1];
if (LeftEyeLength == 0) LeftEyeLength = Point;
NoseBody = MathAbs(Open[i] - Close[i]);
if (NoseBody == 0) NoseBody = Point;
LeftEyeBody = MathAbs(Open[i + 1] - Close[i + 1]);
if (LeftEyeBody == 0) LeftEyeBody = Point;
if(inclination<=-3)
if(MaBar2 - MathMax(Open[1],Close[1])>0)
if (High[i] - High[i + 1] >= NoseLength * NoseProtruding)
{
if (NoseBody / NoseLength <= MaxNoseBodySize)
{
if (1 - (High[i] - MathMax(Open[i], Close[i])) / NoseLength < NoseBodyPosition)
{
if ((!LeftEyeOppositeDirection) || (Close[i + 1] > Open[i + 1]))
{
if ((!NoseSameDirection) || (Close[i] < Open[i]))
{
if (LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize)
{
if ((MathMax(Open[i], Close[i]) <= High[i + 1]) && (MathMin(Open[i], Close[i]) >= Low[i + 1]))
{
if (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody)
{
if (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength)
{
if (Low[i] - Low[i + 1] >= LeftEyeLength * LeftEyeDepth)
{
if ((!NoseBodyInsideLeftEyeBody) || ((MathMax(Open[i], Close[i]) <= MathMax(Open[i + 1], Close[i + 1])) && (MathMin(Open[i], Close[i]) >= MathMin(Open[i + 1], Close[i + 1]))))
{
Down[i] = High[i] + 5 * Point + NoseLength / 5;
if (i == 1) SendAlert("Bearish");
}
}
}
}
}
}
}
}
}
}
}
if(inclination>=3)
if(MathMin(Open[1],Close[1])-MaBar2>0)
if (Low[i + 1] - Low[i] >= NoseLength * NoseProtruding)
{
if (NoseBody / NoseLength <= MaxNoseBodySize)
{
if (1 - (MathMin(Open[i], Close[i]) - Low[i]) / NoseLength < NoseBodyPosition)
{
if ((!LeftEyeOppositeDirection) || (Close[i + 1] < Open[i + 1]))
{
if ((!NoseSameDirection) || (Close[i] > Open[i]))
{
if (LeftEyeBody / LeftEyeLength >= LeftEyeMinBodySize)
{
if ((MathMax(Open[i], Close[i]) <= High[i + 1]) && (MathMin(Open[i], Close[i]) >= Low[i + 1]))
{
if (NoseBody / LeftEyeBody <= NoseBodyToLeftEyeBody)
{
if (NoseLength / LeftEyeLength >= NoseLengthToLeftEyeLength)
{
if (High[i + 1] - High[i] >= LeftEyeLength * LeftEyeDepth)
{
if ((!NoseBodyInsideLeftEyeBody) || ((MathMax(Open[i], Close[i]) <= MathMax(Open[i + 1], Close[i + 1])) && (MathMin(Open[i], Close[i]) >= MathMin(Open[i + 1], Close[i + 1]))))
{
Up[i] = Low[i] - 5 * Point - NoseLength / 5;
if (i == 1) SendAlert("Bullish");
}
}
}
}
}
}
}
}
}
}
}
}
return(0);
}
string TimeframeToString(int P)
{
switch(P)
{
case PERIOD_M1: return("M1");
case PERIOD_M5: return("M5");
case PERIOD_M15: return("M15");
case PERIOD_M30: return("M30");
case PERIOD_H1: return("H1");
case PERIOD_H4: return("H4");
case PERIOD_D1: return("D1");
case PERIOD_W1: return("W1");
case PERIOD_MN1: return("MN1");
}
return("");
}
void SendAlert(string dir)
{
string per = TimeframeToString(Period());
if (UseAlerts)
{
Alert(dir + " Pinbar on ", Symbol(), " @ ", per);
PlaySound("alert.wav");
}
if (UseEmailAlerts)
SendMail(Symbol() + " @ " + per + " - " + dir + " Pinbar", dir + " Pinbar on " + Symbol() + " @ " + per + " as of " + TimeToStr(TimeCurrent()));
}
void point_multiplier()
{
double ticksize = MarketInfo( Symbol(), MODE_TICKSIZE );
if (ticksize==0.00001){
pips=ticksize*10;
point=10000;}
if (ticksize == 0.001){
pips=ticksize*10;
point=100;}
if (ticksize == 0.0001){
pips=ticksize;
point=1000;}
if (ticksize == 0.01){
pips=ticksize;
point=10;}
}
know what is the mistake I made ?