[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Struggling to Learn



PureBytes Links

Trading Reference Links

It does, but you don't have any worthwhile values in those arrays
before you starting using them in the loop.

For example, you have:

> Trend = C[0];

which sets the Trend array all to the first value of the Close array.
This means the whole Trend array has the same value at every bar. Then
you have:

> Uptrend = C > Ref(Trend,-1);

which references that Trend array. Trend is essentially a horizontal
line at this point, since every value is the same (Close[0]), so
Uptrend will be true whenever Close is above that line or false
otherwise. Similarly with Downtrend, Crossup, and Crossdown. They are
all based on the Trend array which is still only a horizontal line so
far. Also, HV and LV are calculated based on the initial value of
Period, which is one.

Then in the loop, the only values you are modifying are Trend and
Period. You never adjust Uptrend, Downtrend, Crossup, Crossdown, HV,
or LV based on the new Trend and Period data you're calculating, but
you continue to use them in conditional statements. Even when the
Period value has increased to say 10, HV and LV are still based
entirely on a period of one, since you haven't recalculated them.
Similarly, even though the data in the Trend array is changing to
presumably create your trend line or curve, you never recalculate
Uptrend, Downtrend, Crossup or Crossdown based on those new values.
They're still only based on the single value Close[0] - a horizontal line.

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, ricko@xxx wrote:
>
> Yes, except that at point 3 the close would cross below the line
(trend) and a sell signal would occur.
> I also want to plot the line (trend).
> 
> GP - you mentioned that "values Uptrend, Downtrend, Crossup,
Crossdown, HV, and LV
> are all generated using only the initial values of Trend and Period.".  
> 
> But I thought defining them before the loop created arrays that
could then be accessed in the loop.
> 
>  
> Rick Osborn 
> 
> 
> 
> ----- Original Message ----
> From: brian_z111 <brian_z111@xxx>
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Tuesday, November 20, 2007 4:49:10 AM
> Subject: [amibroker] Re: Struggling to Learn
> 
> --- In amibroker@xxxxxxxxx ps.com, "ricko8294_98" <ricko@> 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
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/