PureBytes Links
Trading Reference Links
|
> I wonder if anyone could help to program this:
> slow stochastic under 30 & crossing within last 5 bars
> Dmiplus crossing dmiminus within last 5 bars
> give maybr a +1 or so when both events happen within last 5 bars.
> same for stochastic > 70 and crossing with dmi for a bearish indication
> Am guessing that a loop or something like that is needed, which I
> am total ignorant about.
A loop isn't necessary, since EL provides some facilities to make
this pretty easy. I suspect it might be more efficient than writing
it in a loop, but I haven't tested it to be sure.
You could do something like this:
Vars: SlowSto(0), DMIp(0), DMIm(0), Event(0);
SlowSto = SlowK(5);
DMIp = DMIplus(5);
DMIm = DMIminus(5);
Event = 0;
if (SlowSto < 30) and (Highest(SlowSto,5) > 30)
and (MRO(DMIp crosses over DMIm,5,1) > 0)
then Event = 1;
if (SlowSto > 70) and (Lowest(SlowSto,5) < 70)
and (MRO(DMIp crosses under DMIm,5,1) > 0)
then Event = -1;
The MRO() function looks for the Most Recent Occurrence of the event.
I didn't use MRO() for the SlowSto check because you needed to be
sure it's currently <30 or >70 anyway. MRO() can tell you if it
crossed under 30, but you'd still have to check that it's still under
30. So since I had to do that check anyway, I figured the Highest /
Lowest check might be a little quicker than the MRO. And it gives me
a chance to show you two different techniques. :-)
Come to think of it, if you want to require that DMIp is *still*
above DMIm for the Event = 1 case, then you'll have to do a similar
DMIp>DMIm test there as well, and vice-versa for the Event = -1 case.
However, it's not safe to replace the MRO with a Highest/Lowest
check in this case, since you're comparing two moving values instead
of comparing a moving value to a fixed value (30/70).
Gary
|