0

I have coded a Bollinger Band breakout strategy with an Index filter using Amibroker as:

SetOption("MaxOpenPositions", 20);
SetPositionSize(5, spsPercentOfEquity);

Index = Foreign("$XAO", "C", True);
IndexMA = MA(Index, 75);

BollyTop = BBandTop(C, 100, 3);
BollyBot = BBandBot(C, 100, 1);

Buy = C >= BollyTop AND Index >= IndexMA;
Sell = C <= BollyBot;

I want to modify it to generate a buy if there was a bollinger band breakout in the previous 7 days and today's close is higher. Any suggestions?

Dave Barker
  • 6,303
  • 2
  • 24
  • 25

1 Answers1

1

You might try:

//close 7 days ago
C7 = Ref(C,-7);

//high 7 days ago
H7 = Ref(H,-7);

//Bollinger band top 7 days ago
B7 = Ref(BollyTop, -7);

Buy = C >= C7 and H7 >= B7;
Sethmo011
  • 575
  • 7
  • 20