Simple Horizontal Value and Offsets [Auto Shift]

จำนวนเข้าชม 4434
Original (Simple Horizontal Value and Offsets/ SHV ) Requested by @TAFA94

  • Simple adjustable incremented horizontal offset lines extending up and down from a Median point.
  • Set full value for manual Median point control, or set an incremental rounding value for auto Median adjustment.
  • Source and look-back period inputs for fine tuning auto adjust.
  • Auto adjust on by default - can be toggled off for straight manual control.

  • All values will likely need to be changed immediately on applying this script, in order to properly fit your charts specific price/value range and/or time resolution.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

study(title="Simple Horizontal Value and Offsets [Auto Shift]", shorttitle="SHV_AS", overlay=true)

// Revision:    1
// Author:      JayRogers
// Description:
//  - Original (Simple Horizontal Value and Offsets/SHV) Requested by @TAFA94
//  - Simple horizontal values extending up and down from a median value.
//  - Set Median Value, and set offset values. Simples.
// r2 Changes/Description:
//  - Source Look-Back and rounding for automatically adjusting median point to closest specified value
//  - True/False toggle for lookback in case you want to keep it all manual.

manualMed   = input(defval=1.09,    title="Manual Median Value [Full]")
offsetVal   = input(defval=0.0025,  title="Offset Value [+/- line increments]")
autoMed     = input(defval=true,    title="Auto adjust Median based on Look-Back Period?")
autoRnd     = input(defval=0.005,   title="Auto Median Rounding Value [Incremental]")
autoSrc     = input(defval=open,    title="Look-Back Rounding Source")
autoLen     = input(defval=60,      title="Look-Back Period") 

// Get the rounded median point
medianRound() => round((sum(autoSrc, autoLen) / autoLen) / autoRnd) * autoRnd
// Offset multiplier function.
offsetMult(num) => num * offsetVal
// Are we auto adjusting the median?
getMedian() => autoMed ? medianRound() : manualMed

// Style variables for quicker edits
lc  = aqua      // color basis
sto = circles   // odd line style
ste = circles   // even line style
tro = 50        // odd line transparency
tre = 25        // even line transparency
// Median line
midline = plot(getMedian(), title="Median Line", color=lc, style=line, linewidth=2, transp=30)
// Upward offsets
plus1   = plot(getMedian() + offsetMult(1), title="Plus 1", color=lc, style=sto, transp=tro)
plus2   = plot(getMedian() + offsetMult(2), title="Plus 2", color=lc, style=ste, transp=tre)
plus3   = plot(getMedian() + offsetMult(3), title="Plus 3", color=lc, style=sto, transp=tro)
plus4   = plot(getMedian() + offsetMult(4), title="Plus 4", color=lc, style=ste, transp=tre)
plus5   = plot(getMedian() + offsetMult(5), title="Plus 5", color=lc, style=sto, transp=tro)
plus6   = plot(getMedian() + offsetMult(6), title="Plus 6", color=lc, style=ste, transp=tre)
plus7   = plot(getMedian() + offsetMult(7), title="Plus 7", color=lc, style=sto, transp=tro)
plus8   = plot(getMedian() + offsetMult(8), title="Plus 8", color=lc, style=ste, transp=tre)
plus9   = plot(getMedian() + offsetMult(9), title="Plus 9", color=lc, style=sto, transp=tro)
plus10  = plot(getMedian() + offsetMult(10), title="Plus 10", color=lc, style=ste, transp=tre)
// Downward offsets
minus1  = plot(getMedian() - offsetMult(1), title="minus 1", color=lc, style=sto, transp=tro)
minus2  = plot(getMedian() - offsetMult(2), title="minus 2", color=lc, style=ste, transp=tre)
minus3  = plot(getMedian() - offsetMult(3), title="minus 3", color=lc, style=sto, transp=tro)
minus4  = plot(getMedian() - offsetMult(4), title="minus 4", color=lc, style=ste, transp=tre)
minus5  = plot(getMedian() - offsetMult(5), title="minus 5", color=lc, style=sto, transp=tro)
minus6  = plot(getMedian() - offsetMult(6), title="minus 6", color=lc, style=ste, transp=tre)
minus7  = plot(getMedian() - offsetMult(7), title="minus 7", color=lc, style=sto, transp=tro)
minus8  = plot(getMedian() - offsetMult(8), title="minus 8", color=lc, style=ste, transp=tre)
minus9  = plot(getMedian() - offsetMult(9), title="minus 9", color=lc, style=sto, transp=tro)
minus10 = plot(getMedian() - offsetMult(10), title="minus 10", color=lc, style=ste, transp=tre)
If you like what I do, consider buying me a nice fresh cup of tea :)



Great work. By the way, doesn`t work correctly on 3-digits charts like usd/jpy.
+1 ตอบกลับ
JayRogers al.tribun
It functions as intended - you just need to properly adjust the values.

For USDJPY, try setting the Auto Median value to 0.5 (rather than the 0.005 default) and the incremental to 0.1 - I just fired up a chart to confirm this works.

+1 ตอบกลับ
al.tribun JayRogers
Ok. Thanks.
+1 ตอบกลับ
JayRogers albertos
But looking risky on shorter time frames. ...just to be sure, you realize this is simply a script idea, rather than an actual idea for market direction? :)
หน้าแรก ตัวช่วยคัดกรองหุ้น ตัวคัดกรองฟอเร็กซ์ ตัวคัดกรองคริปโต ปฏิทินเศรษฐกิจ เกี่ยวกับ ฟีเจอร์ของชาร์ต อัตราค่าบริการ แนะนำเพื่อน กฎระเบียบการใช้งาน ศูนย์ช่วยเหลือ โซลูชั่นสำหรับเว็บไซต์ & โบรกเกอร์ วิดเจ็ต ชาร์ตโซลูชั่น Lightweight ชาร์ตไลบรารี บล็อก & ข่าว Twitter