Simple Horizontal Value and Offsets [Auto Shift]

4740 lượt xem
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.

Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

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 :)


Bình luận

Great work. By the way, doesn`t work correctly on 3-digits charts like usd/jpy.
+1 Phản hồi
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 Phản hồi
al.tribun JayRogers
Ok. Thanks.
Phản hồi
+1 Phản hồi
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? :)
Phản hồi