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/21/2018 at 6:51 PM #66011
I tried this :
12345678910111213141516171819if close[val]>0 and close[val]<close[val[1]] and close[val[1]]>0 and close[val[1]]>close[val[2]] thenIF LONGONMARKET THENSELL 1 SHARES AT MARKETSELLSHORT 1 SHARES AT MARKETELSESELLSHORT 1 SHARES AT MARKETENDIFENDIFif close[val]<0 and close[val]>close[val[1]] and close[val[1]]<0 and close[val[1]]<close[val[2]]thenIF SHORTONMARKET THENEXITSHORT 1 SHARES AT MARKETBUY 1 SHARES AT MARKETELSEBUY 1 SHARES AT MARKETENDIFENDIFbut still doesn’t work…
03/21/2018 at 7:29 PM #6601203/21/2018 at 9:14 PM #6601603/21/2018 at 10:12 PM #6602203/22/2018 at 4:33 AM #66039OK, eventually I filtered it with supertrend extended (see attached), looks better now, I’ll try to push it.
Here’s the code :
a = 89 (sl)
b = 28 (tp)
c = 20
d = 1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475// Trend Surfer DAX ModifiedDEFPARAM CumulateOrders = False// code-ParameterDEFPARAM FlatBefore = 080500DEFPARAM FlatAfter = 180000// DAX trading windowONCE BuyTimeMorning = 080500//ONCE SellTimeMorning = 110000//ONCE BuyTimeAfternoon = 130000ONCE SellTimeAfternoon = 173000// trading parameterONCE sl = aONCE tp = bONCE lengthKC=20// position management during trading windowIF (Time >= BuyTimeMorning AND Time <= SellTimeAfternoon) THENvalue = (Highest[lengthKC](high)+Lowest[lengthKC](low)+average[lengthKC](close))/3val = linearregression[lengthKC](close-value)indicator1, ignored = CALL "PRC_SuperTrend Extended"[2.236, 66, 1, 10]ignored, indicator2 = CALL "PRC_SuperTrend Extended"[2.236, 66, 1, 10]c1 = (indicator1 < indicator2)c2 = (indicator1 > indicator2)if val>0 and val[1]>0 and val[2]>0 and val<val[1] and val[1]>val[2] and c2 thenIF LONGONMARKET THENSELL 1 SHARES AT MARKETSELLSHORT 1 SHARES AT MARKETELSESELLSHORT 1 SHARES AT MARKETENDIFENDIFif val<0 and val[1]<0 and val[2]<0 and val>val[1] and val[1]<val[2] and c1 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 tpENDIFchears !
03/22/2018 at 4:54 AM #6604103/22/2018 at 5:41 AM #6604203/22/2018 at 12:17 PM #6607803/23/2018 at 4:57 PM #6619003/23/2018 at 7:48 PM #6620904/02/2018 at 6:36 PM #66942Hi again !
I’m trying to make some tweaks on the last code I posted, but I need help…
I took nicolas’ trailing code here https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
I’m keeping the break even part, but I want the trailing step to be the last high or low (if we go short or long) of “n” or “m” periods (n and m being different for long or short and to be optimized).
here’s what I changed, but it doesn’t seem to work :
trailing highs/lows1234567891011121314151617181920212223242526272829303132333435363738394041trailingstart = 39clow = tradeprice - (lowest[m](low))chigh= (highest[n](high))-tradeprice//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)+clow*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=clow*pipsize THENnewSL = newSL+clow*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-chigh*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=chigh*pipsize THENnewSL = newSL-chigh*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//************************************************************************GRAPH newSL as "trailing"04/02/2018 at 6:56 PM #6694604/02/2018 at 7:12 PM #66948Aha I thought my eyes were deceiving me so I nipped in and deleted my comment re the Trailingstart! 🙂 🙂
Have you use GRAPH to see what the value of tradeprice – (lowest[m](low)) is? Because if it is > Trailing start then it wouldn’t work anyway??
04/02/2018 at 7:49 PM #66950ok I am going to look closer, I ‘ll report back when I shall find the error.
Meanwhile, I added pyramiding code I founded in nicolas’ advanced training videos,
I tweaked it so that position size increases also after a win (and not just deacreases after a loss).
Win/loss ratio jumped from 4,73 to 5,71.
here’s the code to put at the begining :
pyramiding12345678910taille=1for i = 1 to 2 doif positionperf(i)<0 thentaille=taille-1elseif taille<5 thentaille=taille+1endifendifnext04/02/2018 at 8:14 PM #66951 -
AuthorPosts
Find exclusive trading pro-tools on