This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

Amibroker code for specific breakout strategy

Good evening..long time no see. Can anyone test the syntax of this code for me?


Code:
// Set the account equity and stop loss percentage
equity = 250000;
stopLossPercent = 1;

// Define the chart patterns and their breakout signals
headAndShoulders = (Ref(high, 1) < Ref(high, 2)) and (Ref(high, 2) > Ref(high, 3)) and (Ref(low, 1) > Ref(low, 2)) and (Ref(low, 2) < Ref(low, 3));
doubleTop = (Ref(high, 1) < Ref(high, 2)) and (Ref(high, 2) > Ref(high, 3)) and (Ref(high, 3) < Ref(high, 4)) and (Ref(high, 4) > Ref(high, 5));
doubleBottom = (Ref(low, 1) > Ref(low, 2)) and (Ref(low, 2) < Ref(low, 3)) and (Ref(low, 3) > Ref(low, 4)) and (Ref(low, 4) < Ref(low, 5));
ascendingTriangle = (Ref(low, 1) > Ref(low, 2)) and (Ref(low, 2) > Ref(low, 3)) and (Ref(low, 3) > Ref(low, 4)) and (Ref(high, 1) < Ref(high, 2)) and (Ref(high, 2) < Ref(high, 3)) and (Ref(high, 3) < Ref(high, 4));
descendingTriangle = (Ref(high, 1) < Ref(high, 2)) and (Ref(high, 2) < Ref(high, 3)) and (Ref(high, 3) < Ref(high, 4)) and (Ref(low, 1) > Ref(low, 2)) and (Ref(low, 2) > Ref(low, 3)) and (Ref(low, 3) > Ref(low, 4));
flag = (Ref(high, 1) < Ref(high, 2)) and (Ref(high, 2) < Ref(high, 3)) and (Ref(high, 3) < Ref(high, 4)) and (Ref(low, 1) > Ref(low, 2)) and (Ref(low, 2) > Ref(low, 3)) and (Ref(low, 3) > Ref(low, 4));
pennant = (Ref(high, 1) > Ref(high, 2)) and (Ref(high, 2) > Ref(high, 3)) and (Ref(high, 3) > Ref(high, 4)) and (Ref(low, 1) < Ref(low, 2)) and (Ref(low, 2) < Ref(low, 3)) and (Ref(low, 3) < Ref(low, 4));

// Set the stop loss and target
stopLoss = equity * stopLossPercent / 100;
target = ATR(14);

// Buy on a breakout
if (headAndShoulders or doubleTop or doubleBottom or ascendingTriangle or descendingTriangle or flag or pennant)
    Buy(stopLoss, target, TrailingStop(4));
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more...