7400

Hi,

I am currently adding candlestick pattern for my EA.

herewith i found formula for black hammer/white hammer from our forum. but i want to confirm whether the formula is correct or not?

```{
if ((Close[1] > Open[1]) && (Open[1]-Low[1] >= 2*(Close[1]-Open[1])) && (High[1]-Close[1] <= (Open[1]-Low[1])*0.10))
{
Comment("WhiteHammer");

}
}

{
if ((Close[1] < Open[1]) && (Close[1]-Low[1] >= 2*(Open[1]-Close[1])) && (High[1]-Open[1] <= (Close[1]-Low[1])*0.10))
{
Comment("WhiteHammer");

}
}```

16077

sheriffonline: i want to confirm whether the formula is correct or not?
1. Don't write hard to read code like that. That is why you are unsure. Make your code self documenting:
```double bodyBottom = MathMin(Open[1], Close[1]);
double bodyTop    = MathMax(Open[1], Close[1]);
double body       = bodyTop - bodyBottom;
double lowerWick  = bodyBottom - Low[1];
double upperWick  = High[1]    - bodyTop;

bool   isHammer      = lowerWick > 2*body && upperWick < lowerWick*0.10;
bool   isWhiteHammer = Close[1] > Open[1] && isHammer;
bool   isBlackHammer = Close[1] < Open[1] && isHammer;
```
Do you have any confusion with any of those lines? Does the formula match?
2. Second if - black hammer.
7400

WHRoeder:
1. Don't write hard to read code like that. That is why you are unsure. Make your code self documenting:Do you have any confusion with any of those lines? Does the formula match?
2. Second if - black hammer.

Yes. formula matches with mine. but yours are simple.

is this correct formula for hammer?

7400

sheriffonline:

Yes. formula matches with mine. but yours are simple.

is this correct formula for hammer?

WHRoeder:
1. Don't write hard to read code like that. That is why you are unsure. Make your code self documenting:Do you have any confusion with any of those lines? Does the formula match?
2. Second if - black hammer.

Hi,

I never experienced with bool operations. can you support me how to use if conditions for these bool operations. i tried following code, but fails.

```{
if (isWhiteHammer==true)
{

}
}```
16077

sheriffonline: I never experienced with bool operations. can you support me how to use if conditions for these bool operations. i tried following code, but fails.
`if (isWhiteHammer==true)`
1. "fails" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
2. Nothing wrong with that.
3. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool).
7400

WHRoeder:
1. "fails" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
2. Nothing wrong with that.
3. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool).
Thank you so much WHRoeder. Works fine here. Thank you for illustrated me like teaching kids. Ofcourse i am Kids in MQL4.. LOL...