DayOpen Straddle for DAX 3-minute timeframe

Category: Strategies By: Paul Created: October 30, 2018, 7:59 AM
October 30, 2018, 7:59 AM
Strategies
26 Comments

A simple concept.

Define the DayOpen using time.

Buy x points above, sellshort x points below the DayOpen.

One position max a day, Long or Short.

ExtraTradeCriteria is optional.

Test DAX 30 Cash, 3 minutes, spread 1, 100k bars

//-------------------------------------------------------------------------
// Main code : Straddle DayOpen
//-------------------------------------------------------------------------

// common rules
DEFPARAM CUMULATEORDERS = false
DEFPARAM PRELOADBARS = 10000

// optional
ExtraTradeCriteria=1

// positionsize and stops
positionsize = 1
sl = 0.60  // % Stoploss
pt = 0.40  // % Profit Target
ts = 0.35  // % MFETrailing

// indicator settigns
NOP=15 //number of points
TimeOpen=090000

// day & time rules
ONCE entertime = TimeOpen
ONCE lasttime  = 100000
ONCE closetime = 240000 // greater then 23.59 means it continues position overnight
ONCE closetimeFriday=173000

tt1 = time >= entertime
tt2 = time <= lasttime
tradetime = tt1 and tt2

DayForbidden = 0 // 0=sunday
df = dayofweek <> dayforbidden

// setup number of trades intraday
if IntradayBarIndex = 0 then
 longtradecounter = 0
 Shorttradecounter = 0
 Tradecounter=0
endif

// general criteria
GeneralCriteria =  tradetime and df

// trade criteria
tcLong =   countoflongshares < 1 and longtradecounter < 1 and tradecounter <1
tcShort =  countofshortshares < 1 and shorttradecounter < 1 and tradecounter <1

// indicator criteria
If time = TimeOpen then
 DayOpen=open
endif

if IntradayBarIndex = 0 then
 lx=0
 sx=0
endif

if high > DayOpen+NOP then
 lx=1
else
 lx=0
endif

if low < DayOpen-NOP then
 sx=1
else
 sx=0
endif

// trade criteria extra
min1 = MIN(dhigh(0),dhigh(1))
min2 = MIN(dhigh(1),dhigh(2))

max1 = MAX(dlow(0),dlow(1))
max2 = MAX(dlow(1),dlow(2))

If ExtraTradeCriteria then
 tcxLong = high < MIN(min1,min2)
 tcxShort = low > MAX(max1,max2)
else
 tcxLong = high
 tcxShort = low
endif

// long entry
If GeneralCriteria then
 if lx and tcLong and tcxLong then
  buy positionsize contract at market
  longtradecounter=longtradecounter + 1
  tradecounter=tradecounter+1
 endif
endif

// short entry
If GeneralCriteria then
 if sx and tcShort and tcxShort then
  sellshort positionsize contract at market
  shorttradecounter=shorttradecounter + 1
  tradecounter=tradecounter+1
 endif
endif

// MFETrailing
trailingstop = (tradeprice/100)*ts
if not onmarket then
 MAXPRICE = 0
 MINPRICE = close
 priceexit = 0
endif
if longonmarket then
 MAXPRICE = MAX(MAXPRICE,close)
 if MAXPRICE-tradeprice(1)>=trailingstop*pipsize then
  priceexit = MAXPRICE-trailingstop*pipsize
 endif
endif
if shortonmarket then
 MINPRICE = MIN(MINPRICE,close)
 if tradeprice(1)-MINPRICE>=trailingstop*pipsize then
  priceexit = MINPRICE+trailingstop*pipsize
 endif
endif
If onmarket and priceexit>0 then
 sell at market
 exitshort at market
endif

// exit at closetime
If onmarket then
 if time >= closetime then
  sell at market
  exitshort at market
 endif
endif

// exit friday at set closetime
if onmarket then
 if (CurrentDayOfWeek=5 and time>=closetimefriday) then
  sell at market
  exitshort at market
 endif
endif

// build-in exit
SET TARGET %PROFIT pt
SET STOP %LOSS sl

GRAPH 0 coloured(300,0,0) AS "zeroline"
GRAPH (positionperf*100)coloured(0,0,0,255) AS "PositionPerformance"

Download
Filename: DailyOpen-Straddle-DAX-3min.itf
Downloads: 1081
Paul Master
I usually let my code do the talking, which explains why my bio is as empty as a newly created file. Bio to be initialized...
Author’s Profile

Comments

Logo Logo
Loading...