--- In amibroker@xxxxxxxxx ps.com, "ricko8294_98" <ricko@xxx> wrote:
>
> Hello
>
> I am trying to learn AB and loops in particular. There seems to be
> something I'm not getting - and I have been playing with this for the
> past several weeks.
>
> I want to create a trend indicator that will track below an uptrend
> (x% below the highest high of the most recent "y" period) or track
> above a downtrend(x% above the lowest low of the most recent "y"
> period), where the period "y" increases each day for the duration of
> each trend up to a maximum level.
>
> When a cross of the price (C) and the trend occurs,(either up or
> down) the period "y" resets to zero.
Hello Rick,
I think there might be another way.
If I
understand what you are trying to do then I am pretty sure it can
be done using array processing.
No harm in trying.
Just looking at the high side first (if we solve that then it should be
easy to adapt to the low side):
starting hard left of screen (using barindex) -
1) bar 1 is higher than bar zero and then bar two starts a downtrend
that continues for a few bars so bar 1 becomes the Highest High for the
set periods (P)
2) a line is set x% below the HHValue(High, P) say 2%
3) when the price crosses up through the setpoint you want to trigger a
signal (Buy?) AND/OR reset the periods (P) to zero.
4) since you want to reset the periods (P), when the closes crosses,
then......
P = barssince(close crossed the setpoint)
Is that what you want?
If so I might have a go at it.
Brian_z