Combined Supertrend Further Discusion
Forums › ProRealTime English forum › ProOrder support › Combined Supertrend Further Discusion
- This topic has 42 replies, 9 voices, and was last updated 6 years ago by verdi55.
-
-
01/27/2018 at 9:22 AM #60656
Good Day
We can use this thread to further discuss possible enhancements on the Combined Supertrend EURUSD 4Hr strategy posted in the Library:
https://www.prorealcode.com/prorealtime-trading-strategies/combined-supertrend-eurusd-4hr/
01/27/2018 at 2:06 PM #60677Hi @Juanan71 please might you share the changes you made to Juanj code?
Juanj code is well good, your changes make the equity curve look sooo good, you will understand we are interested in, and want to learn from, the coding details!?
Did it take you long?
Thank You
GraHal01/27/2018 at 11:02 PM #6070001/28/2018 at 11:44 AM #6071101/28/2018 at 12:13 PM #60713Problem is backtest does not work like demo mode in real time.Backtest make many neutral trades in 0 but really in demo mode is not like that…these trades close at stop loss ..never in be and i dont know why
Just i’ve added the trailing stop made for Nicolas time ago but this trailing is aplyed at the close of candle and no follow the price…problem…when sl or trailing step is in the same candle backtest can not calculate and return very good results but are not reals.
Code of trailing is this but i dont know how integrate it because does not work properly…try this…copy and paste this code at final of any system you have and check resuts in 2h,4h,1h… you will see are amazing but no real
128 line to final add to any other code
Try this123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176Defparam cumulateorders = falsepossize = 1////////////////////////////////////////////////////////////////Andrew Abraham Trend Trader//Posted by @Nicolas in PRC Library/////////////////////////////////////////////////////////////Length = 21Multiplier = 3avrTR = weightedaverage[Length](AverageTrueRange[1](close))highestC = highest[Length](high)lowestC = lowest[Length](low)hiLimit = highestC[1]-(avrTR[1]*Multiplier)lolimit = lowestC[1]+(avrTR[1]*Multiplier)if(close > hiLimit AND close > loLimit) THENret = hiLimitELSIF (close < loLimit AND close < hiLimit) THENret = loLimitELSEret = ret[1]ENDIF///////////////////////////////////////////////////////////////Simplified supertrend (without volatility component ATR)//Posted by @verdi55 in PRC Library/////////////////////////////////////////////////////////////ONCE direction = 1ONCE STlongold = 0ONCE STshortold = 1000000000000factor = 0.005indicator1 = medianpriceindicator3 = closeindicator2 = indicator3 * factorSTlong = indicator1 - indicator2STshort = indicator1 + indicator2If direction = 1 and STlong < STlongold thenSTlong = STlongoldendifIf direction = -1 and STshort > STshortold thenSTshort = STshortoldendifIf direction = 1 and indicator3 < STlong thendirection = -1endifIf direction = -1 and indicator3 > STshort thendirection = 1endifSTlongold = STlongSTshortold = STshortIf direction = 1 thenST = STlongelseST = STshortendif///////////////////////////////////////////////////////////////PRC_adaptive SuperTrend (r-square method) | indicator//Posted by @Nicolas in PRC Library/////////////////////////////////////////////////////////////Period = 10mult = 2Data = customcloseSumX = 0SumXX = 0SumXY = 0SumYY = 0SumY = 0if barindex>Period then// adaptive r-squared periodsfor k=0 to period-1 dotprice = Data[k]SumX = SumX+(k+1)SumXX = SumXX+((k+1)*(k+1))SumXY = SumXY+((k+1)*tprice)SumYY = SumYY+(tprice*tprice)SumY = SumY+tpricenextQ1 = SumXY - SumX*SumY/periodQ2 = SumXX - SumX*SumX/periodQ3 = SumYY - SumY*SumY/periodiRsq=((Q1*Q1)/(Q2*Q3))avg = supertrend[mult,round(Period+Period*(iRsq-0.25))]EndIf//////////////////////////////////////////////////////////////////OriginalST = Supertrend[3,5]/////////////////////////////////////////////////////////////////margin = 7*pointsizeIf countofposition = 0 and abs(ret[1]-ST[1]) > margin and abs(ret-ST) > margin ThenIf close > ret and close > ST and close > avg ThenBuy possize contract at marketElsIf close < ret and close < ST and close < avg ThenSellshort possize contract at marketEndIfElsIf longonmarket and ((abs(ret[1]-ST[1]) < margin and abs(ret-ST) < margin) or ((close < ret and close < ST and close < avg and close < OriginalST) and (close[1] < ret[1] and close[1] < ST[1] and close[1] < avg[1] and close[1] < OriginalST[1]))) ThenSell at marketElsIf shortonmarket and ((abs(ret[1]-ST[1]) < margin and abs(ret-ST) < margin) or ((close > ret and close > ST and close > avg and close > OriginalST) and (close[1] < ret[1] and close[1] < ST[1] and close[1] > avg[1] and close[1] < OriginalST[1]))) ThenExitshort at marketEndIfSL = 20//15//20 // Initial SLTP = 0//30TSL = 1 // Use TSL?TrailingDistance =5// 20//20//20 // Distance from close to TSLTrailingStep =5// 20//20//3 // Pips locked at start of TSL//************************************************************************IF TSL = 1 THEN//reset the stoploss valueIF NOT ONMARKET THENnewSL = 0CAND = 0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL = 0 AND CLOSE - TRADEPRICE(1) >= TrailingDistance*PipSize THENnewSL = TRADEPRICE(1) + TrailingStep*PipSizeENDIF//next movesCAND = BarIndex - TradeIndexIF newSL > 0 AND CLOSE[1] >= HIGHEST[CAND](CLOSE) THENnewSL = CLOSE[1] - TrailingDistance*PipSizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL = 0 AND TRADEPRICE(1) - CLOSE[1] >= TrailingDistance*PipSize THENnewSL = TRADEPRICE(1) - TrailingStep*PipSizeENDIF//next movesCAND = BarIndex - TradeIndexIF newSL > 0 AND CLOSE[1] <= LOWEST[CAND](CLOSE) THENnewSL = CLOSE[1] + TrailingDistance*PipSizeENDIFENDIF//stop order to exit the positionsIF newSL > 0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFSET STOP pLOSS SLset target pprofit tpENDIF01/28/2018 at 12:44 PM #60719@Juanan71 thanks for sharing.
Your problem … Backtest make many neutral trades in 0 … is due to the tick by tick box not being checked during backtesting. See attached image.
To make backtest work like real trading it has to be in tick by tick mode … because that is what happens in real trading.
If you want more information then search for zero bars on this site. Or, as it is quite boring, save yourself time and just accept the explanation above 🙂 (0 bars / zero bars is called other names also on here, but it’s so long since I’ve looked at this I’ve forgotten the other names! 🙂 )
Cheers
GraHal01/28/2018 at 12:49 PM #6072101/28/2018 at 1:21 PM #6072301/28/2018 at 1:52 PM #60724Also, I think your setting of TP = 0 in your code is why there’s massive difference between the optimised results table (shows bad) and the equity curve (shows good!) … even with tick by tick selected. See attached.
I will continue to think on this while I have a shave! Often have brainwaves while shaving / cleaning teeth and away from the screen! 🙂
I haven’t studied / understood your code, but when there is a zero bar / 0 bar then on the equity curve it is showing as 0 profit but in reality it has been a SL value loss (in my case attached SL = £55 loss!
But the odd thing is … some 0 bars / zero bars do show as -£55 loss (see attached) so still some thinking to do! 🙂
I went over a few trades bar by bar on a 1 min TF and the anomaly (see line above) doesn’t seem to be related to whether a profit is hit before the -55 loss or vice versa.
Any comments anyone??
GraHal
01/28/2018 at 3:26 PM #60737Often have brainwaves while shaving / cleaning teeth and away from the screen!
I should try it.
01/28/2018 at 4:20 PM #60739Often have brainwaves while shaving / cleaning teeth and away from the screen!
I should try it.
You should – I have my best ideas in the shower. I am sometimes in there for far too long though!
01/28/2018 at 7:23 PM #60756I still dont know whats exactly the problem….my idea is keep these neutral trades because are important….If can not be neutral maybe loss 1 or 2 points but if i have more winning trades it will be good..any idea for make this neutral trades if price turn back? i mean if price go up for later go down…be sure will not arrive to sl but if price goes down at the beggining of the trade is no problem if arrives to sl…
If you have a good strategy and a good entry system winning the most times and keeping neutral others….we’ll have a good system i think but
if i’m working on a system and after a hard job tested with tic by tic and results are so good but no real…why work? maybe you’ll found other prt bug and all your job is lost again
01/28/2018 at 7:30 PM #60757Often have brainwaves while shaving / cleaning teeth and away from the screen!
I should try it.
Vonasi wrote
You should – I have my best ideas in the shower. I am sometimes in there for far too long though!Maybe Nicolas means he should try just getting away from the screen !!?? 🙂 🙂
01/28/2018 at 7:31 PM #60758Por ejemplo este sistema…de que me sirve trabajar en él si resuta que luego no va a hacer lo que debe hacer…quién me dice que cualquier otro que haga no pasará lo mismo y seguira fallando una y otra cosa???…no me fio para nada ya de los backtest ni del propio prorealtime…creo que tiene muchas cosas que pulir y arreglar.
Me siento decepcionado
01/28/2018 at 7:47 PM #60761@Juanan71 logically the value TP = 0 (your code above line 129 & line 175) is corrupting all the figures. Why have a Take Profit / TP at 0??
Best you read up on the 0 bars / zero bars issue (search on this site) as maybe this is the only way to appreciate what is happening?
Also you have the settings below on Nicolas Trailing Stop. These are not realistic as a trailing distance of 5 would get hit all the time?? The minimum on Dax is 6 points anyway and price retraces 6 points (in a few seconds) at almost every move up / down > 10 to 12 points.
12TrailingDistance =5// 20//20//20 // Distance from close to TSLTrailingStep =5// 20//20//3 // Pips locked at start of TSLGraHal
-
AuthorPosts
Find exclusive trading pro-tools on