Wing's Resistance Breacher (DAX-30m)

Category: Strategies By: Wing Created: June 12, 2017, 7:24 AM
June 12, 2017, 7:24 AM
Strategies
38 Comments

This is a system I made over 6 months ago and have been running live on the DAX 30m. It is based on identifying tops or bottoms in the price. When a breakout from these levels occur it tries to capture the movement, in either direction. It averages 1.55 trades/day and is flat overnight. It employs some simple filters and varied position sizes.

Important things to know:

  • The system is heavily optimized, in that there are many moving parts, but it has performed out of sample since Nov 2, 2016. You may want to optimize it again if you plan on running it.
  • System is backtested on a spread of 1, but 1.3 or so may be more accurate.
  • I have also used similar systems on lower timeframe DAX (10m and 15m), and it can be optimized for other markets.
  • If you do optimize, run an OOS or live demo test before trying to run it live. I take no responsibility what you do with the code (unless you make a profit of course).
  • This system is in many ways a guide on how to NOT program a strategy, but I only want to share systems that I have run live for a long time and trusted with my own money.

I can answer your questions in the comments.

Strategy code:

/////////////////////////////////////
// Wing's Resistance Breacher
// DAX 30m timeframe. Last optimized Nov 2, 2016
//
// Made by user "Wing" of ProRealCode.com
// https://www.prorealcode.com/user/wing/
/////////////////////////////////////

defparam cumulateorders=false

stoch=Stochastic[8,3](close)
mm2=exponentialaverage[8]


// Position size module, 2 is the default. Can be adapted to scale with the profits
/////////////////////////////////////////////////////////////////////////

positionsize=2//+2*round((strategyprofit*2)/10000)
maybe= positionperf(1)<0
losses = positionperf(1)<0 and positionperf(2)<0

if losses then
 PositionSize  = 3//+3*round((strategyprofit*2)/10000)
elsif not losses then
 PositionSize  = 2//+2*round((strategyprofit*2)/10000)
Endif
if maybe and not losses then
 positionsize=3//+3*round((strategyprofit*2)/10000)
endif
if positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0 then
 positionSize=2//+2*round((strategyprofit*2)/10000)
endif
if positionperf(1)>0 and positionperf(2)>0 then
 positionsize=1//+1*round((strategyprofit*2)/10000)
endif

if positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0 and positionperf(4)<0 and positionperf(5)<0 and positionperf(6)<0 then
 positionsize=5
endif

if positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0 and positionperf(4)>0 and positionperf(5)>0 and positionperf(6)>0 then
 positionsize=1
endif

///////////////////////////////////////////////////////////////////////////////////

// Optimization variables
////////////////////////////////////////////////////////////////////////////////
bul=3.5 //long, SL
but=12 // long, PT
shl=6.5 // Short, SL
sht=3.5 // Short PT

lowt=65 // stochastic filter
test=45 //stochastic filter
mmlean=1.0002 // Moving average lean filter
mmlean2=1.0005 // Moving average lean filter

// moving averages
yy=47
tt=53

////////////////////////////////////////////////////////////////////////////////

minSL=20 // minimum SL
lasttime=210000 // last time to open position
which=10 // Parameter of the ATR for SL/TP

once mabot=0
once mabotz=0
once maboty=0
once mabotzy=0

if time<lasttime then

 if time>080000 and dayofweek>1 and stoch>test and mm2[1]*mmlean<mm2 and averagetruerange[which]*bul> minSL and go=1 and mm2[1]*mmlean2>mm2 and close>MaBotzy and onmarket=0 then
  buy PositionSize lot at market
  mystop=averagetruerange[which]*bul
  myprofit=averagetruerange[which]*but
  go=0
 endif

 if time>080000 and stoch<Lowt and mm2*mmlean<mm2[1] and go=1 and mm2*mmlean2>mm2[1] and averagetruerange[which]*shl>minSL and close<MaBotz and onmarket=0 then
  sellshort PositionSize lot at market
  mystop=averagetruerange[which]*shl
  myprofit=averagetruerange[which]*sht
  go=0
 endif
endif



// Identifying tops/bottoms in price
//////////////////////////////////////////////////////////////////////

if close<average[yy] and close<exponentialaverage[tt] and MaBot=0 then
 MaBot=close
 go=1
endif
if close<average[yy] and close<exponentialaverage[tt] and Mabot>0 and close<MaBot then
 mabot=close
endif

if close<average[yy] and close<exponentialaverage[tt] and Mabot>0 and close>MaBot then
 MaBotz=MaBot
endif

if close>average[yy] or close>exponentialaverage[tt] then
 MaBot=0
 MaBotz=0
endif

if close>average[yy] and close>exponentialaverage[tt] and MaBoty=0 then
 MaBoty=close
 go=1
endif
if close>average[yy] and close>exponentialaverage[tt] and Maboty>0 and close>MaBoty then
 maboty=close
endif

if close>average[yy] and close>exponentialaverage[tt] and Maboty>0 and close<MaBoty then
 MaBotzy=MaBoty
endif

if close<average[yy] or close<exponentialaverage[tt] then
 MaBoty=0
 MaBotzy=0
endif

/////////////////////////////////////////////////////////////////////////////////////

// Sell at end of day

if time>215300 then
 exitshort at market
 sell at market
endif

// Earlier friday exit. Insurance against accidental holding over weekends

if dayofweek=5 and time>212300 then
 exitshort at market
 sell at market
endif

set target profit myprofit
set stop loss mystop

Download
Filename: Wings-resistance-breacher.itf
Downloads: 1102
Wing Veteran
I mostly trade DAX. My favorite strategy tool: Machine learning (yes, possible in ProOrder+ProBuilder). I like to answer questions about coding.
Author’s Profile

Comments

Logo Logo
Loading...