RE: Beginners Questions
(2018-07-24, 12:03 AM)malaguti Wrote: In prorealtime I've created this indicator which gives a value for each stage
Stage 2 = 1, stage 4 = -1 and stage 3 and 1 =0
the code is attached also. It allows for a screener for a stage 2 or stage 2 continuation. let me know if you need anything for the screener
also, if anyone would like to make any suggestions, then i'm all ears
such as refining the entry, exit etc
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.