JayRogers

Simple Horizontal Value and Offsets [Auto Shift]

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!
Remove from Favorite Scripts Add to Favorite Scripts
//@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
albertos
11 months ago
Long
+1 Reply
JayRogers albertos
11 months ago
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? :)
Reply
al.tribun
10 months ago
Great work. By the way, doesn`t work correctly on 3-digits charts like usd/jpy.
+1 Reply
JayRogers al.tribun
10 months ago
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 Reply
al.tribun JayRogers
10 months ago
Ok. Thanks.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out