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

[amibroker] Auto trendline



PureBytes Links

Trading Reference Links

Hello and good day,
I have been trying to write a formula that will draw an automatic
trendline through the, (O+C)/2, of the first and last five minute
candles of yesterday. I'm new to AFL and had fun trying to get this far,
which was only accomplished by searching mail archives,the users guide,
knowledge bases and, even the "new" googlesearch.

The trendline works perfectly on some stocks but other stocks will have
the line through one but not both of the candles; while other stocks
show no connection with the trendline at all.

Thoughts on how to make this really work would be greatly appreciated.

This is the code:

x = Cum(1);

xx =  DateNum() !=Ref (DateNum(),-1);

startvalue = LastValue(ValueWhen( Ref (xx,79), (O+C)/2,1 ));     /*
(O+C)/2   of first bar of yesterday */
endvalue1 = LastValue(ValueWhen( Ref (xx,1), (O+C)/2,1 ));        /*
(O+C)/2   of last bar of yesterday */

startbar = LastValue( ValueWhen( (O+C)/2 == startvalue, x, 1 ) );
endbar = LastValue( ValueWhen( (O+C)/2 == endvalue1, x, 1 ) );

Aa = (endvalue1-startvalue)/(endbar-startbar);
b = startvalue;

trendline = Aa * ( x  - startbar ) + b;

Plot( Close, "Price", colorBlue, styleCandle );
Plot( trendline, "Trendline", colorRed );

Thank you,
Kind regards

Geary




------------------------------------

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/