Leave Feedback //@version=4 study(title = "Color MA with Threshold", shorttitle="CMA+",…
- User
Leave Feedback
//@version=4 study(title = "Color MA with Threshold", shorttitle="CMA+", overlay=true)
// Inputs length = input(9, minval=1, title="Length") src = input(close, title="Source") matype = input(1, minval=1, maxval=5, title="AvgType") thresholdLength = input(14, minval=1, title="Slope StdDev Length") mult = input(1.0, title="StdDev Multiplier")
// Moving averages simplema = sma(src, length) exponentialma = ema(src, length) hullma = wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length))) weightedma = wma(src, length) volweightedma = vwma(src, length)
avgval = matype == 1 ? simplema : matype == 2 ? exponentialma : matype == 3 ? hullma : matype == 4 ? weightedma : matype == 5 ? volweightedma : na
// Calculate slope: difference between current and previous avgval slope = avgval - avgval[1]
// Calculate standard deviation of the slope over thresholdLength slope_std = stdev(slope, thresholdLength)
// Define thresholds upperThreshold = mult * slope_std lowerThreshold = -upperThreshold
// Determine color based on slope relative to thresholds Pcolor = slope > upperThreshold ? color.green : slope < lowerThreshold ? color.red : color.yellow
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.