[R-SIG-Finance] Crosses above, crosses below

Mark Knecht markknecht at gmail.com
Wed Oct 2 18:09:56 CEST 2013


On Wed, Oct 2, 2013 at 9:02 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
<SNIP>
>>
> Your original question only asked about a cross above.  If you want to test
> for a cross below, you need to test EMA.10 < EMA.20.
>
> If you want both crosses in one column, you can combine them by checking
> when the diffs of the logical comparisons equal 1.
>
> (diff(EMA.10 > EMA.20)==1) - (diff(EMA.10 < EMA.20)==1)
>
> Now the cross above will be 1 and the cross below will be -1.
>
>>    Again, thanks for the example code. It's helpful.
>>
>> Cheers,
>> Mark

Fair enough. I think this still misses the issue I was concerned about
but I wrote some functions that work the way I want using your inputs
so I'm set for now.

Thanks!

Cheers,
Mark



More information about the R-SIG-Finance mailing list