DOUBLE TOP/BOTTOM HUNTER
Forums › ProRealTime English forum › ProOrder support › DOUBLE TOP/BOTTOM HUNTER
- This topic has 23 replies, 5 voices, and was last updated 6 years ago by Leo.
-
-
11/17/2017 at 6:45 AM #53077
Hi all,
I decide to open a new topic because I need help with the strategy I created using my methodology and my style of algorithmic trading (few money per trade to risk, small time frame, mini contract in IG).
After a while studying the double to and double bottom detected by this code https://www.prorealcode.com/prorealtime-market-screeners/double-top-double-bottom-screener/. I realized that I only know that I don’t know anything.
So here is what I got: I open a long order and a short order just below and above a double top/low. When the order are activated i.e. the double bottom/top is either activated or annulated the market almost always move quickly because (I think) because there are many order placed just in that area.
The strategy take very small profits many often but when it loses…. It loses a lot!
I trade this in real life and winning two out of two but I am not happy because I need two win 4 times for compensate a possible future loss. That’s why I do not upload the strategy to the library.
I hope all of you can help me with this endeavour.
Thanks
M&W HUNTER v1.2123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244//M&W HUNTER//Autor: LEODEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM PreLoadBars = 3000 //cargar informacion//VARIABLES TO BE OPTIMIZED//PERIOD=20 //Period for analysis//Kdouble=0.2 //Factor for defining what is double top or bottom//maxrisk0=13 //pips per trade to risk//Kprofit=0.5 // proportion of profit targetmaxrisk=maxrisk0+(n-1)*2totalrisk=4*maxrisk*PIPVALUE //for stop the robot if things are going badspread=0.7IF TIME < 060000 THEN //(germany time)spread=2*spreadELSIF TIME>213000 THEN //(germany time)spread=2*spreadENDIF//Robot Working Time (Germany)IF TIME>020000 and TIME < 220000 THENontime=1ELSEontime=0ENDIF////// RISK CONTROL IF THINGS ARE GOING WONDERFULL //////n = 1 + (strategyprofit / (77*pipvalue))n = round(n * 100)n = n / 100n = max(1,n)// >>>>>>>>> M&W patterns <<<<<<WMA=weightedaverage[period](close)//Smoothed curve of Leo Moving AverageIF BARINDEX > period THENsmoothWMA=weightedaverage[period](WMA)ELSEsmoothWMA=undefinedENDIF// << Storage of minimums and maximums >>once mintemp=lowonce posmintemp=1once maxtemp=highonce posmaxtemp=1IF BARINDEX>2 THEN// the value 0.7 is to ensure that the donchian channel is faster than the curves analysis (this value to be checked)IF low < lowest[round(0.75*period)](low[1]) THENmintemp=low //minimum temporalposmintemp=BARINDEX //postition of minimum temporalENDIFIF high > highest[round(0.75*period)](high[1]) thenmaxtemp=high //maximum temporalposmaxtemp=BARINDEX //position maximum temporalENDIFENDIF// << Detecting and locating a local minimums >>// Where the WMA is crossing the smoothed WMA, there is a maximum or minimum nearby// If there is a new local min/max, the preivus one is stored in de varible B... (before)once LEVMIN=lowonce POSLEVMIN=1once LEVMAX=highonce POSLEVMAX=1once bullcross=0once bearcross=0IF BARINDEX > PERIOD THEN //For avoid computer errorsbullcross=WMA crosses over smoothWMAbearcross=WMA crosses under smoothWMAENDIFIF bullcross and POSLEVMIN<>posmintemp THENBLEVMIN=LEVMIN //previus local minimum is savedBPOSLEVMIN=POSLEVMINLEVMIN=mintempPOSLEVMIN=posmintempsupport=LEVMINENDIF// --> Detecting and locating a local maximumIF bearcross and POSLEVMAX<>posmaxtemp THENBLEVMAX=LEVMAX //previus local maximum is savedBPOSLEVMAX=POSLEVMAXLEVMAX=maxtempPOSLEVMAX=posmaxtempresistance=LEVMAXENDIFonce support=lowonce resistance=highsupport=min(low,support)resistance=max(high,resistance)// << DETECTING DOUBLE TOP OR BOTTOMS >>once WidthDoubleTop = high-lowonce WidthDoubleBottom = high-lowonce Wpattern=0once Mpattern=0// <<<<<< Double bottoms >>>>>>>>>//looking for the top between two local minimumsIF bullcross THENdoublebottomtop=high[BARINDEX-POSLEVMIN+1] // we start looking for the top in between two local minimums//POSdoublebottomtop=BARINDEX-POSLEVMIN+1FOR i = (BARINDEX-POSLEVMIN+1) to (BARINDEX-BPOSLEVMIN-1) DOIF high[i] > doublebottomtop THENdoublebottomtop=high[i]//POSdoublebottomtop=BARINDEX-iENDIFNEXTWidthDoubleBottom = doublebottomtop-(BLEVMIN+LEVMIN)/2 // (top betwen local minimums) - (average of the las two local minimums)IF abs(BLEVMIN-LEVMIN) < Kdouble*WidthDoubleBottom THEN// we have a double bottomWpattern=1elseWpattern=0ENDIFENDIF// <<<<<<<<<< Double tops >>>>>>>//looking for the bottom between two local maximumsIF bearcross THENdoubletopbottom=low[BARINDEX-POSLEVMAX+1]//POSdoubletopbottom=BARINDEX-POSLEVMAX+1FOR i = (BARINDEX-POSLEVMAX+1) to (BARINDEX-BPOSLEVMAX-1) DOIF low[i] < doubletopbottom THENdoubletopbottom=low[i]//POSdoubletopbottom=BARINDEX-iENDIFNEXTWidthDoubleTop=(BLEVMAX+LEVMAX)/2 -doubletopbottomIF abs(BLEVMAX-LEVMAX) < Kdouble*WidthDoubleTop THEN// we have a double topMpattern=1elseMpattern=0ENDIFENDIF// <<<<<<<<<< DOUBLE BOTTOM FOR TRADING >>>>>>>>once entrylong=undefinedonce entryshort=undefinedmyATR=AverageTrueRange[2*period](close)IF Wpattern=1 THENIF close > (doublebottomtop+myATR) or close < (LEVMIN-0.5*myATR) THENWpattern=0 // <<<< double bottom has been activated or it was cancelled >>>>>ELSE//Here we tradeentrylong = max(doublebottomtop,high)+spread*pipsize/2entryshort= min(LEVMIN,low)-0.5*myATR-spread*pipsize/2stoploss = min(maxrisk,WidthDoubleBottom/pipsize+1.5*spread)StopProfit= WidthDoubleBottom/pipsize*KprofitIF NOT LongOnMarket AND ontime=1 THENBUY n CONTRACTS AT entrylong STOPSET STOP pLOSS stoplossSET TARGET pPROFIT StopProfitENDIFIF NOT ShortOnMarket AND ontime=1 THENSELLSHORT n CONTRACTS AT entryshort STOPSET STOP pLOSS stoplossSET TARGET pPROFIT StopProfitENDIFENDIFENDIF// <<<<<<<<<< DOUBLE TOP FOR TRADING >>>>>>>>IF Mpattern=1 THENIF close < (doubletopbottom-myATR) or close > (LEVMAX+0.5*myATR) THENMpattern=0 //double top has been activated or it was cancelledELSE//Here we tradeentrylong = max(LEVMAX,high)+0.5*myATR+spread*pipsize/2entryshort= min(doubletopbottom,low)-spread*pipsize/2stoploss = min(maxrisk,WidthDoubleTop/pipsize+1.5*spread)StopProfit= WidthDoubleTop/pipsize*KprofitIF NOT LongOnMarket AND ontime=1 THENBUY n CONTRACTS AT entrylong STOPSET STOP pLOSS stoplossSET TARGET pPROFIT StopProfitENDIFIF NOT ShortOnMarket AND ontime=1 THENSELLSHORT n CONTRACTS AT entryshort STOPSET STOP pLOSS stoplossSET TARGET pPROFIT StopProfitENDIFENDIFENDIFIF longonmarket thenIF close < support[1] THEN //+0.3*(resistance-support)SELL AT MARKETENDIFIF TIME > 224500 and DayOfWeek=5 thenSELL AT MARKETENDIFendifIF shortonmarket thenIF close > resistance[1] THEN //-0.3*(resistance-support)EXITSHORT AT MARKETENDIFIF TIME > 224500 and DayOfWeek=5 thenEXITSHORT AT MARKETENDIFendif//Quit the robot if things are going badQ=MAX(Q,(STRATEGYPROFIT/pipvalue/n))R=Q-STRATEGYPROFIT/pipvalue/nIF R > totalrisk THENQUITENDIFIF STRATEGYPROFIT < (-1*totalrisk) THENQUITENDIF11/18/2017 at 7:42 AM #5315801/30/2018 at 9:28 PM #61023hey leo,
i have this IN REAL! Thanks!
so, it was luck or is this the cash cow we all are looking for? 😉
01/31/2018 at 6:20 AM #61041Cool!
so, it was luck or is this the cash cow we all are looking for?
This is what I work everyday for 🙂
I hope still working for you. I am not fully satisfied though, because most of the time the price target of a doble bottom is not fully fullfill. This strategy I post make me win like 3 times in a row and with only one fail it deletes the profit of the last two.
Maybe as an entry and then you control manually the position can be very profitable.
or… let’s improved it together!
01/31/2018 at 7:17 AM #61043Hi Leo
Based on having watched charts for years, I have often times noticed that legitimate double tops tend to make a higher high (tops) or lower low (bottoms) on the second top or bottom than the first. The average close of the second top however if measured across the candle directly before the new high (tops) and low (bottoms) along with the candle that printed the actual high or low is usually lower (for tops) or higher (for bottoms).
Maybe you can try building that into your screener and/or code and see if it improves results?
01/31/2018 at 11:20 AM #61073Hi @Leo , looks good!
I guess you know your Optimising is at 2 min TF and your WF is at 1 min TF?
If I start with £10K Capital, what do I need to change in the code to remove the Quit at around £100? Or change Quit to £10K and just let it run??
I’ve tried a few changes, but so I don’t lose interest (short attention span! 🙂 ) it be easier if you tell me (and others).
Thank You
GraHal1 user thanked author for this post.
01/31/2018 at 11:36 AM #61077It’s okay, I think I have it!
There are so many linked / referred values that’s why I was losing patience, but I changed total risk to 10000 and it ceases the Quit. Now I can continue investigations.
Attached is what I get so far.
12maxrisk=maxrisk0+(n-1)*2totalrisk=10000//4*maxrisk*PIPVALUE //for stop the robot if things are going bad01/31/2018 at 1:49 PM #6109501/31/2018 at 2:02 PM #6110001/31/2018 at 2:54 PM #61106I just compared my real trades with the backtest. It´s completely the same, so this one works.
Anyway, the actual trade would have lost about 400€, thank god I stopped the system yesterday 😉
In this case the last trade would have killed the two won trades before. Ok, but trading is a risky thing. I am thinking about let the system run with some more indices and then in some more time levels of each indices. What do you guys think about it? I would stop each system after a strategyprofit between 500 and 1000€.
01/31/2018 at 4:10 PM #61111I’m probably weird (actually I know I am ! 🙂 ) but I manually control all Strats and exit if the market structure around the entry point / progress of the trade doesn’t look right for the direction of the trade (Long or Short).
Even if I am away from the Screen I keep an eye on profit / loss (you can even see Charts on the App) on the IG App on my phone and exit if there is a decent profit that starts to run down. Better a small profit than see it turn to a loss?
I do then analyse what the Strat is doing (similar to what I’ve done above with Leo’s) and make changes to the code to better the equity curve.
Above sounds better than it is cos this site is like being a kid in a sweet shop … I wanna try this one, no this one, oh forget them, this one’s better than all the others!!! hahahahhahah
GraHal
01/31/2018 at 4:38 PM #61114Attached is the next trigger / double top that ends / exits the previous trade (see post #61095 above showing image of a double bottom).
But in my logic, after you get higher than about a 60% retrace of the 3 red bars (following entry) then any edge / logic the entry (double top) had has gone / means nothing!?
From thereon – past the 60% retrace point – you are living in the land of hope!?
GraHal
01/31/2018 at 6:16 PM #61130Hi all,
First than all I want to thank you for the collaboration in this project.
- @juanj: I got your ideas I will add another parameter for check at double bottom if the lowers are uptrend or uptrend and opposite for double tops
- @ raphaelopilski: I feel relief you close that trade. That happens to me as well
- @Grahal: I got your idea long time ago, even test it with real money and I not getting the robustness I wish because the theory says that a double top/ bottom must be activated, i.e close avobe/ below the middle local. When I trigger in another moment the pattern is not active then there is no probability of winning trade. What I also try live with real money after testing is to open a limit order at a Fibonacci level of 0.38 and I get boring of seeing that many double bottom/top where active and never come back to this beloved pull back for entry.
- Here some insights:
- For Fibonacci levels at double bottoms use “LEVMIN” and “maxtemp” values
- I realise that a possible double top can be a reversal pattern or a very good looking flag pattern… so I am testing different filters for a long long very long bias or trend. Trend is your friend.
01/31/2018 at 7:05 PM #61133@Leo I don’t understand what you are saying in the @Grahal paragraph above. You are talking about entering a trade at a 38% retrace from a double top / bottom?
I was suggesting that the 60% retrace is a good zone to watch further progress very carefully. If the retrace continues at a pace much further than 60% then I would probably do a manual exit of the trade (which was triggered / entered by a double top/bottom).
Cheers
GraHal02/01/2018 at 6:37 AM #61162Ok,
Then this will be another closing condition:
123456789101112131415IF longonmarket thenIF close < support+0.4*(resistance-support) THENSELL AT MARKETENDIFENDIFIF shortonmarket thenIF close > resistance-0.4*(resistance-support)EXITSHORT AT MARKETENDIFENDIF1 user thanked author for this post.
-
AuthorPosts