I have some code (below) which is the formula for DeMark's REI on a platform other than Metatrader. I am not code-proficient and am unsure if it is consistent with how DeMark describes REI (below). If someone could confirm one way or the other I would be really grateful.
If it is consistent, could someone possibly whip it into an MT4 indicator? If it is not consistent, could you elaborate on the difference as it is code which is being used at the moment.
I have scoured this site and beyond looking for TD's REI in MT4 format. AHA posted one on this forum a while ago, but it was in ex4 not mql so I wasn't able to open it to compare with the code (not that I am code-literate). BillyRayValentine, did you ever confirm to AHA whether the REI was DeMark-consistent? Is it consistent with the code below?
There are a couple of other REI indicators floating about on this forum and TSD. There's one by a Russian Morrissey fan, by the looks of things, but that is different from AHA's one. And one called Phat_REI which didn't seem to work.
If anyone could help with comparing the code to confirm its consistency, and in the epic pursuit of a sound TD REI on MT4 I and I am sure others in due course would be massively grateful at your contribution to the advancement of, er, civilisation.
So, here's my non-MT4 code, which I hope but am not sure is consistent with DeMark's description of the indicator:
IF ( ( (HIGH>=LOW[5] OR HIGH>=LOW[6]) AND (LOW<=HIGH[5] OR LOW<=HIGH[6]) ) OR ( (HIGH[2]>=CLOSE[7] OR HIGH[2]>=CLOSE[8]) AND (LOW[2]<=CLOSE[7] OR LOW[2]<=CLOSE[8]) ) ) THEN
VALUE = HIGH - HIGH[2] + LOW - LOW[2]
ABSVALUE =ABS(HIGH - HIGH[2]) + ABS(LOW- LOW[2])
ELSE
VALUE = 0
ABSVALUE = 0
ENDIF
RETURN SUMMATION[N](VALUE) / SUMMATION[n](ABSVALUE) AS "REI"
and here is the man himself:
"The first step in calculating the REI is to add together the respective differences between the current day's high and the high two days earlier and the current day's low and the low two days earlier. These values will be positive or negative depending on whether the current day's high and low are greater or less than the high and low two days earlier. To prevent buying or selling prematurely into a steep price decline or advance, two additional conditions should be met to qualify a positive or negative value on a particular day:
1) either the high two days earlier must be greater than or equal to the close seven or eight days ago, or the current day's high must be greater than or equal to the low five or six days ago;
2) either the low two days earlier must be less than or equal to the close seven or eight days ago, or the current day's low must be less than or equal to the high five or six days ago.
If either of these conditions are not satisfied, a zero value is assigned to that day.
If they both are, the daily values (the differences between the highs and lows) are summed , and the specific value for that next day is determined. Next, all the positives and negative values are added together over a five-day period. This value is then divided by the absolute value price movement of each day over the five-day period. The numerator of the calculation can be either positive, negative or zero, because each day's value is summed for five days, but the denominator is always positive because it is only concerned with the differential price movement itself. This value is then multiplied by 100. Consequently, the REI can fluctuate between +100 and -100."
If it is consistent, could someone possibly whip it into an MT4 indicator? If it is not consistent, could you elaborate on the difference as it is code which is being used at the moment.
I have scoured this site and beyond looking for TD's REI in MT4 format. AHA posted one on this forum a while ago, but it was in ex4 not mql so I wasn't able to open it to compare with the code (not that I am code-literate). BillyRayValentine, did you ever confirm to AHA whether the REI was DeMark-consistent? Is it consistent with the code below?
There are a couple of other REI indicators floating about on this forum and TSD. There's one by a Russian Morrissey fan, by the looks of things, but that is different from AHA's one. And one called Phat_REI which didn't seem to work.
If anyone could help with comparing the code to confirm its consistency, and in the epic pursuit of a sound TD REI on MT4 I and I am sure others in due course would be massively grateful at your contribution to the advancement of, er, civilisation.
So, here's my non-MT4 code, which I hope but am not sure is consistent with DeMark's description of the indicator:
IF ( ( (HIGH>=LOW[5] OR HIGH>=LOW[6]) AND (LOW<=HIGH[5] OR LOW<=HIGH[6]) ) OR ( (HIGH[2]>=CLOSE[7] OR HIGH[2]>=CLOSE[8]) AND (LOW[2]<=CLOSE[7] OR LOW[2]<=CLOSE[8]) ) ) THEN
VALUE = HIGH - HIGH[2] + LOW - LOW[2]
ABSVALUE =ABS(HIGH - HIGH[2]) + ABS(LOW- LOW[2])
ELSE
VALUE = 0
ABSVALUE = 0
ENDIF
RETURN SUMMATION[N](VALUE) / SUMMATION[n](ABSVALUE) AS "REI"
and here is the man himself:
"The first step in calculating the REI is to add together the respective differences between the current day's high and the high two days earlier and the current day's low and the low two days earlier. These values will be positive or negative depending on whether the current day's high and low are greater or less than the high and low two days earlier. To prevent buying or selling prematurely into a steep price decline or advance, two additional conditions should be met to qualify a positive or negative value on a particular day:
1) either the high two days earlier must be greater than or equal to the close seven or eight days ago, or the current day's high must be greater than or equal to the low five or six days ago;
2) either the low two days earlier must be less than or equal to the close seven or eight days ago, or the current day's low must be less than or equal to the high five or six days ago.
If either of these conditions are not satisfied, a zero value is assigned to that day.
If they both are, the daily values (the differences between the highs and lows) are summed , and the specific value for that next day is determined. Next, all the positives and negative values are added together over a five-day period. This value is then divided by the absolute value price movement of each day over the five-day period. The numerator of the calculation can be either positive, negative or zero, because each day's value is summed for five days, but the denominator is always positive because it is only concerned with the differential price movement itself. This value is then multiplied by 100. Consequently, the REI can fluctuate between +100 and -100."