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.
-
-
04/02/2018 at 8:31 PM #66954
Hey ! I’m glad it works for you ! Are you using it on 1min timeframe? because it is much more profitable on 2min (because optimized for it).
Here is the latest code, with “quit snippet” (don’t forget to adjust capital and %loss if you’re using it) :
a=50
b=500
c=175
d=39
trendsurfer dax 2min12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// Trend Surfer DAX ModifiedDEFPARAM CumulateOrders = False//ONCE BigLoss = 0.95//ONCE Capital = 10000//IF NOT OnMarket AND OnMarket[1] THEN//IF (Capital + StrategyProfit) <= (Capital * BigLoss) THEN//QUIT//ENDIF//Capital = Capital + StrategyProfit//ENDIFtaille=1for i = 1 to 2 doif positionperf(i)<0 thentaille=taille-1elseif taille<5 thentaille=taille+1endifendifnext// Conditions pour ouvrir une position acheteuseindicator1 = Average[a](close)indicator2 = Average[b](close)c1 = (indicator1[1] CROSSES OVER indicator2[1])IF c1 THENBUY max(1,taille) SHARES AT MARKETENDIF// Conditions pour fermer une position acheteuseindicator3 = Average[a](close)indicator4 = Average[b](close)c2 = (indicator3[1] CROSSES UNDER indicator4[1])IF c2 THENSELL AT MARKETENDIF// Conditions pour ouvrir une position en vente à découvertindicator5 = Average[a](close)indicator6 = Average[b](close)c3 = (indicator5[1] CROSSES UNDER indicator6[1])IF c3 THENSELLSHORT max(1,taille) SHARES AT MARKETENDIF// Conditions pour fermer une position en vente à découvertindicator7 = Average[a](close)indicator8 = Average[b](close)c4 = (indicator7[1] CROSSES OVER indicator8[1])IF c4 THENEXITSHORT AT MARKETENDIFStopdistanceBreakeven = dnb = barindex - tradeindexminprice = lowest[nb + 1](Low)maxprice = highest[nb + 1](High)If longonmarket thenIf maxprice >= positionprice + StopdistanceBreakeven thensell at positionprice +1 stopelseSET STOP ptrailing cendifendifIf shortonmarket thenIf minprice <= positionprice - StopdistanceBreakeven thenexitshort at positionprice -1 stopelseSET STOP ptrailing cendifENDIF04/02/2018 at 8:51 PM #66955@GraHal you were right, first “(lowest[m](low))” and “tradeprice” were inverted. Then I fixed the code, and I now have a break even and trailing highs and lows 🙂
It doesn’t work for this particular strategy, but I think we can use it on others, I am currently testing it on my dax trend surfer 1 min.
I just got one problem : when I optimize “m” and “n”probacktest tests all possibilities for m (as it should be), but n stays to 1 !
Is it a bug from the plateform ?
Here is the code :
trailing highs and lows12345678910111213141516171819202122232425262728293031323334353637383940414243//trailing stop functiontrailingstart = 39 //trailing will start @trailinstart points profitclow = (lowest[m](low))-tradepricechigh= tradeprice-(highest[n](high))//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+1elseSET STOP ptrailing 175ENDIF//next movesIF newSL>0 AND clow>trailingstart thennewSL = newSL+clow*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-1elseSET STOP ptrailing 175ENDIF//next movesIF newSL>0 AND chigh>trailingstart thennewSL = newSL-chigh*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF04/15/2018 at 2:19 AM #68373Hello again,
here is an other enigma i am not able to solve myself :
I wrote the PRC_squeeze system (seen above) on IB markets, futur Dax (because this is where I trade manually, and where i spend most of my time). So far i’m happy with the curve, ready to test it on ProOrder.
I exported the strategy on IG markets, CFD Dax and the stratety transforms into a looser one.
Now, I know the curves are not the same and several cotation points off, but the Squeeze is (please tell me if I’m wrong, I’ve got a lot to learn) a momentum indicator, thus this shouldn’t be a problem, because it buys/sells on the trend strength (thus in relation with previous historic) and not on fixed levels.
So theorically, it should buy/sell on the same time (or close) in both cases, and even if it is not the case, the system should work anyway, shouldn’t it ?
So why is it not the case ?
Why, all parameters equals, can’t I get a similar curve ?
Is it the system itself ? the market ? the plateform ? me ? or everything at the same time ?
Could someone test it on Ig broker and tell me the result ?
Attached is :
- the system, dax 2 min
- the supertrend extended indicator (used in the system)
- the curves on IG and IB
- in the red squares are buying and selling times which are different and I can’t see why
04/15/2018 at 8:29 AM #6838104/15/2018 at 11:30 AM #68390Hi @Eric I didn’t understand what you meant. You think this has to do with opening and closing time of the market ?
But trading time is from 08am to 5pm in the system…
Attached is a clue of what is wrong, the system almost only buys and many trades close on the same candle, but I don’t know why : sl or tp are not touched.
04/15/2018 at 2:04 PM #68400Hi @Eric I didn’t understand what you meant. You think this has to do with opening and closing time of the market ? But trading time is from 08am to 5pm in the system… Attached is a clue of what is wrong, the system almost only buys and many trades close on the same candle, but I don’t know why : sl or tp are not touched.
i looked at the wrong code
04/15/2018 at 3:08 PM #68405Hello again, here is an other enigma i am not able to solve myself :
I’ve read and reread the last several posts and I’m still not 100% sure what the enigma is … is it trades opening and closing in the same bar?
I downloaded what I thought was 2 Systems (from the post quoted above) and my Platform keeps telling me they are Indicators ( I did save them under Systems )!!??
My brain may need a rest so I’ll have a lie under my duvet (which I always enjoy 🙂 ) and hope the enigma is a bit clearer when I surface again 🙂 🙂
GraHal
04/15/2018 at 5:42 PM #6840904/15/2018 at 6:29 PM #6841004/15/2018 at 6:55 PM #68412Okay, I started testing the conditions. I use supertrend extended as a filter, so I made an indicator to test which direction it was going, -1 for red and + 1 for blue and it’s inverted !
I think this could be helpfull to those who import itf files with “called indicators” in it : the variables indicator1 and 2 switched, god knows why…
04/16/2018 at 1:20 AM #68432So ! I rewrote the code to make the conditions work and each one is tested in an indicator (see attached).
signal_squeeze1 :
- negative surface for down supertrend and positive surface for up supertrend
- red spikes for short signals and green spikes for long signals
signal_squeeze2 :
- red spikes for short signals AND down supertrend
- green spikes for long signals AND up supertrend
signal_squeeze2 is used by the system to enter a position, and supertrend to exit (plus money management). But it’s not the case as you can see.
Soooooooo, now that I narrowed down the problem, i’m deducing that the only part of the code which could be the problem is the part below, where the system buys and sells, Elementary my dear Watson !
12345678910111213141516171819202122232425262728293031//signal1 : buy signal//signal2 : sell signal//lol[1] = -1 : down supertrend//lol[1] = 1 : up supertrendif signal2 thenIF LONGONMARKET THENSELL AT MARKETSELLSHORT 5 SHARES AT MARKETELSESELLSHORT 5 SHARES AT MARKETENDIFENDIFif signal1 thenIF SHORTONMARKET THENEXITSHORT AT MARKETBUY 5 SHARES AT MARKETELSEBUY 5 SHARES AT MARKETENDIFENDIFIF LONGONMARKET and lol[1]=-1 THENSELL AT MARKETENDIFIF SHORTONMARKET and lol[1]=1 THENEXITSHORT AT MARKETENDIFI finally found the problem and I’m really having fun doing this, but now i’m stuck, and this has been already for a few hours, could someone help please ?
chears !
PS : the entire code is also attached if needed
04/16/2018 at 10:30 AM #68455I finally found the problem, but now i’m stuck,
What are you stuck on?
I’ve run your code and made a few trial changes, but – as I can’t see results and / or an equity curve for your PRC_TTM-SQUEEZE4.itf – I can’t tell if I am improving or not?
Please post your results and equity curve for PRC_TTM-SQUEEZE4.itf
Thanks
GraHal04/16/2018 at 11:31 AM #6847204/16/2018 at 12:02 PM #68481I must already have the Indicator (Platform tells you if not).
Attached results (over 10k bars only ) with Code line 56 and 80 as below … which I had already changed prior to you saying above … I must be getting better at this coding lark!!! 🙂 🙂
PS I think I only changed the first 8 lines as shown below?
PPS You get a good increase on your curve at the end … so are my changes making much difference at all??
I may have patted myself on the back too soon?? 🙂
Attached is mine over 100k bars … different but mot much better, but my code changes may spark more ideas in you??123456789101112131415161718192021222324if signal2 thenSellShort 5 SHARES AT MARKETENDIFif signal1 thenBuy 5 SHARES AT MARKETENDIFIF LONGONMARKET and lol[1]=-1 THENSELL AT MARKETENDIFIF SHORTONMARKET and lol[1]=1 THENEXITSHORT AT MARKETENDIFStopdistanceBreakeven = cNormalStop = slnb = barindex - max(1,tradeindex)minprice = lowest[nb + 1](Low)maxprice = highest[nb + 1](High)04/16/2018 at 10:54 PM #68540 -
AuthorPosts
Find exclusive trading pro-tools on