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/27/2020 at 4:55 AM #128304
Hi everyone,
Here is a new strategy on Wall Street/DJI 5 min TF that utilize Perfect Trend Line as entry/exit and Trend Impulse Filter as trend direction. All credits to the original author.
DLS code is added to avoid high spread period. Time Zone used is UTC+08:00. Looking forward for your suggestion and ideas of improvement.
XXXDJI-M1-TrendImpulsev1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115DEFPARAM 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)timeframe(5 minute)thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsizetlow1 = Lowest[SlowLength](low)- SlowPipDisplace*pointsizethigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsizetlow2 = Lowest[FastLength](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)once bb = srcif barindex>length thensrc = (highest[length](high)+lowest[length](low))/2rising = src-src[length]>0falling = src-src[length]<0aa = rising or fallingbb = exponentialaverage[centertrend](aa*src+(1-aa)*bb[1])//—-if bb>bb[1] then//bulltrendimpulse = 1elsif bb<bb[1] then//beartrendimpulse = 2endifendif//====== Enter market - start =====// LONG sideC1 = trendimpulse = 1 AND prefecttrend[1] = 2 AND prefecttrend = 1IF timeok AND Not OnMarket AND C1 THENBUY 1 CONTRACT AT MARKETSET STOP pLOSS SLENDIF// SHORT sideC2 = trendimpulse = 2 AND prefecttrend[1] = 1 AND prefecttrend = 2IF timeok AND Not OnMarket AND C2 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//====== Exit market - end =====04/27/2020 at 5:04 AM #128311Please use XXXDJI-M1-TrendImpulsev1-1.itf, I cannot delete XXXDJI-M1-TrendImpulsev1.itf. Anyway, they are functionally the same, but v1 has the variable [center] which cannot be interpreted by Insert PRT code correctly, thus I rename it to [centertrend]
04/27/2020 at 7:34 AM #128315Thanks a lot @yahootew3000. Did you make backtests with “only” 2 OOS please? What about the results if you exclude the last 3 months periods? (start the backtest earlier or just shorten the end date). I think that for most trend following strategy, the last period OOS is not so relevant because of the large volatility and directional bias of the market, just my humble opinion.
04/27/2020 at 11:07 AM #128392Time Zone used is UTC+08:00
How come you used UTC + 8 when you are UTC +2 in Netherlands?
Great looking code / System btw!
Thank You for sharing with us all!
1 user thanked author for this post.
04/27/2020 at 11:48 AM #128396How come you used UTC + 8 when you are UTC +2 in Netherlands?
Looks like more Singapore than Netherlands, doesn’t it?
1 user thanked author for this post.
04/27/2020 at 12:01 PM #128400Looks like more Singapore than Netherlands, doesn’t it?
His flag you mean?
It’s weird on his post his flag looks like Singapore? But then when I click on his name I see a Netherlands flag??
But yeah … UTC + 8 would be correct for Singapore as Singapore is 12 hours ahead of New York.
Now to convert for UK Time (UTC +1)
EDIT / PS
Now I look more closely you are correct Roberto … both flags are Singapore!
My eyes again, but also the flags appear so tiny on my screen.
04/27/2020 at 3:20 PM #128449Thanks a lot @yahootew3000. Did you make backtests with “only” 2 OOS please? …
Oh ya Nicolas. I did just 2 OOS, used to 1 min time frame. I redo for 5 OOS, seems not so good 🙁 I like this system due to high frequency, but perhaps need to add some other filter…
04/27/2020 at 3:27 PM #128453Now I look more closely you are correct Roberto … both flags are Singapore!
Haha, yes, from Singapore indeed…
1 user thanked author for this post.
04/30/2020 at 12:27 AM #128898Hi, congrats for the strategy, it works great with indexes. It’s probably a newbie’s question, but here it goes: how come when I apply this startegy to indexes the performance is great, but when I apply it to a stock the result is not good. I have tried in many different ways to get a good performance with different stocks, but no success. Maybe I am getting this wrong, but isn’t the end objective to apply these to stocks, as we can not buy indexes? sory for the ignorance…
Another issue I have encountered is that the command “timeframe” is not accepted by prorealtime 10.3, it returns a message that says it is only allowed for ProScreener. How did you manage to make it work?
Cheers and thanks for the great strategy
Luis
04/30/2020 at 12:15 PM #128990No worry, in fact, I’m new as well, I learned a lot from this forum actually 🙂how come when I apply this startegy to indexes the performance is great, but when I apply it to a stock the result is not good.
It is built for the index future only, not for a specific stock, the variables may not be suitable, the SL range is different as well. But I think take some effort, it is possible to apply for stock, but I have less interest to trade algo on stock as you can see this strategy is for frequent trade, if applying on stocks, the commission is costly.
Maybe I am getting this wrong, but isn’t the end objective to apply these to stocks, as we can not buy indexes?
Not trading against the index itself, but the future contract of the index. The trade is done using CFD.
Another issue I have encountered is that the command “timeframe” is not accepted by prorealtime 10.3
PRT 10.3 should support it. I don’t know if there is any known issue. @Nicolas, maybe you encounter similar question before or know the answer?
04/30/2020 at 12:18 PM #128993If your broker not support real live automatic trading, this error is normal since you still using a previous version of the platform.
1 user thanked author for this post.
04/30/2020 at 12:45 PM #128998Now to convert for UK Time (UTC +1)
Did you manage to get this to run on UK time? I tried subtracting 7 hours from all times but makes no difference, results are dismal using the fixed values in the opt box.
04/30/2020 at 1:07 PM #129007I agree @Nonetheless and I don’t think it’s times either as they are only short periods where spread is sky high.
I put it on the back burner for a while … be good if we can solve the mystery as the OP and Lucho0712 say it works great!?
1 user thanked author for this post.
04/30/2020 at 1:28 PM #12901804/30/2020 at 1:30 PM #129019 -
AuthorPosts
Find exclusive trading pro-tools on