Wing’s Trend Lines
This indicator draws up to 12 trend lines, based on previous high/low points. I created it to trade manually with it, but it can also be implemented into a strategy. An old indicator that will work on both 10.2 and 10.3. It could be improved using the new functionalities in 10.3.
Features:
- Displays 1-12 trend lines. (Up to 6 lines of support and 6 lines of resistance)
- Trend lines are updated automatically, just like a regular indicator.
- If you decrease the amount of lines (parameter ‘DisplayedLines’) shown, from 12 to 6 for example, it will prioritize recent trends and not show older trends.
- Parameter ‘p’ can be changed to increase or decrease the trend lookback. Big or small trends.
- Lines are angled Support and Resistance lines based on RSI high/low points.
- How to trade: Price will bounce when approaching a trend line (mean reversion) or go through and continue (breakout). Not all instruments are good to trade with the indicator, but they will be in some timeframes.
- Does not display horizontal lines of interest (there’s other indicators for that) unless made up by least two price points.
Note that if you load 10000 bars or more it can take some time to load. Note that it does not draw lines into the future (it could probably be updated to do that). When switching trend it will also create ugly vertical change, but it works like a charm.
If you want to apply the indicator, download it, import it, and right-click your price bars and then add the indicator to your price.
I can answer questions in the comments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
//////////////////////////////////////////////////// // // Wing's Trend Lines - (Support and Resistance) // // Made by user "Wing" of ProRealCode.com // https://www.prorealcode.com/user/wing/ // ////////////////////////////////////////////////// // // Parameter: // p = 7 // 'lookback' / scale // LinesDisplayed=12 ////////////////////////////////////////////////// rs=RSI[p] once t1=0 once t2=0 once t3=0 once t4=0 once b1=0 once b2=0 once b3=0 once b4=0 once top=0 if rs[4]>70 and high[4]>high[3] and high[4]>high[2] and high[4]>high[1] and high[4]>high and top=0 then t4=t3 t3=t2 t2=t1 t1=barindex-4 top=6 endif if rs[4]<30 and low[4]<low[3] and low[4]<low[2] and low[4]<low[1] and low[4]<low and top=0 then b4=b3 b3=b2 b2=b1 b1=barindex-4 top=6 endif if top>0 then top=top-1 endif // tops if high[barindex-t2]>high[barindex-t1] then linet1=high[barindex-t2]-(((barindex-t2)*sqrt(square(high[barindex-t1]-high[barindex-t2])))/(t1-t2)) else linet1=high[barindex-t2]+(((barindex-t2)*sqrt(square(high[barindex-t1]-high[barindex-t2])))/(t1-t2)) endif if high[barindex-t3]>high[barindex-t2] then linet2=high[barindex-t3]-(((barindex-t3)*sqrt(square(high[barindex-t2]-high[barindex-t3])))/(t2-t3)) else linet2=high[barindex-t3]+(((barindex-t3)*sqrt(square(high[barindex-t2]-high[barindex-t3])))/(t2-t3)) endif if high[barindex-t3]>high[barindex-t1] then linet21=high[barindex-t3]-(((barindex-t3)*sqrt(square(high[barindex-t1]-high[barindex-t3])))/(t1-t3)) else linet21=high[barindex-t3]+(((barindex-t3)*sqrt(square(high[barindex-t1]-high[barindex-t3])))/(t1-t3)) endif if high[barindex-t4]>high[barindex-t1] then linet3=high[barindex-t4]-(((barindex-t4)*sqrt(square(high[barindex-t1]-high[barindex-t4])))/(t1-t4)) else linet3=high[barindex-t4]+(((barindex-t4)*sqrt(square(high[barindex-t1]-high[barindex-t4])))/(t1-t4)) endif if high[barindex-t4]>high[barindex-t2] then linet31=high[barindex-t4]-(((barindex-t4)*sqrt(square(high[barindex-t2]-high[barindex-t4])))/(t2-t4)) else linet31=high[barindex-t4]+(((barindex-t4)*sqrt(square(high[barindex-t2]-high[barindex-t4])))/(t2-t4)) endif if high[barindex-t4]>high[barindex-t3] then linet32=high[barindex-t4]-(((barindex-t4)*sqrt(square(high[barindex-t3]-high[barindex-t4])))/(t3-t4)) else linet32=high[barindex-t4]+(((barindex-t4)*sqrt(square(high[barindex-t3]-high[barindex-t4])))/(t3-t4)) endif // bots if low[barindex-b2]>low[barindex-b1] then lineb1=low[barindex-b2]-(((barindex-t2)*sqrt(square(low[barindex-b1]-low[barindex-b2])))/(b1-b2)) else lineb1=low[barindex-b2]+(((barindex-b2)*sqrt(square(low[barindex-b1]-low[barindex-b2])))/(b1-b2)) endif if low[barindex-b3]>low[barindex-b2] then lineb2=low[barindex-b3]-(((barindex-b3)*sqrt(square(low[barindex-b2]-low[barindex-b3])))/(b2-b3)) else lineb2=low[barindex-b3]+(((barindex-b3)*sqrt(square(low[barindex-b2]-low[barindex-b3])))/(b2-b3)) endif if low[barindex-b3]>low[barindex-b1] then lineb21=low[barindex-b3]-(((barindex-b3)*sqrt(square(low[barindex-b1]-low[barindex-b3])))/(b1-b3)) else lineb21=low[barindex-b3]+(((barindex-b3)*sqrt(square(low[barindex-b1]-low[barindex-b3])))/(b1-b3)) endif if low[barindex-b4]>low[barindex-b1] then lineb3=low[barindex-b4]-(((barindex-b4)*sqrt(square(low[barindex-b1]-low[barindex-b4])))/(b1-b4)) else lineb3=low[barindex-b4]+(((barindex-b4)*sqrt(square(low[barindex-b1]-low[barindex-b4])))/(b1-b4)) endif if low[barindex-b4]>low[barindex-b2] then lineb31=low[barindex-b4]-(((barindex-b4)*sqrt(square(low[barindex-b2]-low[barindex-b4])))/(b2-b4)) else lineb31=low[barindex-b4]+(((barindex-b4)*sqrt(square(low[barindex-b2]-low[barindex-b4])))/(b2-b4)) endif if low[barindex-b4]>low[barindex-b3] then lineb32=low[barindex-b4]-(((barindex-b4)*sqrt(square(low[barindex-b3]-low[barindex-b4])))/(b3-b4)) else lineb32=low[barindex-b4]+(((barindex-b4)*sqrt(square(low[barindex-b3]-low[barindex-b4])))/(b3-b4)) endif // return values //resistance=(linet1+ linet2+ linet21+ linet3+ linet31+ linet32)/6 //support=(lineb1+ lineb2+ lineb21+ lineb3+ lineb31+ lineb32)/6 //midpoint=(resistance+support)/2 if linesdisplayed<12 then lineb32=linet1 endif if linesdisplayed<11 then linet32=linet1 endif if linesdisplayed<10 then lineb31=linet1 endif if linesdisplayed<9 then linet31=linet1 endif if linesdisplayed<8 then lineb3=linet1 endif if linesdisplayed<7 then linet3=linet1 endif if linesdisplayed<6 then lineb21=linet1 endif if linesdisplayed<5 then linet21=linet1 endif if linesdisplayed<4 then lineb2=linet1 endif if linesdisplayed<3 then linet2=linet1 endif if linesdisplayed<2 then lineb1=linet1 endif return linet1, linet2, linet21, linet3, linet31, linet32, lineb1, lineb2, lineb21, lineb3, lineb31, lineb32 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Nice aproach, have you ever try to implement it for patterns recognitions, like double top/bottom?
Not yet but I plan to.
Have a look in this Forum, I got something interesting for you… https://www.prorealcode.com/topic/dobule-bottom-or-double-top
Dear Wing,
As I am a daytrader, and one of my best friend is a programmer we think your approach of support and resistance lines are really interesting! Thank you for sharing your idea! To be honest, I really would like to try it in another platform I use daily, and my friend said that he will rewrite the code to being able to use on that platform, but we would have one question before we could finish that.
Do we assume correctly that, line t1, t2 etc. are just Y coordinates for the current X value bar, or tick?!
Thank you very much
David