Funky EMA 2
Funky EMA 2
0
at https://mozilla.org/MPL/2.0/
// © mindyourbuisness
//@version=6
indicator("Trend Heuristics", "TH", overlay = true)
import mindyourbuisness/CustomAlertLib/2 as CAL
// Rolling VWAP
// v3, 2022.07.24
import PineCoders/ConditionalAverages/1 as pc
// ————— Constants
int MS_IN_MIN = 60 * 1000
int MS_IN_HOUR = MS_IN_MIN * 60
int MS_IN_DAY = MS_IN_HOUR * 24
string TT_SRC = "The source used to calculate the VWAP. The default is the
average of the high, low and close prices."
string TT_WINDOW = "By default, the time period used to calculate the RVWAP
automatically adjusts with the chart's timeframe.
Check this to use a fixed-size time period instead, which you define with the
following three values."
string TT_MINBARS = "The minimum number of last values to keep in the moving
window, even if these values are outside the time period.
This avoids situations where a large time gap between two bars would cause the
time window to be empty."
string TT_STDEV = "The multiplier for the standard deviation bands offset above
and below the RVWAP. Example: 1.0 is 100% of the offset value.
\n\nNOTE: A value of 0.0 will hide the bands."
string TT_TABLE = "Displays the time period of the rolling window."
// Inputs
string groupName = "Rolling VWAP"
float srcInput = input.source(hlc3, "Source", tooltip = TT_SRC, group = groupName)
// ———————————————————— Functions {
// Signal calculations
float bodyRange = high - low
float closePosition = (close - low) / bodyRange
buySignalrvwap := open > upperBand1 and low < upperBand1 and close > upperBand1 and
closePosition >= 0.5 and lowerWick > upperWick and close > high[1]
sellSignalrvwap := open < lowerBand1 and high > lowerBand1 and close < lowerBand1
and closePosition <= 0.5 and upperWick > lowerWick and close < low [1]
// Plots
plot(showRVWAPInput ? rollingVWAP : na, "Rolling VWAP", rvwapColorInput)
// Signal plots
plotshape(showSignalInputrVwap and buySignalrvwap, "Buy Signal",
style=shape.triangleup, location=location.belowbar, color=BULL_COLOR,
size=size.tiny)
plotshape(showSignalInputrVwap and sellSignalrvwap, "Sell Signal",
style=shape.triangledown, location=location.abovebar, color=BEAR_COLOR,
size=size.tiny)
plotshape(showBreakoutSignals and bullishBreakout, "Bullish Breakout",
style=shape.circle, location=location.belowbar, color=BULL_COLOR, size=size.tiny)
plotshape(showBreakoutSignals and bearishBreakout, "Bearish Breakout",
style=shape.circle, location=location.abovebar, color=BEAR_COLOR, size=size.tiny)
// Alerts
if buySignalrvwap and showSignalInputrVwap
CAL.customAlert(alertFormat, str.tostring(syminfo.ticker) + ": Bullish sweep of
rolling VWAP")
if sellSignalrvwap and showSignalInputrVwap
CAL.customAlert(alertFormat, str.tostring(syminfo.ticker) + ": Bearish sweep of
rolling VWAP")
if bullishBreakout and showBreakoutSignals
CAL.customAlert(alertFormat, str.tostring(syminfo.ticker) + ": Bullish breakout
above VWAP")
if bearishBreakout and showBreakoutSignals
CAL.customAlert(alertFormat, str.tostring(syminfo.ticker) + ": Bearish breakout
below VWAP")