if check on negative MACD histogram

 

Hi All

Ignore whether this check is actually a valid way to go short :-)

Can any one spot what's up with this code, I cant figure it out:

if(dbMACDDivergence_Bar1 <= dbDivergenceShortSetting) 
{
    //short conditions met

 

Where dbDivergenceShortSetting is set to -0.3

 

the aim of the check is to check whether the histogram of the MACD on the last bar was equal to or less than the value of -0.3

so it should be true if:

dbMACDDivergence_Bar1 = -0.3
dbMACDDivergence_Bar1 = -0.458
dbMACDDivergence_Bar1 = -1.6

etc

and False if
dbMACDDivergence_Bar1 = -0.29
dbMACDDivergence_Bar1 = 2.1

Basically want it to trigger if the histogram gets to -0.3 or less. My understand is that a greater number to -0.3 is towards zero and then on to positive numbers :-)

Have I done something really dumb ?

thanks in anticipation. 

 

just to add, this rule isn't triggering, despite the dbMACDDivergence_Bar1 hitting -0.3 and less (e.g. -0.4)

 
idh:

just to add, this rule isn't triggering, despite the dbMACDDivergence_Bar1 hitting -0.3 and less (e.g. -0.4)


Add a print statement before your "if" to check the values.
 

yeah thanks, I do that a lot when debugging. I think I may have found the issue.

I do hope MT5 is better than 4... 

 
idh:

yeah thanks, I do that a lot when debugging. I think I may have found the issue.

I do hope MT5 is better than 4... 

In what respect ?  do you know OOP ?
 

yes I know OOP.

I've just been finding MT4 a bit quirky, its OK but it could be better so hoping 5 sorts some of the issues.

little things that bug me like, no 10 minute chart so you have to conjure up something yourself (or reuse someone elses code). Lack of debugger, strategy tester seems a bit flaky sometimes.

hey, typical brit, gotta moan about something yes? ;-) 

 
idh:

yes I know OOP.

I've just been finding MT4 a bit quirky, its OK but it could be better so hoping 5 sorts some of the issues.

little things that bug me like, no 10 minute chart so you have to conjure up something yourself (or reuse someone elses code). Lack of debugger, strategy tester seems a bit flaky sometimes.

hey, typical brit, gotta moan about something yes? ;-) 

Don't worry,  you will find plenty to moan about with MT5,  the position management system is radically different,  you can hold one position on each instrument,  so you don't get to see individual orders as you do with MT4.  The MT5 Strategy Tester is great if you want to test an EA that trades multiple instruments,  but if you want to test with tick data you are not going to be happy.  If you want control of the spread for testing . . .  you are not going to be happy.  If you want to use some specific history data, then you are not going to be happy.  There are also some nice things,  even if they haven't quite been implemented as well as they might have,  for example OnChartEvent() to do stuff when an Object or Button on the chart is clicked . . .
 

hmmmm OK, thanks for the insight, maybe not so then. My EA development is for spreadbetting, I think most people use it for Forex. I've also looked at NinjaTrader, perhaps that's better I don't know, problem with NinjaTrader is finding a broker offering connectivity for spreadbetting.

Reason: