Quote:
Originally Posted by cochran1
Derk, not sure the best way to code this but my point was just to trade with the 4hr trend; if the 4hr is trending down then trade short, if the 4hr is trending up then trade long. thanks mike
|
Mike:
Therein lies the problem... How precisely do I tell which way it is trending? Using the HA candle instead of price candles might be good.
To tell the trend of the price channel, I do a "scoring" system, looking at the current, previous and previous previous values, like this:
Code:
if (MA_Hi_0 > MA_Hi_1) sum++;
if (MA_Lo_0 > MA_Lo_1) sum++;
if (MA_Hi_0 > MA_Hi_2) sum++;
if (MA_Lo_0 > MA_Lo_2) sum++;
if (MA_Hi_1 > MA_Hi_2) sum++;
if (MA_Lo_1 > MA_Lo_2) sum++;
if (MA_Hi_0 < MA_Hi_1) sum--;
if (MA_Lo_0 < MA_Lo_1) sum--;
if (MA_Hi_0 < MA_Hi_2) sum--;
if (MA_Lo_0 < MA_Lo_2) sum--;
if (MA_Hi_1 < MA_Hi_2) sum--;
if (MA_Lo_1 < MA_Lo_2) sum--;
Then if "sum" turns out to be 3 or greater, I call it a long trend; -3 or less and it's a short trend. I suppose I could do something similar for the general trend. Perhaps I should just require the current, previous and previous previous HA candles to be the same colour.
Anyone have a better idea?
-Derk