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

[amibroker] filter last 30 days with O>C, try to sum their O-L



PureBytes Links

Trading Reference Links

Hello,

i am trying to get O-L of the last 30 Bars when O>C, put them in an
array and sort them.

My formula is this:
[code]
Counter = 0;
BC      = 0;
for(i=BarCount-1;i>=0;i--)
{
	if(O[i] > C[i] AND Counter <= 30)
	{
		counter = Counter+1;
		BC[Counter] = BarCount[i]-1;
	}
}
for(i=1;i<=30;i++)
{
	OL[i] = O[BC[i]] - L[BC[i]];
}

//Just to see what's in the arrays
"1  " + WriteVal(BC[1]);"2  " + WriteVal(BC[2]);"3  " +
WriteVal(BC[3]);"4  " + WriteVal(BC[4]);"5  " + WriteVal(BC[5]);
"6  " + WriteVal(BC[6]);"7  " + WriteVal(BC[7]);"8  " +
WriteVal(BC[8]);"9  " + WriteVal(BC[9]);"10 " + WriteVal(BC[10]);
"11 " + WriteVal(BC[11]);"12 " + WriteVal(BC[12]);"13 " +
WriteVal(BC[13]);"14 " + WriteVal(BC[14]);"15 " + WriteVal(BC[15]);
"16 " + WriteVal(BC[16]);"17 " + WriteVal(BC[17]);"18 " +
WriteVal(BC[18]);"19 " + WriteVal(BC[19]);"20" + WriteVal(BC[20]);
"21 " + WriteVal(BC[21]);"22 " + WriteVal(BC[22]);"23 " +
WriteVal(BC[23]);"24 " + WriteVal(BC[24]);"25 " + WriteVal(BC[25]);
"26 " + WriteVal(BC[26]);"27 " + WriteVal(BC[27]);"28 " +
WriteVal(BC[28]);"29 " + WriteVal(BC[29]);"30 " + WriteVal(BC[30]);


"1  " + WriteVal(OL[1]);"2  " + WriteVal(OL[2]);"3  " +
WriteVal(OL[3]);"4  " + WriteVal(OL[4]);"5  " + WriteVal(OL[5]);
"6  " + WriteVal(OL[6]);"7  " + WriteVal(OL[7]);"8  " +
WriteVal(OL[8]);"9  " + WriteVal(OL[9]);"10 " + WriteVal(OL[10]);
"11 " + WriteVal(OL[11]);"12 " + WriteVal(OL[12]);"13 " +
WriteVal(OL[13]);"14 " + WriteVal(OL[14]);"15 " + WriteVal(OL[15]);
"16 " + WriteVal(OL[16]);"17 " + WriteVal(OL[17]);"18 " +
WriteVal(OL[18]);"19 " + WriteVal(OL[19]);"20" + WriteVal(OL[20]);
"21 " + WriteVal(OL[21]);"22 " + WriteVal(OL[22]);"23 " +
WriteVal(OL[23]);"24 " + WriteVal(OL[24]);"25 " + WriteVal(OL[25]);
"26 " + WriteVal(OL[26]);"27 " + WriteVal(OL[27]);"28 " +
WriteVal(OL[28]);"29 " + WriteVal(OL[29]);"30 " + WriteVal(OL[30]);

[/code]

But i get always the same figure in every OL[i].
What is wrong with it and how is it correctly done?
Is it possible at all?

Maybe it would be a lot easier with an ArrayToNum function?

Regards
Robert





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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