Wing's Trend Lines

Category: Indicators By: Wing Created: September 8, 2017, 9:47 AM
September 8, 2017, 9:47 AM
Indicators
4 Comments

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.

////////////////////////////////////////////////////
//
// 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

Download
Filename: WingsTrendLines.itf
Downloads: 307
Wing Veteran
I mostly trade DAX. My favorite strategy tool: Machine learning (yes, possible in ProOrder+ProBuilder). I like to answer questions about coding.
Author’s Profile

Comments

Logo Logo
Loading...