PureBytes Links
Trading Reference Links
|
Hi,
I'm trying to write an AFL to draw support trendline (PS. I'm aware that there is existing trendline AFLs in the library). There is a section where I can't think of other ways but to use loop (probably should be defined as a loop in another loop). This slows down the AFL speed tremendously. Would anyone be able to think of a better way to improve the following ?
The logic of the code is this: The first point of the support/trend line has been identified as (SupportX1, SupportY1). The following code then attempts to find the next point (SupportX2, SupportY2) of the trendline. A bar-by-bar search approach is adopted (hence the loop). The bar with the Low that forms the lowest gradient line is the target here (assigned SupportX2).
Any help is appreciated.
Kevin
gradient0 = ( Ref(L, -1) - SupportY1) / (-1 + SupportX1);
for (i=1; i<BarCount; i++)
{
loopstartX = 1;
while(loopstartX < (SupportX1[i]))
{
gradient = ( Ref(L,-loopstartX) - SupportY1 )/(-loopstartX + SupportX1);
if ((gradient[i]) < (gradient0[i]))
{
gradient0[i] = gradient[i];
SupportX2[i]= loopstartX;
}
nxsup00 = nxsup00 + 1;
}
}
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
|