ONCE EntryDay = 24
ONCE MonthDay1 = 5
ONCE MonthDay2 = 10
ONCE Tally = 0
ONCE AboveFlag = 0
// ate the beginning of each year save the closing price of the previous year
IF OpenYear <> OpenYear[1] THEN
YearClose = close[1]
AboveFlag = 0
ENDIF
// at the beginning of each Month reset the tally of trading days to zero
IF (OpenMonth <> OpenMonth[1]) THEN
Tally = 0
ENDIF
// each new day updates the tally
IF (OpenDay <> OpenDay[1]) THEN
Tally = Tally + 1
ENDIF
// between day 5 and day 10 check if the price is above the previous Year's closing price
IF (Tally >= MonthDay1) AND (Tally <= MonthDay2) AND (OpenMonth = 1) THEN
AboveFlag = max(AboveFlag,close > YearClose)
ENDIF
// enter after trading day 24 if conditions are met
IF (OpenDay >= EntryDay) AND AboveFlag AND Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// TAKE PROFIT: exit when the price closes below DONCHIAN UP
ONCE p = 20
Upper = HIGHEST[p](HIGH[1])
TPflag = close > Upper
IF LongOnMarket AND TPflag THEN
SELL AT MARKET
ENDIF
// STOP LOSS: exit when the price closes below (Sma200 - 3%)
Sma200 = average[200,0](close) * 0.97
SLflag = close < Sma200
IF LongOnMarket AND SLflag THEN
SELL AT MARKET
ENDIF
// debugging section
//graphonprice YearClose coloured("Blue")
//graphonprice Sma200 coloured("Fuchsia")
//graph Tally
//graph AboveFlag