PureBytes Links
Trading Reference Links
|
Glynn
> BarsSince(Cross(Mov(CLOSE,50,S),Mov(CLOSE,200,S)))
>
> What I would now like to do is find out what the numerical difference
between
> the 200 and 50 day moving ave for both days "before" the occurrence was.
>
> So theoretically if the alert showed that the crossover happened 12 days
ago,
> Col B and Col C would show the Moving average difference for 13 and 14
days previously.
{Exploration}
ColumnA: B/Since
BarsSince(Cross(Mov(CLOSE,50,S),Mov(CLOSE,200,S)));
ColumnB: -2 Bars
Bars:=LastValue(BarsSince(Cross(Mov(CLOSE,50,S),Mov(CLOSE,200,S))));
Abs(LastValue(Ref(Mov(C,50,S),-Bars-2)- Ref(Mov(C,200,S),-Bars-2)));
ColumnC: -1 Bar
Bars:=LastValue(BarsSince(Cross(Mov(CLOSE,50,S),Mov(CLOSE,200,S))));
Abs(LastValue(Ref(Mov(C,50,S),-Bars-1)- Ref(Mov(C,200,S),-Bars-1)));
{Recommend you use minimum 500 bars, preferably more}
> A last question. How would I write a formula referencing x bars back. I.E.
If I wanted
> to know the close of 6 bars ago, how would I write this. I have searched
like mad
> through the MS help, but just cant seem to find it. I am sure it is a
mental block.
I think it was Tom Sprunger who included some suggestions from Equis on a
slightly different matter, but the suggested method of using LastValue() to
create a constant appears to be the way to go for your problem. I have used
LastValue() in the exploration, and the one issue that I checked had
returned the correct values for columns B and C.
Because of the long MA's you are using it is probable that using less than
500 bars in the exploration will give an unacceptable number of N/A results.
Note also that the LastValue() function cannot be used in the same way for
system testing as it is being used in the sample exploration.
It may be that the key to your second question lies with being able to
identify a codeable event that corresponds to the number of bars back that
you want to check. Your question leaves me a little uncertain as to what you
are trying to achieve.
Roy
|