This is a simple strategy, just an idea that seems to work. No MoneyManagement or Position Size. Optimized for DAX 5 minutes.
It looks for breakouts in Donchian Channel for going in the opposite direction, trying to catch breaout failures so kind of mean reversion system. There is no Stop, when the losses reach 10xATR it changes (“flip”) direction to catch the trend that seems to be forming. Also finish tradings at 20:30, kind of time stop with no overnight.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
// System parameters DEFPARAM CumulateOrders = False DEFPARAM PRELOADBARS = 20 //DEFPARAM FLATBEFORE = 000000 DEFPARAM FLATAFTER = 203000 // Condiciones de entrada myUpperband, myLowerband, ignored = CALL "Donchian (canal)"[8] c1 = close < myLowerband c2 = close > myUpperband // Conditions for Entry of Long Positions IF c1 AND NOT ONMARKET THEN BUY 1 CONTRACTS AT MARKET ELSIF SHORTONMARKET AND (CLOSE-TRADEPRICE) > FlipPosition THEN BUY 1 CONTRACTS AT MARKET ENDIF // Conditions for Entry of Short Positions IF c2 AND NOT ONMARKET THEN SELLSHORT 1 CONTRACTS AT MARKET ELSIF LONGONMARKET AND (CLOSE-TRADEPRICE) < -FlipPosition THEN SELLSHORT 1 CONTRACTS AT MARKET ENDIF // Loss, Profit //SET STOP LOSS 15*AverageTrueRange[10](close) SET TARGET PROFIT 15*AverageTrueRange[12](close) FlipPosition = 10*AverageTrueRange[12](close) // END |
Donchian channel indicator (should be set as a new indicator)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//N=10 //variable to add as an external one IF BarIndex > N THEN upperBand = Highest[N](High) lowerBand = Lowest[N](Low) middleBand = (upperBand + lowerBand)/2 ELSE upperBand = Undefined lowerBand = Undefined middleBand = Undefined ENDIF RETURN upperBand[1] AS "Upper band" , lowerBand[1] AS "Lower band" , middleBand[1] COLOURED(0,255,0) AS "Middle band" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Thanks Nicolas for adding the indicator, I somehow thougt it was one of the default indicators 🙂
The one you used is not, that’s why I added it. What is the timezone for your DAX instrument please? While testing it, I did not get exactly the same results even if it was not bad at all.
My timezone is UTC+00:00… and I think that´s the backtest timezone
Thanks for the idea. Personally I don’t like to enter trades without a hard stop and also I don’t like to trade the DAX outside the official kassa times – because the spread is then wider than 1p.
So my modified code looks like this:
// System parameters
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 20
DEFPARAM FLATBEFORE = 090000
DEFPARAM FLATAFTER = 180000
STOPPER = 100
// Condiciones de entrada
myUpperband, myLowerband, ignored = CALL “Donchian (canal)”[8]
c1 = close myUpperband
// Conditions for Entry of Long Positions
IF c1 AND NOT ONMARKET THEN
BUY 1 CONTRACTS AT MARKET
SET STOP $LOSS STOPPER
ELSIF SHORTONMARKET AND (CLOSE-TRADEPRICE) > FlipPosition THEN
BUY 1 CONTRACTS AT MARKET
SET STOP $LOSS STOPPER
ENDIF
// Conditions for Entry of Short Positions
IF c2 AND NOT ONMARKET THEN
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP $LOSS STOPPER
ELSIF LONGONMARKET AND (CLOSE-TRADEPRICE) < -FlipPosition THEN
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP $LOSS STOPPER
ENDIF
// Loss, Profit
//SET STOP LOSS 15*AverageTrueRange[10](close)
//SET TARGET PROFIT 15*AverageTrueRange[12](close)
FlipPosition = 10*AverageTrueRange[14](close)
// END
If you see room for improvements, feel free to post here. Ah, I switched to 1min timeframe 🙂
Masala, thanks for your contribution. I don´t like the offmarket spreads neither 😉 I understand your waryness of non hard stops but in this case seems to hurt the profit quite a bit.
Be aware that in your code the c1 lack of “>” symbol and the c2 is missing completely (“c2=close<myLowerband")
Tempus, me da un error al validar el codigo, sobre la variable N.
Al crear el indicador me pide darle valor, y luego en el codigo me dice que debe ir sin valor.
gracias
Hi Uveus,
I am guessing you inserted the code of the indicator into the system code, is that right? If so, don´t need to, just import both the indicator and the system and run the system, it takes itself the code from the indicator.
If this is not your problem I dont understand your question.
———————————————————
Te contesto en inglés porque tenemos que escribir en el mismo idioma que el foro para que todo el mundo lo entienda, si no nos dan un toque. Si no entiendes la respuesta en inglés escríbeme un correo, creo que puedes desde mi perfil y ya te contesto en español.