I am missing something here, a second pair of eyes required to double check some code...

Back to topics list To post a new topic, please log in or register
avatar
189
tonyjms2005 2016.05.05 12: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
}

avatar
189
tonyjms2005 2016.05.05 12: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

avatar
Moderator
3412
GumRai 2016.05.05 13: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 (


avatar
189
tonyjms2005 2016.05.05 13:47 #
 

Hi

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

Thanks

Antony

avatar
Moderator
3412
GumRai 2016.05.05 13: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?
avatar
189
tonyjms2005 2016.05.05 14: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

avatar
Moderator
3412
GumRai 2016.05.05 14: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

avatar
189
tonyjms2005 2016.05.05 18: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 

Back to topics list  

To add comments, please log in or register