TIMEFRAME (weekly, updateonclose)
// Swing High - Low
ONCE LookBack = 50 //50 bars to make sure SWINGs have enough empty space to their left
ONCE MaxBars = 2 //2 bars to keep holding SWING valid
ONCE MaxHigh = 0
ONCE MinLow = 0
// Swing HIGH
Hi = high[1] = highest[LookBack](high)
Hi = Hi AND low[1] = highest[3](low)
Hi = Hi AND close < open
// Swing LOW
Lo = high[1] = lowest[3](high)
Lo = Lo AND low[1] = lowest[LookBack](low)
Lo = Lo AND close >= open
//
IF Hi OR Lo THEN
MaxHigh = highest[3](high)
MinLow = lowest[3](low)
ENDIF
x = summation[MaxBars](Hi)
y = summation[MaxBars](Lo)
////////////////////////////////////////////////////////////////////////
TIMEFRAME (default) //2 or 4-hour TF suggested
ONCE nLots = 1
ONCE Multiplier = 4.0 //4.0
DaysForbidden = OpenDayOfWeek < 1 OR OpenDayOfWeek > 5
TimeForbidden = OpenTime < 090000 OR OpenTime > 190000
// LONG trades
a = y AND close < MaxHigh AND close > MinLow
IF a AND Not OnMarket AND Not DaysForbidden AND Not TimeForbidden THEN
SL = (close - MinLow) / pipsize
TP = SL * Multiplier
BUY nLots CONTRACT AT MARKET
ENDIF
// SHORT trades
b = x AND close > MinLow AND close < MaxHigh
IF b AND Not Onmarket AND Not DaysForbidden AND Not TimeForbidden THEN
SL = (MaxHigh - close) / pipsize
TP = SL * Multiplier
SELLSHORT nLots CONTRACT AT MARKET
ENDIF
SET TARGET pPROFIT TP
SET STOP pLOSS SL