RE: Beginners Questions
(2018-07-27, 09:44 PM)pcabc Wrote: OK, I've rolled a simple stage estimator and tried to plot it against the S&P500 for the same period.
The stage estimators are the two coloured bars, one stacked above the other labelled A & B.
Green = Stage 2
Red = Stage 4
Grey = insufficient data or stages 1 or 3
Pseudo code for A:
 stage = 1/3
 Loop:
     slope = sma150 (days) - previous sma150d (days)
     if (slope > 0) and (close >= sma150d):
     stage = 2
     end if
     if (slope < 0) and (close <= sma150d):
     stage = 4
     end if
  Â
Note, once it has gone from stage 1/3 to 2 or 4 it never goes back to 1/3. This seemed to whipsaw around a fair bit when the price was going sideways.
Pseudo code for B:
This is an adaption of the above. However, it has additional tests such that if the 50 day moving average is below the rising 150 day MA. The idea was for it to whipsaw less, which it seemed to do, but that is not apparent on the posted chart.
 stage = 1/3
 Loop:
     slope = sma150d (days) - previous sma150d
     if (slope > 0) and (close >= sma150d):
     stage = 2
         if (sma50d < sma150d)
             stage = 1/3
         end if
     end if
     if (slope < 0) and (close <= sma150d):
     stage = 4
         if (sma50d > sma150d)
             stage = 1/3
         end if
     end if
  Â
This code seems seems to result as a slightly more complex version of a golden / death cross based indication. I also note that mid stage 2 or 4, comparing the 150 and 200 day SMAs is good mid stage. I'm coming to the conclusion that the devil is in the detail, that mid stage is trivial but it is the stage entries and exits are more tricky. I will play with some logic based on channels to see what the effect is.
what you've done is given yourself a "trend filter" so that you wean out those fakeouts. I used the linear regression, which would work in the same way, likely you and i would have similar results if we just used those.
however as you say the devil is indeed in the detail and yes that tricky part of the right entry, stop and exit are not going to be easy.
in fairness however i'm coming to the conclusion that the benefit of an indicator that gave us our stages would if anything only really be useful in finding the entry
I don't think the drop in 2016 is a stage 4, but at the end of the day who cares?
we would have been taken out with our stop loss anyway. so it all becomes pretty moot to be honest trying to worry about a stage 3 or stage 4 exit as we should have taken our profit by then. and the stop loss is going to be nigh on impossible to really get right, so all we're doing it for is the entry
now, if i could code a double or triple top breakout where the SMA on the candle chart is sloping up, i'd be an extremely happy man. and my coding skills are just not good enough. you will be the first to hear by the way if i do manage it!!