Today I had another play with filter analysis and came up with this simple indicator.
You can put two filter conditions in it – one that has to be true for long trades and one that has to be true for short trades. The indicator then checks what percentage of green candles are evident when the long condition is true and what percentage of red candles are evident when the short condition is true. It also totals up the gain or loss for all candles whilst each filter condition is true. This can then be compared to the calculated datum results for all candles (all time % of red candles, all time % of green candles and average gain per candle for all candles if you are long or short).
This allows us to see if our filter offers any edge and is worthy of being used in a strategy to decide whether we should be long or short.
The attached image is on the DJI daily and tests the conditions of only going long if the SMA50 is above the SMA100 and only short if it is below it.
The datum is that 53.02% of candles are green and 46.97% red. If we apply our filter then when our long condition is true we get 53.54% green candles and when our short condition is true we get 48.43% red candles. So it seems that our filter is good for telling us when to be short (1.46% better performance) but makes little difference for long trades (0.52% better performance).
If we look at the average gain per candle for when each filter condition is true we see that the datum is that the market gains an average of 2.87 per candle (meaning that if we were always short we would lose -2.87 pips per candle on average). When our long filter is applied this drops to 2.05 per candle and when our short filter is applied it drops to -5.33
So it seems this simple filter actually costs us more than if we had no filter at all. I guess that is due to the lagging nature of average cross overs and the fact that the DJI falls faster than it rises normally so the lag keeps us in at the start of big falls and keeps us out at the start of the market recovering.
It would be interesting if others want to post here the results of other trend filters for comparison.
//long and short conditions to test
longcondition = average[50] > average[200]
shortcondition = average[50] < average[200]
if longcondition[1] then
if close <> open then
longcount = longcount + 1
longtot = longtot + (close - open)
if close > open then
longperctot = longperctot + 1
endif
longperc = (longperctot/longcount)*100
longavggain = longtot/longcount
endif
endif
if shortcondition[1] then
if close <> open then
shortcount = shortcount + 1
shorttot = shorttot + (open - close)
if close < open then
shortperctot = shortperctot + 1
endif
shortperc = (shortperctot/shortcount)*100
shortavggain = (shorttot/shortcount)
endif
endif
//calculate datums
if close <> open then
datumcount = datumcount + 1
greentot= greentot + (close - open)
redtot = redtot + (open - close)
if close > open then
greenperctot= greenperctot + 1
endif
if close < open then
redperctot= redperctot + 1
endif
greenavggain = (greentot/datumcount)
redavggain = (redtot/datumcount)
greenperc = (greenperctot/datumcount)*100
redperc = (redperctot/datumcount)*100
endif
return longperc coloured(0,128,0) as "long%", shortperc coloured(128,0,0)as "short%", greenperc coloured(0,255,0) as "long datum%", redperc coloured(255,0,0)as "short datum%", longavggain coloured(0,128,0) as "long avg gain", shortavggain coloured(128,0,0)as "short avg gain", greenavggain coloured(0,255,0) as "long datum avg gain", redavggain coloured(255,0,0)as "short datum avg gain"