spauken 47 posts msg #127154 - Ignore spauken |
2/4/2016 8:42:23 PM
Can anyone help me with an indicator? I want to count how many times a fast MA crossed (above and below) a slow moving average for the last two years and display the cumulative count at the bottom of the chart.
|
Mactheriverrat 3,156 posts msg #127157 - Ignore Mactheriverrat |
2/5/2016 1:30:13 AM
Here's some code on how many days a EMA(5) is above EMA(5). You can change this to MA(5) above MA(5) or EMA(10) above EMA(30). If you get the picture.
BxB is number of consecutive days ema(5) above (+)/below(-) previous EMA(5) and set{BBb,days( ema(5) is above EMA(5)1 day ago,100)}
set{BBa,days( ema(5) is below EMA(5) 1 day ago,100)} set{BxB, BBa - BBb} and add column BxB {B_x_B}
do not draw BxB
|
mahkoh 1,065 posts msg #127233 - Ignore mahkoh |
2/8/2016 4:05:55 PM
This should do it. However,when examining the charts it doesn't always seem correct. This could be related to accounting for dividends.
|
spauken 47 posts msg #127265 - Ignore spauken |
2/10/2016 1:28:24 PM
Thanks mahkoh. This does work, although the count is limited to the only the last 100 days per the SF user guide. Not sure why, but it is.
|
Kevin_in_GA 4,599 posts msg #127266 - Ignore Kevin_in_GA |
2/10/2016 1:42:15 PM
I believe that SF has upgraded many of their functions (including count()) to go back up to 252 days.
|