Strategy TrendImpulse v1
Forums › ProRealTime English forum › ProOrder support › Strategy TrendImpulse v1
- This topic has 74 replies, 6 voices, and was last updated 1 year ago by thomas2004ch.
-
-
04/30/2020 at 1:49 PM #12902804/30/2020 at 2:09 PM #12903504/30/2020 at 4:04 PM #12906804/30/2020 at 4:20 PM #129075
do you speak french ?
Even if you do then please do not do so in the English speaking forums. Start a fresh topic in the French forum if you wish to discuss things in French.
04/30/2020 at 4:45 PM #12908304/30/2020 at 6:48 PM #129107Wahrscheinlich meinte er diese Meldung siehe Anhang. Ich kann den Code auch nicht starte. Ich soll die Variablen einfügen. Aber weiß nicht wie.He probably meant this message see attachment. I can’t start the code either. I should insert the variables. But don’t know how.
04/30/2020 at 7:05 PM #129109Maik2404 – You failed to attach any image plus….
There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.
The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:
Post your topic in the correct forum.
ProRealTime Platform Support only platform related issues.
ProOrder only strategy topics.
ProBuilder only indicator topics.
ProScreener only screener topics
General Discussion any other topics.
Welcome New Members for new forum members to introduce themselves.Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
Always be polite and courteous to others.
Have fun.I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂
04/30/2020 at 7:06 PM #129110Maik Fred, as Yahootew mentions in the original post, try downloading XXXDJI-M1-TrendImpulsev1-1.itf
That version contains the variables. Maybe it solves your problem
04/30/2020 at 7:12 PM #12911104/30/2020 at 9:09 PM #12914004/30/2020 at 9:47 PM #12914305/01/2020 at 10:47 PM #129327Thanks a lot yahootex3000.
I was looking at the DLS conditions.
Things become a bit more complicated if we live in Europe, since we too have a DLS period… but not exactly on the same period as USA !
In Europe, DLS time begins on the last Sunday of March, and ends on the last Sunday of October.
As a consequence, during 2 short periods, in March (from the 2nd Sunday to the last Sunday) and in October/November (from the las Sunday of October to the 1st Sunday of November), the time difference is only 5 hrs, while it is 6 hrs during the other part of the year. I am trying to solve the equation !
05/04/2020 at 8:32 AM #129712In Europe, DLS time begins on the last Sunday of March, and ends on the last Sunday of October.
Indeed, I have a code for DLS conversion of ASIA->UK, but no UK (or EUR) -> USA. Anyway, I share also the UK version here, hope it can help a bit…
123456789// --------- UK DAY LIGHT SAVINGS MONTHS ---------------- //mar = month = 3 // MONTH STARToct = month = 10 // MONTH ENDIF ( dayofweek >= 0 and mar AND 31-day<7 ) OR ( month > 3 AND month < 10 ) OR ( oct AND 31-day > 6 ) OR (dayofweek = 4 AND oct AND day<31) OR (dayofweek = 3 AND oct AND day+1<31) OR (dayofweek = 2 AND oct AND day+2<31) OR (dayofweek = 1 AND oct AND day+3<31) OR (dayofweek = 0 AND oct AND day+4<31) OR (dayofweek = 5 AND oct AND 31-day<7) THENUKDLS=1ELSEUKDLS=0ENDIF05/04/2020 at 10:25 AM #129779Hi All,
I integrated the ML + Trailing Stop and replace the trendimpulse with bollinger, result seems better. Also added ATR to filter out the huge volatility and cause big losses or big winners (especially March) to be more practical for live.
Take note I’m taking 90-10 WFA 5 iterations to optimize the startingvalue and startingvalue2.
Please see attached.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389DEFPARAM CumulateOrders = falseDEFPARAM PRELOADBARS = 1000// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //mar = month = 3 // MONTH STARTnov = month = 11 // MONTH ENDIF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THENUSDLS=010000ELSEUSDLS=0ENDIFtimeok = NOT(time >051500- USDLS AND time <053000 - USDLS) AND NOT(time >060000 - USDLS AND time <070000 - USDLS)//startingvalue = 15 //5, 100, 10 boxsizeincrement = 5 //5, 20, 10maxincrement = 7 //5, 10 limit of no of increments either up or downreps = 3 //1 number of trades to use for analysis //2maxvalue = 70 //20, 300, 150 //maximum allowed valueminvalue = 50 //5, minimum allowed value//startingvalue2 = 55 //5, 100, 50 stop lossincrement2 = 3 //5, 10maxincrement2 = 7 //1, 30 limit of no of increments either up/down //4reps2 = 3 //1, 2 nos of trades to use for analysis //3maxvalue2 = 25 //20, 300, 200 maximum allowed valueminvalue2 = 5 //5, minimum allowed valueheuristicscyclelimit = 2once heuristicscycle = 0once heuristicsalgo1 = 1once heuristicsalgo2 = 0if heuristicscycle >= heuristicscyclelimit thenif heuristicsalgo1 = 1 thenheuristicsalgo2 = 1heuristicsalgo1 = 0elsif heuristicsalgo2 = 1 thenheuristicsalgo1 = 1heuristicsalgo2 = 0endifheuristicscycle = 0elseonce valuex = startingvalueonce valuey = startingvalue2endifif heuristicsalgo1 = 1 then//heuristics algorithm 1 startif (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) thenoptimise = optimise + 1endifonce valuex = startingvalueonce pincpos = 1 //positive increment positiononce nincpos = 1 //negative increment positiononce optimise = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)once mode1 = 1 //switches between negative and positive increments//once wincountb = 3 //initialize best win count//graph wincountb coloured (0,0,0) as "wincountb"//once stratavgb = 4353 //initialize best avg strategy profit//graph stratavgb coloured (0,0,0) as "stratavgb"if optimise = reps thenwincounta = 0 //initialize current win countstratavga = 0 //initialize current avg strategy profitheuristicscycle = heuristicscycle + 1for i = 1 to reps doif positionperf(i) > 0 thenwincounta = wincounta + 1 //increment current wincountendifstratavga = stratavga + (((positionperf(i)*countofposition[i]*close)*-1)*-1)nextstratavga = stratavga/reps //calculate current avg strategy profit//graph (positionperf(1)*countofposition[1]*100000)*-1 as "posperf1"//graph (positionperf(2)*countofposition[2]*100000)*-1 as "posperf2"//graph stratavga*-1 as "stratavga"//once besta = 300//graph besta coloured (0,0,0) as "besta"if stratavga >= stratavgb thenstratavgb = stratavga //update best strategy profitbesta = valuexendif//once bestb = 300//graph bestb coloured (0,0,0) as "bestb"if wincounta >= wincountb thenwincountb = wincounta //update best win countbestb = valuexendifif wincounta > wincountb and stratavga > stratavgb thenmode1 = 0elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 1 thenvaluex = valuex - (increment*nincpos)nincpos = nincpos + 1mode1 = 2elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 1 thenvaluex = valuex + (increment*pincpos)pincpos = pincpos + 1mode1 = 1elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 2 thenvaluex = valuex + (increment*pincpos)pincpos = pincpos + 1mode1 = 1elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 2 thenvaluex = valuex - (increment*nincpos)nincpos = nincpos + 1mode1 = 2endifif nincpos > maxincrement or pincpos > maxincrement thenif besta = bestb thenvaluex = bestaelseif reps >= 10 thenweightedscore = 10elseweightedscore = round((reps/100)*100)endifvaluex = round(((besta*(20-weightedscore)) + (bestb*weightedscore))/20) //lower reps = less weight assigned to win%endifnincpos = 1pincpos = 1elsif valuex > maxvalue thenvaluex = maxvalueelsif valuex < minvalue thenvaluex = minvalueendifoptimise = 0endif// heuristics algorithm 1 endelsif heuristicsalgo2 = 1 then// heuristics algorithm 2 startif (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) thenoptimise2 = optimise2 + 1endifonce valuey = startingvalue2once pincpos2 = 1 //positive increment positiononce nincpos2 = 1 //negative increment positiononce optimise2 = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)once mode2 = 1 //switches between negative and positive increments//once wincountb2 = 3 //initialize best win count//graph wincountb2 coloured (0,0,0) as "wincountb2"//once stratavgb2 = 4353 //initialize best avg strategy profit//graph stratavgb2 coloured (0,0,0) as "stratavgb2"if optimise2 = reps2 thenwincounta2 = 0 //initialize current win countstratavga2 = 0 //initialize current avg strategy profitheuristicscycle = heuristicscycle + 1for i2 = 1 to reps2 doif positionperf(i2) > 0 thenwincounta2 = wincounta2 + 1 //increment current wincountendifstratavga2 = stratavga2 + (((positionperf(i2)*countofposition[i2]*close)*-1)*-1)nextstratavga2 = stratavga2/reps2 //calculate current avg strategy profit//graph (positionperf(1)*countofposition[1]*100000)*-1 as "posperf1-2"//graph (positionperf(2)*countofposition[2]*100000)*-1 as "posperf2-2"//graph stratavga2*-1 as "stratavga2"//once besta2 = 300//graph besta2 coloured (0,0,0) as "besta2"if stratavga2 >= stratavgb2 thenstratavgb2 = stratavga2 //update best strategy profitbesta2 = valueyendif//once bestb2 = 300//graph bestb2 coloured (0,0,0) as "bestb2"if wincounta2 >= wincountb2 thenwincountb2 = wincounta2 //update best win countbestb2 = valueyendifif wincounta2 > wincountb2 and stratavga2 > stratavgb2 thenmode2 = 0elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 1 thenvaluey = valuey - (increment2*nincpos2)nincpos2 = nincpos2 + 1mode2 = 2elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 1 thenvaluey = valuey + (increment2*pincpos2)pincpos2 = pincpos2 + 1mode2 = 1elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 2 thenvaluey = valuey + (increment2*pincpos2)pincpos2 = pincpos2 + 1mode2 = 1elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 2 thenvaluey = valuey - (increment2*nincpos2)nincpos2 = nincpos2 + 1mode2 = 2endifif nincpos2 > maxincrement2 or pincpos2 > maxincrement2 thenif besta2 = bestb2 thenvaluey = besta2elseif reps2 >= 10 thenweightedscore2 = 10elseweightedscore2 = round((reps2/100)*100)endifvaluey = round(((besta2*(20-weightedscore2)) + (bestb2*weightedscore2))/20) //lower reps = less weight assigned to win%endifnincpos2 = 1pincpos2 = 1elsif valuey > maxvalue2 thenvaluey = maxvalue2elsif valuey < minvalue2 thenvaluey = minvalue2endifoptimise2 = 0endif// heuristics algorithm 2 endendif//GRAPH valuex//GRAPH valueytimeframe(1 day)volindic = (averagetruerange[5](close)/close)*100timeframe(5 minute)thigh1 = Highest[valuex](high)+ SlowPipDisplace*pointsizetlow1 = Lowest[valuex](low)- SlowPipDisplace*pointsizethigh2 = Highest[valuey](high)+ FastPipDisplace*pointsizetlow2 = Lowest[valuey](low)- FastPipDisplace*pointsizeif barindex>2 thenif Close>line1[1] thenline1 = tlow1elseline1 = thigh1endifif Close>line2[1] thenline2 = tlow2elseline2 = thigh2endifendifif (Close[0]<line1[0] and Close[0]<line2[0]) thentrend = 1endifif (Close[0]>line1[0] and Close[0]>line2[0]) thentrend = -1endifif (line1[0]>line2[0] or trend[0] = 1) thentrena = 1endifif (line1[0]<line2[0] or trend[0] = -1) thentrena = -1endifif trena<>trena[1] thenif trena=1 then//bearprefecttrend = 2else//bullprefecttrend = 1endifendiftimeframe(default)bollMA = average[length, 1](close)//50,1STDDEV = STD[length]bollUP = bollMA + 2 * STDDEVbollDOWN = bollMA - 2 * STDDEVbollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)//====== Enter market - start =====// LONG sideC1 = bollPercent > 60 AND prefecttrend[1] = 2 AND prefecttrend = 1IF timeok AND Not OnMarket AND C1 AND volindic < 3.5 THENBUY 1 CONTRACT AT MARKETSET STOP pLOSS SLENDIF// SHORT sideC2 = bollPercent < 40 AND prefecttrend[1] = 1 AND prefecttrend = 2IF timeok AND Not OnMarket AND C2 AND volindic < 3.5 THENSELLSHORT 1 CONTRACT AT MARKETSET STOP pLOSS SLENDIF//====== Enter market - end =====//====== Exit market - start =====X1 = prefecttrend[1] = 1 AND prefecttrend = 2IF LONGONMARKET AND X1 THENSELL AT MARKETENDIFX2 = prefecttrend[1] = 2 AND prefecttrend = 1IF SHORTONMARKET AND X2 THENEXITSHORT AT MARKETENDIF// Avoid losing trade not caught by trainingtradegain = POSITIONPERF * 100rangelevel = 100* (range)/closegainenough = summation[barindex - tradeindex](tradegain > 0.2) > 1closefast = gainenough AND rangelevel < 0.5 AND POSITIONPERF * 100 <= 0.1IF closefast THENEXITSHORT AT MARKETSELL AT MARKETENDIF//====== Exit market - end =====//====== Trailing Stop mechanism - start =====trailingstart = (0.5 * SL ) / pointsizetrailingstep = (0.25 * SL ) / pointsize//resetting variables when no trades are on marketif not onmarket thenpriceexit = 0endif//case LONG orderif longonmarket then//first move (breakeven)IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THENpriceexit = tradeprice(1) + trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = close-priceexit >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit + trailingstep*pointsizeENDIFENDIFendif//case SHORT orderif shortonmarket then//first move (breakeven)IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THENpriceexit = tradeprice(1) - trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = priceexit-close >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit - trailingstep*pointsizeENDIFENDIFendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif//====== Trailing Stop mechanism - end =====05/04/2020 at 2:29 PM #129849Hi yahootew3000
Thank you very interesting strategy. I worked a lot on your previews version. I think some entry point missed because of the closure of a previous position.
I’m going to look at your new one. Boll are interesting indeed. On you result screen below which variable did you use? Even with optimization tool starting date 2019, I can find out the same result. Maybe i’m wrong on something, is there variable to modify in the code text directly?
Many thanks for the work.
-
AuthorPosts
Find exclusive trading pro-tools on