Hello Alex,

 

i have modified your code but haven’t tested it.  I have also modified the
buyprice to get the correct price in case of a gap.

 

Longsetup = {setup code here};
StopBuy = 1.005 * valuewhen(LongSetup,H); 
Buy = barssince(Longsetup)<=5 AND H>StopBuy;
BuyPrice = max(open,StopBuy);

 

Thomas

www.patternexplorer.com

 

 

Von: amibroker@yahoogroups.com [mailto:[EMAIL PROTECTED] Im Auftrag
von dralexchambers
Gesendet: Mittwoch, 31. Jänner 2007 11:02
An: amibroker@yahoogroups.com
Betreff: [amibroker] Backtester buy and buyprice

 

Hi,

In my backtester code I am trying to achieve the following:

1. Wait for a longsetup condition, then
2. Set a buy order for the next bar: buyprice is the High of setup 
day + (0.5% of the high price)
3. Cancel the buy order if it is not fulfilled in 5 days from setup 
day

The code I have is the following:

Longsetup = {setup code here};
StopBuy = 1.005 * H; 
Buy = Longsetup AND H>StopBuy;
BuyPrice = StopBuy;

But this doesn't seem to work.

Can anyone suggest - thanks.

 

Reply via email to