/////////////////////////////////////////////////////// // // SaherElm IT Center Cycle Channel Oscillator // --------------------------------------------- // saherelm implementation of above oscillator ... // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // //@version=5 indicator(title="SaherElm Cycle Channel Oscillator", shorttitle = "XS_CC_OSC", overlay = false) // // START Inputs .... // scl_t = input.int(defval = 10, title = "Short Cycle Length") mcl_t = input.int(defval = 30, title = "Medium Cycle Length") scm = input.float(defval = 1.0, title = "Short Cycle Multiplier") mcm = input.float(defval = 3.0, title = "Medium Cycle Multiplier") src = input.source(defval = close, title = "Source") ebc = input.bool(defval = false, title = "Enable bar colors") // // END Inputs .... // // // START Functions .... // // // END Functions .... // // // START Calculations .... // // scl = scl_t / 2 mcl = mcl_t / 2 ma_scl = ta.rma(src, scl) ma_mcl = ta.rma(src, mcl) scm_off = scm * ta.atr(scl) mcm_off = mcm * ta.atr(mcl) // scl_2 = scl / 2 mcl_2 = mcl / 2 sct = nz(ma_scl[scl_2], src) + scm_off scb = nz(ma_scl[scl_2], src) - scm_off mct = nz(ma_mcl[mcl_2], src) + mcm_off mcb = nz(ma_mcl[mcl_2], src) - mcm_off // scmm = math.avg(sct,scb) // omed = (scmm - mcb) / (mct - mcb) oshort = (src - mcb) / (mct - mcb) // bc = (oshort > 0.5) ? (oshort > 1.0 ? color.purple : (oshort > omed ? color.lime : color.green)) : (oshort < 0 ? color.purple : ( oshort < omed ? color.red : color.orange)) // var bullishColor = color.aqua var bearishColor = color.fuchsia // showSignals = input.bool(defval = false, title = "Show Signals", group = "Signals") showBullishSignals = input.bool(defval = false, title = "Show Bullish Signals", group = "Signals") showBearishSignals = input.bool(defval = false, title = "Show Bearish Signals", group = "Signals") // // RED ... FastOSC = oshort // // Green ... SlowOSC = omed // MIDOSC = FastOSC >= SlowOSC ? (FastOSC - SlowOSC) / 2 : (SlowOSC - FastOSC) / 2 // isFastOSCCrossOverSlowOSC = ta.crossover(FastOSC, SlowOSC) isFastOSCCrossUnderSlowOSC = ta.crossunder(FastOSC, SlowOSC) // hasBullishSignal = isFastOSCCrossOverSlowOSC and MIDOSC >= 0.02 hasBearishSignal = isFastOSCCrossUnderSlowOSC and MIDOSC >= 0.02 // hasSignal = hasBullishSignal or hasBearishSignal // // END Calculations .... // // // START Plots .... // // Draw Area ... // upperLine = plot(1.0, title = "Upper Line", color = color.gray) middleLine = plot(0.5, title = "Middle Line", color = color.gray) lowerLine = plot(0.0, title = "Lower Line", color = color.gray) // fill(lowerLine, middleLine, color = color.new(color.red, 95), title = "Lower Area Fill") fill(upperLine, middleLine, color = color.new(color.green, 95), title = "Upper Area Fill") // plot(series = omed >= 1.0 ? omed : na, histbase = 1.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Medium Cycle OB") plot(series = omed <= 0.0 ? omed : na, histbase = 0.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Medium Cycle OS") // plot(series = oshort >= 1.0 ? oshort : na, histbase = 1.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Short Cycle OB") plot(series = oshort <= 0.0 ? oshort : na, histbase = 0.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Short Cycle OS") // plot(series = oshort, color = color.red, linewidth = 2, title = "Fast Osc") plot(series = omed, color = color.green, linewidth = 2, title = "Slow Osc") // plot(series = MIDOSC, title = "Mid Osc", style = plot.style_histogram, color = color.yellow, linewidth = 2) // plotshape(series = showSignals and showBullishSignals and hasBullishSignal ? FastOSC : na, title = "FastOSC CrossOver SlowOSC", location = location.bottom, style = shape.triangleup, color = bullishColor, size = size.small) plotshape(series = showSignals and showBearishSignals and hasBearishSignal ? FastOSC : na, title = "FastOSC CrossUnder SlowOSC", location = location.top, style = shape.triangledown, color = bearishColor, size = size.small) // // END Plots .... // // // START Alerts ... // alertcondition(hasSignal, "XS_CC_OSC > Signal") alertcondition(hasBullishSignal, "XS_CC_OSC > Long Signal") alertcondition(hasBearishSignal, "XS_CC_OSC > Short Signal") // // END Alerts ... // ////////////////////////////////////////////////////// // TODOS: // ------- // - [] //////////////////////////////////////////////////////