Download MetaTrader 5
To add comments, please log in or register
Thousands of developers have already published their products in the Market. Join them!
antony
549
antony 2016.05.05 10:00 

Hello

I have a function in my EA whihc has operate correctly for some time, until recently. When the function detects a very specific candle shape it returns a vale higher than 0.

So here is the function call:

if(Reversal(-1)>0){Alert"candle pattern found!");}
if(Reversal(1)>0){Alert"candle pattern found!");}


Here is the function:

int Reversal(int up_dn){

if(up_dn==-1){
//+------------------------------------------------------------------+
//|      shooting stars                                              |
//+------------------------------------------------------------------+
if((Close[2]-Open[2])*2<=High[2]-Close[2] && Open[2]==Low[2]){return(1);}//bullish shooting star

if((Open[1]-Close[1])*1.5<=High[1]-Open[1] && (Open[1]-Close[1])>(Close[1]-Low[1])){return(2);}//bearish shooting star

if((Open[1]-Close[1])*5<=High[1]-Open[1] && (Close[1]-Low[1])*2<High[1]-Open[1]){return(3);}//bearish shooting star
//+------------------------------------------------------------------+
//|      hanging man                                                 |
//+------------------------------------------------------------------+
 if((Open[1]-Close[1])*1.9<Close[1]-Low[1] && (High[1]-Open[1])<Open[1]-Close[1]){return(5);}//bearish hangman 
  
}    
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
if(up_dn==1){
 
 if((Open[2]-Close[2])*2<=Close[2]-Low[2] && Open[2]==High[2]){return(1);}//bearish hammer
 
 if((Close[1]-Open[1])*1.5<=Open[1]-Low[1] && (Close[1]-Open[1])>(High[1]-Close[1])){return(2);}//bullish hammer
 
 if((Close[1]-Open[1])*5<=Open[1]-Low[1] && (High[1]-Close[1])*2<Open[1]-Low[1]){return(3);}//bullish hammer
//+------------------------------------------------------------------+
//|      inverted hammer                                             |
//+------------------------------------------------------------------+  
if((Close[1]-Open[1])*1.9<High[1]-Close[1] && (Open[1]-Low[1])<Close[1]-Open[1]){return(5);}//bullish inverted hammer

}
   return(0);
//end
}

antony
549
antony 2016.05.05 10:03  

The function just seems to return 0 even when one of the statements are met. Has something changed or is there something that I have missed there?

Thanks

Antony

Keith Watford
Moderator
7979
Keith Watford 2016.05.05 11:14  
if(Reversal(-1)>0){Alert"candle pattern found!");}
if(Reversal(1)>0){Alert"candle pattern found!");}
if(Reversal(-1)>0){Alert("candle pattern found!");}
if(Reversal(1)>0){Alert("candle pattern found!");}

Your code will not compile with the missing (

antony
549
antony 2016.05.05 11:47  

Hi

Oh yes sorry, my mistake that was a typing error on the forum post rather than my EA.

Thanks

Antony

Keith Watford
Moderator
7979
Keith Watford 2016.05.05 11:58  
tonyjms2005:

Hi

Oh yes sorry, my mistake that was a typing error on the forum post rather than my EA.

Thanks

Antony

Don't you just copy and paste?
antony
549
antony 2016.05.05 12:14  
The statement has been simpliefied from my EA for the purpose of trying to figure oyut what is going on.
if(Reversal(-1)>0){Alert("candle pattern found!");}


Thanks

Antony

Keith Watford
Moderator
7979
Keith Watford 2016.05.05 12:18  

Well, I corrected the error and ran it through the strategy tester and it appears to return values other than zero


0    18:11:15    2016.02.19 22:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.19 22:00  @@@@TEST AUDUSD,H1: 2016.02.19 22:00:00
0    18:11:15    2016.02.22 05:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.22 05:00  @@@@TEST AUDUSD,H1: 2016.02.22 05:00:00
0    18:11:15    2016.02.22 10:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.22 10:00  @@@@TEST AUDUSD,H1: 2016.02.22 10:00:00
0    18:11:15    2016.02.22 12:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.22 12:00  @@@@TEST AUDUSD,H1: 2016.02.22 12:00:00
0    18:11:15    2016.02.22 20:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.22 20:00  @@@@TEST AUDUSD,H1: 2016.02.22 20:00:00
0    18:11:15    2016.02.22 20:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.22 20:00  @@@@TEST AUDUSD,H1: 2016.02.22 20:00:00
0    18:11:15    2016.02.23 04:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 04:00  @@@@TEST AUDUSD,H1: 2016.02.23 04:00:00
0    18:11:15    2016.02.23 04:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 04:00  @@@@TEST AUDUSD,H1: 2016.02.23 04:00:00
0    18:11:15    2016.02.23 12:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 12:00  @@@@TEST AUDUSD,H1: 2016.02.23 12:00:00
0    18:11:15    2016.02.23 17:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 17:00  @@@@TEST AUDUSD,H1: 2016.02.23 17:00:00
0    18:11:15    2016.02.23 20:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 20:00  @@@@TEST AUDUSD,H1: 2016.02.23 20:00:00
0    18:11:15    2016.02.23 22:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 22:00  @@@@TEST AUDUSD,H1: 2016.02.23 22:00:00
0    18:11:15    2016.02.23 23:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:15    2016.02.23 23:00  @@@@TEST AUDUSD,H1: 2016.02.23 23:00:00
0    18:11:16    2016.02.24 10:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:16    2016.02.24 10:00  @@@@TEST AUDUSD,H1: 2016.02.24 10:00:00
0    18:11:16    2016.02.24 13:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:16    2016.02.24 13:00  @@@@TEST AUDUSD,H1: 2016.02.24 13:00:00
0    18:11:16    2016.02.24 15:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:16    2016.02.24 15:00  @@@@TEST AUDUSD,H1: 2016.02.24 15:00:00
0    18:11:16    2016.02.24 22:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:16    2016.02.24 22:00  @@@@TEST AUDUSD,H1: 2016.02.24 22:00:00
0    18:11:16    2016.02.24 23:00  @@@@TEST AUDUSD,H1: Alert: candle pattern found!
0    18:11:16    2016.02.24 23:00  @@@@TEST AUDUSD,H1: 2016.02.24 23:00:00

antony
549
antony 2016.05.05 16:29  

Must be an issue with my terminal I will try and re-install the mt4 program to see if it resolves the error.

Thanks

Antony 

/
To add comments, please log in or register