PureBytes Links
Trading Reference Links
|
Thanks, Herman!
It helps a lot. As usual, I was getting waaaay too complicated.
-CS
----- Original Message -----
From: "Herman van den Bergen" <psytek@xxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, April 21, 2004 4:15 AM
Subject: RE: [amibroker] Bubble Sort
> The code below was kindly posted by someone on the list, but i forgot
> his/her name...
>
> function sort(inlist)
> {
> //sort inlist
> temp=0;
> for(i = BarCount-1; i>=0; i--)
> {
> for (j = 1; j <= i; j++)
> {
> if (inlist[j-1] > inlist[j])
> {
> temp = inlist[j-1];
> inlist[j-1] = inlist[j];
> inlist[j] = temp;
> }
> }
> }
> //inlist now sorted
> return inlist;
> }
>
> herman.
>
> -----Original Message-----
> From: Corey Saxe [mailto:res1wgwl@xxxxxxxxxxx]
> Sent: Wednesday, April 21, 2004 1:30 AM
> To: AmiBroker main
> Subject: [amibroker] Bubble Sort
>
>
> Has anyone coded a bubble sort routine in AB yet.
>
> Assistance will be greatly appreciated.
>
> Here is my malfunctioning attempt to use it to find the median.
> Yes, I know AB has a MEDIAN, I'm trying to get the sort routine down:
>
> SetBarsRequired(1000000,1000000);
> Y=C;//sort closes
> N=5;CH=0;csMEDIAN=0;
>
> for(i=6;i<BarCount;i++)
> {//outermost FOR bracket
>
>
> do
> {//do bracket
> for(j=0;j<N;j++)
> {//inner FOR
> CH=0;//"change" set to zero
>
> E1[i]=Y[i-j];
> E2[i]=Y[i-j-1];
> if(E1[i]>E2[i])//change condition
> {
> Y[i-j]=E2[i];
> Y[i-j-1]=E1[i];
> CH=1;//change was made
> }
>
>
> }//inner FOR
> }//do bracket
> while(CH!=0);
>
> Mid[i]=int(N/2);
> csMEDIAN=Y[i-2];//for 5 bar median
>
> }//outermost FOR bracket
> GraphXSpace=5;
>
> Plot(Y,"Y",4,8);
> Plot(csMEDIAN,"csMEDIAN",0,8|styleOwnScale);
> Plot(mid,"mid",0,1|styleOwnScale);
> Plot(CH,"CH",5,1|styleOwnScale);
>
> Thanks,
> -CS
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> 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/
|