Download MetaTrader 5
To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
Sherif Hasan
7223
Sherif Hasan 2014.11.19 12:25 

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");
        
    }
}

if its wrong please help me what exact formula to find hammer candlestick?

Thanks in Advance.

whroeder1
13627
whroeder1 2014.11.19 14:16  
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.
Sherif Hasan
7223
Sherif Hasan 2014.11.19 14:34  
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?

Sherif Hasan
7223
Sherif Hasan 2014.11.19 16:55  
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)
    {
            
    }
}
whroeder1
13627
whroeder1 2014.11.19 17:36  
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).
Sherif Hasan
7223
Sherif Hasan 2014.11.19 18:00  
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...
/
To add comments, please log in or register