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

[amibroker] using indicator in Script for backtesting



PureBytes Links

Trading Reference Links

Hello All,

I created a indicator which I called in my script during backtest. 
When I am backtest it it runs extremely slow. I takes forever if I 
try to optimize it.

I think it is because at each bar, I calls the function again and 
again causing massive resource usage. Does anyone know how to access 
it at a specific bar or recode to better use the function.

THanks,
Chris




function numUpDown(periods)
{
  	for(t=0;t<BarCount;t++)
	{
		Value = 0;

		if(t >= periods)
		{
			x = t;
			for(i=0; i<periods;i++)
			{				
				if( C[x] > O[x] )
					Value++;
				else if(C[x] < O[x] )
					Value--;

				if( C[x] > C[x-1] )
					Value++;
				else if(C[x] < C[x-1] )
					Value--;

				x--;
			}
			
		}

		result[t] = Value;

	}

	return result;
}

upDown = numUpDown(10);


Buy = 	AND (UpDown > 0);
BuyPrice = O;
Buy = (Ref(Buy, -1));

Sell = C>ref(c,-1);
SellPrice =  O;
Sell = Ref(Sell,-1); 





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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

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