Strategy HSI-M1-ReverseAngleLong
Forums › ProRealTime English forum › ProOrder support › Strategy HSI-M1-ReverseAngleLong
- This topic has 11 replies, 4 voices, and was last updated 5 years ago by
zilliq.
-
-
05/27/2020 at 7:25 PM #133495
Hi everyone,
Here is a new strategy on Hang Seng 1 min TF. It measures the angle of the slope and looking for a V-slope. As unit of price and bar is not the same, thus replaced the bar with ATR (with higher period) to have in relative price to price comparison.
Looking forward for your suggestion and ideas of improvement.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485DEFPARAM CumulateOrders = falseDEFPARAM PRELOADBARS = 2000//Money ManagementMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize = 1ENDIFif MM = 1 thenonce maxSize = 2once minSize = 1once startingsize = 1once stepsize = 0.5once resetafterlost = 0once doublestepdown = 0once resetafterstrikewin = 2once positionsize = startingsizeonce wincount = 0if strategyprofit <> strategyprofit[1] thenif positionperf(1)>0 thenif positionsize < maxSize thenpositionsize = positionsize + stepsizeendifwincount = wincount + 1if wincount >= resetafterstrikewin thenpositionsize = startingsizewincount = 0endifelseif resetafterlost thenpositionsize = startingsizeelsif doublestepdown thenpositionsize = positionsize - stepsize * 2elsepositionsize = positionsize - stepsizeendifwincount = 0endifendifif positionsize < minSize thenpositionsize = minSizeendifENDIFtimedaytrade = (time > 093100 + waitmin) AND (time < 120000) OR (time > 130000 + waitmin AND time < 155500)timeok = timedaytrade//====== Enter market - start =====samebarsignal = 0M1atrAB = AverageTrueRange[periodA + periodB](close)//Look for V shapeadjacentA = (close - close[periodA]) / M1atrABangelA = atan(adjacentA)adjacentB = (close[periodA] - close[periodA + periodB]) / M1atrAB[periodA]angelB = atan(adjacentB)C1 = angelB < longB AND angelA > longA// LONG sideIF timeok AND Not OnMarket AND C1 AND samebarsignal = 0 THENBUY positionsize CONTRACT AT MARKETSET STOP pLOSS SLTP = RR * SLSET TARGET pPROFIT TPsamebarsignal = 1ENDIF//====== Enter market - end =====//====== Exit market - start =====IF NOT ONMARKET THENENDIF//====== Exit market - end =====4 users thanked author for this post.
05/28/2020 at 10:15 AM #133580Hi,
Can you try to backtest this strategy with a breakeven and maybe a filter on M5
With 200k, i get 100%.
for example
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156DEFPARAM CumulateOrders = falseDEFPARAM PRELOADBARS = 2000//Money ManagementMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize = 1ENDIFif MM = 1 thenonce maxSize = 2once minSize = 1once startingsize = 1once stepsize = 0.5once resetafterlost = 0once doublestepdown = 0once resetafterstrikewin = 2once positionsize = startingsizeonce wincount = 0if strategyprofit <> strategyprofit[1] thenif positionperf(1)>0 thenif positionsize < maxSize thenpositionsize = positionsize + stepsizeendifwincount = wincount + 1if wincount >= resetafterstrikewin thenpositionsize = startingsizewincount = 0endifelseif resetafterlost thenpositionsize = startingsizeelsif doublestepdown thenpositionsize = positionsize - stepsize * 2elsepositionsize = positionsize - stepsizeendifwincount = 0endifendifif positionsize < minSize thenpositionsize = minSizeendifENDIFtimedaytrade = (time > 093100 + waitmin) AND (time < 120000) OR (time > 130000 + waitmin AND time < 155500)timeok = timedaytradetimeframe(5minutes,updateonclose)st = close > supertrend[5,4]timeframe(default)//====== Enter market - start =====samebarsignal = 0M1atrAB = AverageTrueRange[periodA + periodB](close)//Look for V shapeadjacentA = (close - close[periodA]) / M1atrABangelA = atan(adjacentA)adjacentB = (close[periodA] - close[periodA + periodB]) / M1atrAB[periodA]angelB = atan(adjacentB)C1 = angelB < longB AND angelA > longA// LONG sideIF timeok AND Not OnMarket AND C1 AND samebarsignal = 0 and st THENBUY positionsize CONTRACT AT MARKETSET STOP pLOSS SLTP = RR * SLSET TARGET pPROFIT TPsamebarsignal = 1ENDIF//====== Enter market - end =====//====== Exit market - start =====IF NOT ONMARKET THENENDIF//====== Exit market - end =====// breakeven stop atronce breakevenstoptype = 1 // breakeven stop - 0 off, 1 ononce breakevenstoplong = 1 // breakeven stop atr relative distanceonce breakevenstopshort = 1 // breakeven stop atr relative distanceonce pointstokeep = 5 // positive or negativeonce atrperiodbreakeven = 14 // atr parameter valueonce minstopbreakeven = 36 // minimum breakeven stop distance//----------------------------------------------atrbreakeven = averagetruerange[atrperiodbreakeven]((close/10)*pipsize)/1000//atrbreakeven=averagetruerange[atrperiodbreakeven]((close/1)*pipsize) // (forex)bestopl = round(atrbreakeven*breakevenstoplong)bestops = round(atrbreakeven*breakevenstopshort)if breakevenstoptype = 1 then//if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxpricebe = 0minpricebe = closenewslbe = 0endif//if longonmarket thenmaxpricebe = max(maxpricebe,close)if maxpricebe-tradeprice(1)>=bestopl*pointsize thenif maxpricebe-tradeprice(1)>=minstopbreakeven thennewslbe=tradeprice(1)+pointstokeep*pipsizeelsenewslbe=tradeprice(1)- minstopbreakeven*pointsizeendifendifendif//if shortonmarket thenminpricebe = min(minpricebe,close)if tradeprice(1)-minpricebe>=bestops*pointsize thenif tradeprice(1)-minpricebe>=minstopbreakeven thennewslbe = tradeprice(1)-pointstokeep*pipsizeelsenewslbe = tradeprice(1) + minstopbreakeven*pointsizeendifendifendif//if longonmarket thenif newslbe>0 thensell at newslbe stopendifif newslbe>0 thenif low < newslbe thensell at marketendifendifendif//if shortonmarket thenif newslbe>0 thenexitshort at newslbe stopendifif newslbe>0 thenif high > newslbe thenexitshort at marketendifendifendifendif1 user thanked author for this post.
05/28/2020 at 3:13 PM #133623Thanks @MAKSIDE for the idea.
For the 100% result, I guess you mean win rate? Not sure why, but I don’t get the same result with the parameters I set in the .itf.
If re-optimize the parameters, I have some combination giving 100% win rate, but the trade number is way too low <5. Do you observe the same?
If possible, can you please share the .itf?
05/28/2020 at 3:45 PM #13362705/30/2020 at 4:51 PM #13391006/01/2020 at 8:57 AM #134018hello how did you define x and y to make the code work?
I don’t see an optimization report to help with the decision ..? Thank you Best regards.06/01/2020 at 12:55 PM #134051Hi DowJones
Thanks for your work
Something I dn’t understand is the ATR instead of a number of bars ?
12adjacentB = (close[periodA] - close[periodA + periodB]) / M1atrAB[periodA]angelB = atan(adjacentB)Because to calculate Arctangente you need the opposite side : (close[periodA] – close[periodA + periodB] Thant’s ok
But M1atrAB[periodA] is not the adajacent side ?
I understand your explannations but don’t think it will be the same
Cheers
1 user thanked author for this post.
06/01/2020 at 9:00 PM #134105And I don’t understand this part of your code
123456789if resetafterlost thenpositionsize = startingsizeelsif doublestepdown thenpositionsize = positionsize - stepsize * 2elsepositionsize = positionsize - stepsizeendifwincount = 0endifBecause I think you decrement position size when position perf is negative but resetafterlost is always at 0 and doublestepdown too.
Does something mis as a count on loss trades ?
Thanks
1 user thanked author for this post.
06/02/2020 at 12:56 PM #134210I understand your explannations but don’t think it will be the same
Hi @zilliq, indeed. I understand your concern. Using ATR is just taking the reference where x bar in average moved by y point (range). Rather than taking directly the bar, because the bar unit is totally not relevant with point unit. For sure both analogy is still not the same like measuring with ruler with centimeter, but at least using bar vs point are less relevant, e.g. from 5 bars, it moves from 21000 to 21150, so taking arctan of 5 and 150 vs from 5 bars, ATR is 50, it moves from 21000 to 21150, so taking arctan of 50 and 150
but resetafterlost is always at 0 and doublestepdown too
From GRAPH, right? Because I never activate it (line 5) 🙂 I left it like a template and forget to remove it.
1MM = 0 // = 0 for optimization06/02/2020 at 3:15 PM #134230Thanks for you answer Dowjones. I understand for ATR, it’s a different point of view
For the second part, sorry for my bad explanations
I said that resetafterlost is always at 0 so the condition is always at ON (instead to be at 0 some times and if positionsperf(1)<0 to be at 1 for example) and same for doublestepdown. So how can the code understand wich choice to use ?
Hope to be clear
06/04/2020 at 1:37 PM #134555So how can the code understand wich choice to use ?
Ah, sorry for misunderstanding. These are actually configuration parameter, to be chosen accordingly which is preferred.
once maxSize = 2once minSize = 1once startingsize = 1once stepsize = 0.5once resetafterlost = 0once doublestepdown = 0once resetafterstrikewin = 2Whether you prefer to reset the lot back to startingsize once hit a single loss trade, or you prefer to doublestepdown. It is choice need to be made.
So if you choose resetafterlost, then doublestepdown will not be applicable even if you set it to 1. By default, all are set to 0, so once there is a loss trade, the lot size will be reduced by sizestep
06/04/2020 at 10:08 PM #134604 -
AuthorPosts
Find exclusive trading pro-tools on