Trend surfer DAX modified
Forums › ProRealTime English forum › ProOrder support › Trend surfer DAX modified
- This topic has 45 replies, 6 voices, and was last updated 6 years ago by irioton.
-
-
03/19/2018 at 12:46 PM #65668
Hi guys !
This is the first system I post here.
I made my own version of Reiners Trend surfer DAX, whith Nicolas´ TDI indicator and my own parameters but the backtest doesn´t work,
I think it might be because of the trailing stop and take profit which are variables (a and b in the code) that I want to optimize because this will be how I exit the trades, no exit on signal, just sl/tp.
The message just says “an error occured” but doesn´t say where or why.
Here´s the code :
Trend surfer DAX mofified1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071// Trend Surfer DAX Modified// code-ParameterDEFPARAM FlatAfter = 173000DEFPARAM FlatBefore = 093000// DAX trading windowONCE BuyTimeMorning = 093000ONCE SellTimeMorning = 110000ONCE BuyTimeAfternoon = 130000ONCE SellTimeAfternoon = 170000ONCE lengthRSI = 13ONCE lengthband = 34ONCE lengthrsipl = 3ONCE lengthtradesl = 7ONCE lineup = 68ONCE linemid = 50ONCE linedown = 32// trading parameterONCE PositionSize = 1ONCE sl = aONCE tp = b*sl// emergency stopIF STRATEGYPROFIT <-500 THENQUIT ENDIF// position management during trading windowIF (Time >= BuyTimeMorning AND Time <= SellTimeMorning) OR (Time >= BuyTimeAfternoon AND Time <= SellTimeAfternoon) THEN// calculate TDI indicatorr = rsi[lengthrsi](close)ma = average[lengthband](r)offs = (1.6185 * std[lengthband](r))blueup = ma+offsbluedn = ma-offsjaune = (blueup+bluedn)/2vert = average[lengthrsipl](r)rouge = average[lengthtradesl](r)// open position// longIF Not ONMARKET AND rouge<bluedn AND vert CROSSES OVER rouge OR rouge<linedown AND vert CROSSES OVER rouge THENBUY PositionSize CONTRACT AT MARKETENDIFIF Not ONMARKET AND rouge>linemid AND vert CROSSES OVER rouge THENBUY PositionSize CONTRACT AT MARKETENDIFIF Not ONMARKET AND rouge CROSSES OVER jaune THENBUY PositionSize CONTRACT AT MARKETENDIF// shortIF Not ONMARKET AND rouge>blueup AND vert CROSSES UNDER rouge OR rouge>lineup AND vert CROSSES UNDER rouge THENSELL PositionSize CONTRACT AT MARKETENDIFIF Not ONMARKET AND rouge<linemid AND vert CROSSES UNDER rouge THENSELL PositionSize CONTRACT AT MARKETENDIFIF Not ONMARKET AND rouge CROSSES UNDER jaune THENSELL PositionSize CONTRACT AT MARKETENDIF// stop and profitSET STOP pTRAILING slSET TARGET pPROFIT tpENDIFcan someone help please ?
03/19/2018 at 12:52 PM #65672Remove ENDIF from line 28 and place it at line 29.
03/19/2018 at 1:41 PM #65677Okay ! It does work now (the backtest not the system…yet) thank you ! .
I´ve got another problem now (I put fixed sl/tp for now) : the system only goes long and cumulates orders, I don´t get it !
It never goes short and sometimes it takes 2 long positions instead of one.
I tried to fixe the problem and put EXITs on trades at market when it should reverse, but it doesn´t work, any ideas ?
Here´s the modified code :
Exit positions1234567891011121314151617181920212223// open position// longIF Not ONMARKET AND rouge<bluedn AND vert CROSSES OVER rouge OR rouge<linedown AND vert CROSSES OVER rouge OR rouge>linemid AND vert CROSSES OVER rouge OR rouge CROSSES OVER jaune THENIF SHORTONMARKET THENBUY AT MARKETENDIFBUY PositionSize CONTRACT AT MARKETENDIF// shortIF Not ONMARKET AND rouge>blueup AND vert CROSSES UNDER rouge OR rouge>lineup AND vert CROSSES UNDER rouge OR rouge<linemid AND vert CROSSES UNDER rouge OR rouge CROSSES UNDER jaune THENIF LONGONMARKET THENSELL AT MARKETENDIFSELL PositionSize CONTRACT AT MARKETENDIF// stop and profitSET STOP pTRAILING slSET TARGET pPROFIT tpENDIF03/19/2018 at 1:49 PM #6568003/19/2018 at 2:03 PM #6568403/19/2018 at 2:12 PM #6568603/19/2018 at 2:31 PM #65688wow I didn´t know that, thank you !
I am sorry to waste your time with beginners problems,
The good thing is that I have an edge now ! Yeeeaahh ! I just need to optimise sp/tp
so here´s the code for now:
the code1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162// Trend Surfer DAX ModifiedDEFPARAM CumulateOrders = False// code-ParameterDEFPARAM FlatAfter = 173000DEFPARAM FlatBefore = 090500// DAX trading windowONCE BuyTimeMorning = 090500ONCE SellTimeMorning = 110000ONCE BuyTimeAfternoon = 130000ONCE SellTimeAfternoon = 170000ONCE lengthRSI = 13ONCE lengthband = 34ONCE lengthrsipl = 3ONCE lengthtradesl = 7ONCE lineup = 68ONCE linemid = 50ONCE linedown = 32// trading parameterONCE PositionSize = 1ONCE sl = 50ONCE tp = 50// emergency stopIF STRATEGYPROFIT <-500 THENQUITENDIF// position management during trading windowIF (Time >= BuyTimeMorning AND Time <= SellTimeMorning) OR (Time >= BuyTimeAfternoon AND Time <= SellTimeAfternoon) THEN// calculate TDI indicatorr = rsi[lengthrsi](close)ma = average[lengthband](r)offs = (1.6185 * std[lengthband](r))blueup = ma+offsbluedn = ma-offsjaune = (blueup+bluedn)/2vert = average[lengthrsipl](r)rouge = average[lengthtradesl](r)// open position// longIF Not ONMARKET AND rouge<bluedn AND vert CROSSES OVER rouge OR rouge<linedown AND vert CROSSES OVER rouge OR rouge>linemid AND vert CROSSES OVER rouge OR rouge CROSSES OVER jaune THENBUY PositionSize CONTRACT AT MARKETENDIF// shortIF Not ONMARKET AND rouge>blueup AND vert CROSSES UNDER rouge OR rouge>lineup AND vert CROSSES UNDER rouge OR rouge<linemid AND vert CROSSES UNDER rouge OR rouge CROSSES UNDER jaune THENSELLSHORT PositionSize CONTRACT AT MARKETENDIF// stop and profitSET STOP pTRAILING slSET TARGET pPROFIT tpENDIF03/19/2018 at 2:49 PM #65692So, optimisation gives me Trailingstop = 49 and tp= 2.9*sl , but only on 10 000 bars, could someone test it on a 100 000 bars version ?
Now I have another problem, there are still bits where the trade is taken in the opposite direction (i.e. 23/01/2018 after 9H00 and goes on all day long) of where it should go, I will see if I can solve it.
Which also this system can give us more, I will pursue the investigation.
03/19/2018 at 3:58 PM #65708I am sorry to waste your time with beginners problems,
We are happy to help when we get a good explanation of the Issue (as you have done).
What Timeframe is this to be run on? I can’t see TF anywhere sorry?
03/19/2018 at 4:34 PM #65719could someone test it on a 100 000 bars version ?
We are all willing to help, but you should be able to test yourself on 100k bars.
03/19/2018 at 5:27 PM #6573103/19/2018 at 5:39 PM #65742maybe if I put x bars and 100 000 it will work,
Yes! That’s how it works! 😉
03/19/2018 at 6:03 PM #6574403/21/2018 at 4:41 AM #65920Okay, back from Berlin,
It’s 4:30 am, I spent the night, backtesting and optimising the strategy (on 100 000 candles 😉 ), I even broke it into pieces, optimizing each one and ….
it goes nowhere, ratios are not good or not good enough.
So I threw it away and started a new one. This is a trend surfer DAX too, so I think we can keep it in the same thread.
It’s 2min, 1pt spread, based on nicolas’ PRC_TTM SQUEEZE and Verdi’s Breakeven that I found in Grahal’s snippets.
It’s simple : buy when it turns from red to yellow and sell when it turn from blue to dark blue.
I’m close to get it right, I just got one problem, the system buys on every yellow (next candle of course) and sells on every blue (see the picture attached).
Here is the code :
trend surfer squeeze12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273// Trend Surfer DAX ModifiedDEFPARAM CumulateOrders = False// code-ParameterDEFPARAM FlatAfter = 180000DEFPARAM FlatBefore = 080500// DAX trading windowONCE BuyTimeMorning = 090500ONCE SellTimeMorning = 110000ONCE BuyTimeAfternoon = 130000ONCE SellTimeAfternoon = 173000// trading parameterONCE sl = aONCE tp = bONCE lengthKC=20// position management during trading windowIF (Time >= BuyTimeMorning AND Time <= SellTimeMorning) OR (Time >= BuyTimeAfternoon AND Time <= SellTimeAfternoon) THENvalue = (Highest[lengthKC](high)+Lowest[lengthKC](low)+average[lengthKC](close))/3val = linearregression[lengthKC](close-value)if val>0 and val<val[1] thenIF LONGONMARKET THENSELL 1 SHARES AT MARKETSELLSHORT 1 SHARES AT MARKETELSESELLSHORT 1 SHARES AT MARKETENDIFENDIFif val<0 and val>val[1] thenIF SHORTONMARKET THENEXITSHORT 1 SHARES AT MARKETBUY 1 SHARES AT MARKETELSEBUY 1 SHARES AT MARKETENDIFENDIFStopdistanceBreakeven = cNormalStop = slnb = barindex - tradeindexminprice = lowest[nb + 1](Low)maxprice = highest[nb + 1](High)If longonmarket thenIf maxprice >= positionprice + StopdistanceBreakeven thensell at (positionprice + 1) stopelsesell at positionprice - NormalStop stopendifendifIf shortonmarket thenIf minprice <= positionprice - StopdistanceBreakeven thenexitshort at (positionprice - 1) stopelseexitshort at positionprice + NormalStop stopendifendif// stop and profit//SET STOP pLOSS slSET TARGET pPROFIT tpENDIFMy guess is I should define what is yellow and dark blue (this I think I can do) and then buy/sell on the change of color (this I have no idea, how do you say “buy if red then yellow ???)
Can you help ?
Also, when I do the backtest, I have MFE and MAE in the closed positions toggle, which one should I trust ? (Cause I like MAE 🙂 )
Should I do a “e-ratio” like I read somewhere on the internet ?
03/21/2018 at 11:07 AM #65961Also, when I do the backtest, I have MFE and MAE in the closed positions toggle, which one should I trust ? (Cause I like MAE )
Glad you got back safe, shouldn’t you have been sleeping at 4:30 AM? 🙂
My brain has not woken enough yet re most of the questions, but MFE is Max Profit and MAE is Max Loss during that trade.
I check these and if a Strategy shows big MAE and then eventually a small MFE for lots of individual trades then I consider the Strat not good (even if overall a good profit shows). Reason: it would mean I’ve been sitting there stressing while the trade has had big drawdowns! Okay eventually it managed repeatedly to hitch-hike onto a favourable trend and come out smelling of roses / profit in the end, but the journey was tiring … just like yours from Berlin to Paris! 🙂
Cheers
GraHal
PS I drew same conclusion as you re your original Strat, but I didn’t like to say.
Thank you for your sterling effort through the night on the new version Strat, I will test it out later. -
AuthorPosts
Find exclusive trading pro-tools on