JayRogers

Simple Horizontal Value and Offsets [Auto Shift]

3670 lượt xem
256
Original (Simple Horizontal Value and Offsets/ SHV ) Requested by @TAFA94

Description:
  • 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.

**NOTE**
  • 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.

Cheers!
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
//@version=2

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.

// - INPUTS START
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") 
// - INPUTS END

// - FUNCTIONS START
// 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
// - FUNCTIONS END

// - PLOTTING START
// 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)
// - PLOTTING END

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
Long
+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
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Cách thức hoạt động Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Xu Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất