-
Notifications
You must be signed in to change notification settings - Fork 45
/
price_action
57 lines (45 loc) · 3.75 KB
/
price_action
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//@version=5
indicator('Donald - Price Action', 'Donald - Price Action', true, max_bars_back = 5000, max_lines_count = 500, max_boxes_count = 500)
// ---------------------------------------------------------------------------------------------- //
// High Volatility ------------------------------------------------------------------------------ //
import jdehorty/KernelFunctions/2 as kernels
// ~~~~~~~~~~~ INPUTS ~~~~~~~~~~~ //
smoothingLength = input.int(14, "Smoothing length", group="Momentum", tooltip="Smoothing length is the length used to smooth out our Bullish and Bearish signals, along with our Overly Bullish and Overly Bearish Signals.")
// Kernel Settings
lookbackWindow = input.int(8, "Lookback Window", tooltip="The number of bars used for the estimation. This is a sliding value that represents the most recent historical bars. Recommended range: 3-50", group="Kernel Settings")
relativeWeighting = input.float(8., "Relative Weighting", step=0.25, tooltip="Relative weighting of time frames. As this value approaches zero, the longer time frames will exert more influence on the estimation. As this value approaches infinity, the behavior of the Rational Quadratic Kernel will become identical to the Gaussian kernel. Recommended range: 0.25-25", group="Kernel Settings")
startBar = input.int(25, "Start Regression at Bar", tooltip="Bar index on which to start regression. The first bars of a chart are often highly volatile, and omission of these initial bars often leads to a better overall fit. Recommended range: 5-25", group="Kernel Settings")
//Bullish and bearish (these hold momentum and may be a safe way to know if the momentum is still going strong for the trend)
bullishBar = kernels.rationalQuadratic(close, lookbackWindow, relativeWeighting, startBar) > kernels.rationalQuadratic(ta.highest(ta.vwma(ohlc4, smoothingLength), smoothingLength), lookbackWindow, relativeWeighting, startBar)
bearishBar = kernels.rationalQuadratic(close, lookbackWindow, relativeWeighting, startBar) < kernels.rationalQuadratic(ta.lowest(ta.vwma(ohlc4, smoothingLength), smoothingLength), lookbackWindow, relativeWeighting, startBar)
//Very bullish and bearish (these may represent when the momentum is about to change as they are almost TOO Bullish and Bearish
rsi = kernels.rationalQuadratic(ta.rsi(close, smoothingLength), lookbackWindow, relativeWeighting, startBar)
vol = kernels.rationalQuadratic(volume, lookbackWindow, relativeWeighting, startBar)
//Kernal Crossing Calculations
kern1 = kernels.rationalQuadratic(close, lookbackWindow, relativeWeighting, startBar)
kern2 = kernels.gaussian(close, lookbackWindow - 2, startBar)
// Kernel Crossovers
var bool isBullishCross = na
if ta.crossover(kern2, kern1)
isBullishCross := true
var bool isBearishCross = na
if ta.crossunder(kern2, kern1)
isBearishCross := true
// Volume Moving Average : Base ----------------------------------------------------------------- //
nzVolume = nz(vol)
i_vSMA = kernels.rationalQuadratic(ta.vwma(vol, smoothingLength), lookbackWindow, relativeWeighting, startBar)
risingVol = nzVolume >= nzVolume[1]
bullCandle = close > open
bearCandle = close < open
rising = false
if bullCandle and bullCandle[1] and bullCandle[2] and nzVolume > i_vSMA and risingVol and risingVol[1]
if isBullishCross
rising := true
isBullishCross := false
falling = false
if bearCandle and bearCandle[1] and bearCandle[2] and nzVolume > i_vSMA and risingVol and risingVol[1]
if isBearishCross
falling := true
isBearishCross := false
plotshape(falling ? high : na, style=shape.labeldown, size = size.tiny, location=location.abovebar, color=#B99876, text='PUT Track', offset=0)
plotshape(rising ? low : na, style=shape.labelup, size = size.tiny, location=location.belowbar, color=color.white, text='CALL Track', offset=0)