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

[amibroker] Problem with using "function" in AFL



PureBytes Links

Trading Reference Links

I need to call a function with parameters, but for some reason I can't
get it to work when using the variables passed into the function. In
the code below, if I explicitly set the variable values, the function
works fine -- executing about 80 trades. If I have them commented out
(and the passed in values are used), the system doesn't execute any
trades. I make no other changes.

I've plotted the values when passed in and they appear to be correct.
What am I missing here? This is AB 4.80.1 although it behaves the same
on older versions as well.

What's also odd is if I plot the "Buy" array, it looks exactly the
same whether or not the variables are explicitly set -- just no trades
get executed when the passed in values are used. At a loss here...

/////////////////////////////////
.... some code to read from a file ...

function rule1(aver,width,percent)
	{

//aver =10;
//width=1.5;
//percent=1.005;

	Bbot = BBandBot(Close,aver,width);
	Buy_cond1 = Close < BBot /percent;
	BuyPrice = Close;
}

if (p11 = 1)
{
//rule1(p12,p13,p14);
rule1(10,1.5,1.005);
}


..... some other code -- nothing touching Buy_cond1 or Buy ....


entrybar = -1;

//Buy = Buy_cond1 AND Buy_cond2 AND Buy_cond3;
Buy = Buy_cond1;

// exit code

for( i = 0; i < BarCount; i++ )
	{
	if( entrybar == -1 AND Buy[ i ] )
		{
		entrybar = i;
		}

	if( entrybar != -1 AND i > entrybar AND Close[ i ] > Close[ entrybar
]+0.02 OR i-entrybar>=20 ) 
		{
		Sell[ i ] = 1;
		SellPrice[ i ] = Close[ i ];
		entrybar = -1;
		}
	else
		{
		Sell[ i ] = 0;
		}
	}






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/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/