Creator Message:
Function
Represented by a white line, this Super Oscillator indicator identifies instruments that are overbought or oversold, which can be an important part of determining buy and sell points. An oversold market is a market that has fallen sharply and is expected to recover. In this indicator, gray candlesticks are used at the bottom to show that an oversold zone is near and a red candlestick shows that the overbought zone is ending. On the other hand, an overbought market has risen sharply and could be ripe for a decline. Yellow line dips are used to indicate overbought zones.
CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © blackcat1402
#study("[blackcat] L2 Super Oscillator","[blackcat] L2 Super Oscillator",
# Converted and mod by Sam4Cok@Samer800 - 03/2023
declare lower;
input n = 5;#
input n1 = 9;
input m1 = 3;
input m2 = 3;
input p = 9;
#barssince(Condition) =>
script barssince {
input Condition = 0;
def barssince = if Condition then 1 else barssince[1] + 1;
plot return = barssince;
}
#xrf(values, length) =>
script xrf {
input values = close;
input length = 10;
def r_val;
r_val = if length >= 1 then
fold i = 0 to length - 1 with p do
if IsNaN(r_val[1]) or !IsNaN(values[i]) then values[i] else p else Double.NaN;
plot out = r_val;
}
#bton(b) =>
script bton {
input b = no;
def bton = if b then 1 else 0;
plot out = bton;
}
#xsa(src, len, wei) =>
script xsa {
input src = close;
input len = 5;
input wei = 1;
def sum;
def ma;
def out;
sum = CompoundValue(1, sum[1] - src[len] + src, src);
ma = if IsNaN(src[len]) then Double.NaN else sum / len;
out = CompoundValue(1, (src * wei + out[1] * (len - wei)) / len, ma);
plot return = out;
}
def na = Double.NaN;
#//source code
def xsa1 = (close - Lowest(low, 13)) / (Highest(high, 13) - Lowest(low, 13)) * 100;
def super_osc = 3 * xsa(xsa1, 5, 1) - 2 * xsa(xsa(xsa1, 5, 1), 3, 1);
def preparation_period = If(super_osc >= 90, 82, 100);
plot Super = super_osc;
plot Prep = preparation_period;
Super.SetLineWeight(2);
Super.SetDefaultColor(Color.CYAN);
Prep.SetDefaultColor(Color.RED);
def lowv = Lowest(close, 15);
def highv = Highest(close, 15);
def rsv = ExpAverage((close - lowv) / (highv - lowv) * 100, 3);
def k = ExpAverage(rsv, 3);
def sup = super_osc <= 10;
def candidate_cond = sup[1] and k > xrf(k, 1);
def os_cond = super_osc <= 10;
def xsa2 = (close - Lowest(low, n)) / (Highest(high, n) - Lowest(low, n)) * 100;
def var1 = 4 * xsa(xsa2, 5, 1) - 3 * xsa(xsa(xsa2, 5, 1), 3.2, 1);
def candCondCount = if var1> 8 then candCondCount[1] + 1 else 0;
def candidate_cond2 = candCondCount==1;
def os_cond2 = var1 <= 8;
def var2 = xrf(low, 1);
def var3 = xsa(AbsValue(low - var2), 3, 1) / xsa(Max(low - var2, 0), 3, 1) * 100;
def var4 = ExpAverage(If(close * 1.3, var3 * 10, var3 / 10), 3);
def var5 = Lowest(low, 13);
def var6 = Highest(var4, 13);
def var7 = If(Average(close, 34), 1, 0);
def var8 = ExpAverage(If(low <= var5, (var4 + var6 * 2) / 2, 0), 3) / 618 * var7;
def var9 = If(var8 > 100, 100, var8);
def osCondCount = if bton(var9 > 20) > 0.5 then osCondCount[1] + 1 else 0;
def os_cond3 = osCondCount==1;
def fast_line = (close-lowest(low,n1))/(highest(high,n1)-lowest(low,n1))*100;
def slow_line = xsa(fast_line,m1,1);
def void = xsa(slow_line, m2, 1);
def osCondCnt4 = if slow_line > void then osCondCnt4[1] + 1 else 0;
def os_cond4 = barssince(osCondCnt4==1)<p and osCondCnt4==1 and slow_line<20;
def os_zone = if(os_cond or os_cond2 or os_cond3,0,0);
def longCnt = if bton(candidate_cond) > 0.5 then longCnt[1] + 1 else 0;
def long_cond = if(longCnt==1 or candidate_cond2 or os_cond4 and super_osc<20,58,0);
def cond = os_cond or os_cond2 or os_cond3;
def cond1 = longCnt==1 or candidate_cond2 or os_cond4 and super_osc<20;
plot osZone = if cond then os_zone else na;
plot Long = If(cond1, if(longCnt==1 or candidate_cond2 or os_cond4 and super_osc<20, 18, 0), 0);
osZone.SetPaintingStrategy(PaintingStrategy.SQUARES);
osZone.SetDefaultColor(Color.YELLOW);
osZone.SetLineWeight(2);
long.SetDefaultColor(Color.GREEN);
plot mid = if isNaN(close) then na else 50;
mid.SetDefaultColor(Color.DARK_GRAY);
#AddCloud(osZone, Long, Color.YELLOW);
AddCloud(103, preparation_period, Color.DARK_RED);
AddCloud(Long, -3, Color.DARK_GREEN);
#--- END of CODE
Last edited by a moderator: