Hello!
Have been building a strategy in the last couple of days and i have never contributed really to the forum with a strategy so i thought i could share one now
This is mostly how a tend to build strategies, the frame with trends on higher timeframe and only exit with TS.
it is built and optimized on on DAX 5 min with 200k bars, might be a little over optimized over 1M bars
but i hope someone gets anyhing out of this and maybe a new take on building strategies (or maybe im just like everyone else)
Would be fun to see someone else try to make something out of it.
the concept of the entry is basicly to enter when the MA has turnt up significantly wich one could interpret as strenght in the move
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
//MONEY MANAGEMENT DAX II
MM = 0 // = 0 for optimization
if MM = 0 then
positionsize = 2
ENDIF
if MM then
MinSize = 2 // IG minimum position size allowed
MaxSize = 1050 // IG tier 2 margin limit
ProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currency
DD = 500 //MinSize drawdown in instrument currency
Multiplier = 3 //drawdown multiplier
Capital = DD * Multiplier
Equity = Capital + ProfitAccrued + StrategyProfit
PositionSize = Max(MinSize, Equity * (MinSize/Capital))
if positionsize > MaxSize then
positionsize = MaxSize
endif
PositionSize = Round(PositionSize*100)
PositionSize = PositionSize/100
ENDIF
TIMEFRAME (daily, updateonclose)
Cond5 = Average[10,8] > Average[10*1.1,8]
TIMEFRAME (60 MINUTES, updateonclose)
Cond4 = Average[11,6] > Average[11*1.2,6]
TIMEFRAME (10 MINUTES, updateonclose)
Cond3 = Average[23,2] > Average[23*1.35,2]
TIMEFRAME (default, UPDATEONCLOSE)
//Angle of Moving Average
MM = Average[20,5](close)
ADJASUROPPO = (MM-MM[10]*pipsize) / 10
ANGLE = (ATAN(ADJASUROPPO))
Difference = Angle - Angle[1]
Cond2 = Difference > 35
//VWAP
if day<>day[1] then
d=0
else
d=d+1
if volume >0 then
VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
endif
endif
Cond1 = close > VWAP
Condbuy = Cond1 and Cond2 and Cond3 and Cond4 and Cond5
IF Condbuy THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
//****************************************************************************
once enableSL = 1 // stop loss
once enableTS = 1 // trailing stop
once enableBE = 0 // breakeven stop
SL = 1.4 // % stop loss
TS = 0.3 // % trailing stop
BESG = 0 // % break even stop gain
BESL = 0 // % break even stop level
// underlaying security / index / forex
// profittargets and stoploss have to match the lines
// 0.01 FOREX [i.e. GBPUSD=0.01]
// 1.00 SECURITIES [i.e. aapl=1 ;
// 100.00 INDEXES [i.e. dax=100]
// 100=XAUUSD
// 100=CL US Crude
// DAX=100
underlaying=100
// trailing stop
if enableTS then
trailingstop = (tradeprice/100)*TS
if not onmarket then
maxprice=0
minprice=close
priceexit=0
endif
if ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
maxprice=0
minprice=close
priceexit=0
endif
if longonmarket then
maxprice=max(maxprice,close)
if maxprice-tradeprice(1)>=(trailingstop) then
priceexit=maxprice-(trailingstop/(underlaying/100))*pointsize
endif
endif
if shortonmarket then
minprice=min(minprice,close)
if tradeprice(1)-minprice>=(trailingstop) then
priceexit=minprice+(trailingstop/(underlaying/100))*pointsize
endif
endif
if longonmarket and priceexit>0 then
sell at priceexit stop
endif
if shortonmarket and priceexit>0 then
exitshort at priceexit stop
endif
endif
// break even stop
if enableBE then
if not onmarket then
newsl=0
endif
if ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
newsl=0
endif
if longonmarket then
if close-tradeprice(1)>=(((tradeprice(1)/100)*BESG)/(underlaying/100))*pointsize then
newsl=tradeprice(1)+(((tradeprice(1)/100)*BESL)/(underlaying/100))*pointsize
endif
endif
if shortonmarket then
if tradeprice(1)-close>=(((tradeprice(1)/100)*BESG)/(underlaying/100))*pointsize then
newsl=tradeprice(1)-(((tradeprice(1)/100)*BESL)/(underlaying/100))*pointsize
endif
endif
if longonmarket and newsl>0 then
sell at newsl stop
endif
if shortonmarket and newsl>0 then
exitshort at newsl stop
endif
endif
// to set & display stoploss
if enableSL then
set stop %loss SL
endif