[amibroker] Re: Counting Bars - I have confused myself

 

Hi


You could give this a try, it's a loop within a loop. The inner loop looks back 200 bars from the bar in the outer loop and counts forward until it finds a match. I've used rounding on the close prices to get more matches. It depends how accurate you want to be. A zero result means no match in the last 200 bars.


SameCloseBarsAgo = 0;
for( i = 200; i < BarCount; i++ )
{
CurrentClose = round(C[i]);
for (j = i - 200; j < i; j++)
{
if (round(C[j]) == CurrentClose)
{
SameCloseBarsAgo[i] = i - j;
break;
}
}
}

Filter = 1;
AddColumn(SameCloseBarsAgo, "SameCloseBarsAgo", 1.0);


Cheers
Alan

__._,_.___

Posted by: alanclem@bigpond.net.au
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

**** 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/


.

__,_._,___


EmoticonEmoticon