Author Topic: Help with coding for buying on a breakout's throwback for backtast  (Read 51736 times)


  • Newbie
  • *
  • Posts: 2
    • View Profile
I have been testing a strategy for buying signals on amibroker`s backtest. But I would like to modify the formula for a system I think could generate better results.
I have been trying to write the code myself but i am not beeing able to write it properly. I wonder if anyone could help me.
The code I have been using is the following:

Buy = H > Ref(HHV(H,38),-1);
BuyPrice = Ref(HHV(H,38),-1);

This makes the buy signal righ at the price of a breakout. What I want to do is to make the following changes:
The buy signal would happen when the price closes above the hhv 38 value. And then the actual buy would happen when / if the price returns in a throwback on that exact previous HHV 38 price that gave the signal.
I have sent a picture explaning what I mean.

Thank you for your help!