Ive got much appreciated help from Roberto coding a DJ open-breakout strategy. I would like to get some help adding US daylight savings time or EU summer/winter time snippet code to this strategy.
DEFPARAM CumulateOrders = FALSE
IF Not OnMarket THEN
MyExit = 0
ELSE
c1 = 0
ENDIF
// ADR Average Daily Range
MyADR = average[20,0](Dhigh(1) - Dlow(1))
//
IF (Time = 000000) OR ((Time > 000000) AND (Time < Time[1])) THEN
MyHI = high
MyLO = low
c1 = 0
ENDIF
IF Time <= 142900 THEN
MyHI = max(MyHI,high)
MyLO = min(MyLO,low)
MyRange = MyHI - MyLO
c1 = ((MyRange / MyADR) * 100) < x //75
ENDIF
IF Time >= 142900 AND c1 THEN
BUY 0.2 Contract AT MyHI + y * pipsize STOP
SELLSHORT 0.2 Contract AT MyLO - y * pipsize STOP
SET TARGET pPROFIT PL //40
SET STOP pLOSS SL //80
ENDIF
IF MyExit = 0 THEN
IF (LongOnMarket AND (close - TradePrice) >= t * pipsize) OR (ShortOnMarket AND (TradePrice - close) >= tS * pipsize) THEN //27.5 37.5
MyExit = TradePrice
ENDIF
ENDIF
IF MyExit > 0 THEN
SELL AT MyExit STOP
EXITSHORT AT MyExit STOP
ENDIF
//GraphOnPrice TradePrice coloured(0,0,255,255)
//GraphOnPrice MyHI coloured(0,128,0,200)
//GraphOnPrice MyLO coloured(255,0,0,255)
//Graph close - TradePrice
//Graph c1
//Graph MyADR
//Graph MyRange
Ive found this US daylight savings code in MOD:
// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //
mar = month = 3 // MONTH START
nov = month = 11 // MONTH END
IF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THEN
USDLS=010000
ELSE
USDLS=0
ENDIF
once shortStep = 0
once openStrongLong = 0
if not onmarket or (time <= 143000 - USDLS and time >= 210000 - USDLS) then
shortStep = 0
openStrongLong = 0
endif
//detect strong direction for market open
once rangeOK = 50
once tradeMin = 500
IF (time >= 144000 - USDLS) AND (time <= 144000 + tradeMin - USDLS) THEN
openStrongLong = close > open AND close - open > rangeOK
ENDIF
I dont get it to work, since results are exactly the same.
I think this should the the correct snippet (for 2022):
// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //
DSTstart = 20220313
DSTend = 20221106
IF OpenDate >= DSTstart AND OpenDate < DSTend THEN
USDLS=010000
ELSE
USDLS=0
ENDIF
you’ll have to change it every year.
thanks roberto! but results on 200k 1m and 5m bars shows exactly the same results.
I think you should add USDLS, instead of subtracting it.
okay, tried to change it up in many ways, but dont understand what you mean by add instead of subtract.
Instead of using “-“, I think “+” would be more apppropriate.
// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //
DSTstart = 20220313
DSTend = 20221106
IF OpenDate >= DSTstart AND OpenDate < DSTend THEN
USDLS=010000
ELSE
USDLS=0
ENDIF
but there are no “-” in the code? sorry for not understanding