This strategy is one which takes advantage of only long opportunities in the SA Top 40 (SAF40) Index also known as the ALSI.
The code is testing if price is making new highs and lows before setting a new long order at market.
Target and loss levels are based upon the size of a factorized ATR 14 periods. Take profit size is larger than the stop loss one.
//-------------------------------------------------------------------------
// Main code : Wisper Breakout
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 0
// Conditions to enter long positions
c1 = (close[3] <= high[4])
c2 = (close[3] >= low[4])
c3 = (close[2] <= high[3])
c4 = (close[2] >= low[3])
c5 = (close[1] <= high[2])
c6 = (close[1] >= low[2])
if high[4] > high[3] then
ath = high[4]
else
ath = high[3]
endif
if high[2] > ath then
ath = high[2]
else
ath = ath
endif
if high[1] > ath then
ath = high[1]
else
ath = ath
endif
c7 = (close > ath)
IF c1 AND c2 AND c3 AND c4 AND c5 AND c6 AND c7 AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
atr = AverageTrueRange[14](close)
SET STOP pLOSS atr * 2
SET TARGET pPROFIT atr * 2.5