Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

UPDATE - 07/2024
  • minor code fix.
  • added MFI and BB
  • option to apply setting on all indicator.
  • option to disable any of the indicator.
  • some other style options.
CODE:
CSS:
#// Indicator for TOS
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
# Update - minor code fix, option to apply repainting to all indicators. Added MFI and BB Indicator
# Updatedby Sam4Cok@Samer800    - 07/2024
declare lower;
input signalLineDisplay = {Default "Long & Short Above", "Long & Short Below",
                          "Short Above & Long Below", "Don't Show Signal Line"};
input repaintting = {Default "Repaint All Indicators", "No Repaint To All Indicators", "Selected Repainting"};
input timeframe  = {Default "Apply Chart Timeframe To All Indicators", "Apply Master Timeframe To All Indicators", "Select Timeframe For Each Indicator"};
input masterTimeframe = AggregationPeriod.FIFTEEN_MIN;
input ShowLabel = no;
input colorbars = yes;  # "Color bars?"
input ColorTriggerCandle = yes;
input enableBollingerBand = yes;
input enableLoxxer        = yes;
input enableMacd          = yes;
input enableRsi           = yes;
input enableVelocity      = yes;
input enableCci           = yes;
input enableStochastic    = yes;
input enableMfi           = yes;
input BollingerBandManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'BB Resolution'
input BollingerBandRepainting = yes;  # 'BollingerBand Allow Repainting?'
input bbAvgType = AverageType.SIMPLE;   # 'BollingerBand Avg Type'
input bbSource = FundamentalType.CLOSE;
input BollingerBandLength = 20;
input BollingerBandMulti  = 1.5;    # 'StdDev'
input LoxxerManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'
input loxxPeriod = 14;     # 'Loxxer Period'
input macdManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'
input macdAvgType = AverageType.EXPONENTIAL;
input macdSource = FundamentalType.CLOSE;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input rsiManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'
input rsiSource = FundamentalType.CLOSE;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input VelocityManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'
input VelocitySource = FundamentalType.CLOSE;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input cciManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'
input cciSource = FundamentalType.CLOSE;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input stochManualTimeframe = AggregationPeriod.FIVE_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'
input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input mfiManualTimeframe = AggregationPeriod.FIVE_MIN;    # ' MFI  Resolution'
input mfiRepainting = yes;      # ' mfi Allow Repainting?'
input mfiLength     = 14;         # " mfi  Length"

def na = Double.NaN;
def last = isNaN(close);
def current = GetAggregationPeriod();

def loxRep; def macdRep; def rsiRep; def velRep; def cciRep; def stochRep; def mfiRep; def bbRep;
Switch (repaintting) {
Case "No Repaint To All Indicators" :
    loxRep   = no;
    macdRep  = no;
    rsiRep   = no;
    velRep   = no;
    cciRep   = no;
    stochRep = no;
    mfiRep   = no;
    bbRep   = no;
Case "Selected Repainting" :
    loxRep  = loxxRepainting;
    macdRep = macdRepainting;
    rsiRep  = rsiRepainting;
    velRep  = velRepainting;
    cciRep  = cciRepainting;
    stochRep = stochRepainting;
    mfiRep  = mfiRepainting;
    bbRep  = BollingerBandRepainting;
Default :
    loxRep   = yes;
    macdRep  = yes;
    rsiRep   = yes;
    velRep   = yes;
    cciRep   = yes;
    stochRep = yes;
    mfiRep   = yes;
    bbRep   = yes;
}
def loxxAgg;
def macdAgg;
def rsiAgg;
def velAgg;
def cciAgg;
def stochAgg;
def mfiAgg;
def bbAgg;
Switch (timeframe) {
Case "Apply Master Timeframe To All Indicators" :
    loxxAgg  = Max(current, masterTimeframe);
    macdAgg  = Max(current, masterTimeframe);
    rsiAgg   = Max(current, masterTimeframe);
    velAgg   = Max(current, masterTimeframe);
    cciAgg   = Max(current, masterTimeframe);
    stochAgg = Max(current, masterTimeframe);
    mfiAgg   = Max(current, masterTimeframe);
    bbAgg   = Max(current, masterTimeframe);
Case "Select Timeframe For Each Indicator" :
    loxxAgg  = Max(Current, LoxxerManualTimeframe);
    macdAgg  = Max(Current, macdManualTimeframe);
    rsiAgg   = Max(Current, rsiManualTimeframe);
    velAgg   = Max(Current, VelocityManualTimeframe);
    cciAgg   = Max(Current, cciManualTimeframe);
    stochAgg = Max(Current, stochManualTimeframe);
    mfiAgg   = Max(current, mfiManualTimeframe);
    bbAgg   = Max(current, BollingerBandManualTimeframe);
Default :
    loxxAgg  = Current;
    macdAgg  = Current;
    rsiAgg   = Current;
    velAgg   = Current;
    cciAgg   = Current;
    stochAgg = Current;
    mfiAgg   = Current;
    bbAgg   = Current;
}
########### Color ###############
DefineGlobalColor("green"  , CreateColor(45,210,4));
DefineGlobalColor("red"    , CreateColor(210,4,45));
DefineGlobalColor("dgreen" , CreateColor(27,126,2));
DefineGlobalColor("dred"   , CreateColor(147,2,31));

Script pulldat {
input src = FundamentalType.CLOSE;
input res = 60000;
input rep = yes;
    def isrealtime = !isNaN(src);
    def Current = GetAggregationPeriod();
    def chartTimeframe = Current == res;
    def chartSrc = Fundamental(FundamentalType = src);
    def chartSrc1 = Fundamental(FundamentalType = src)[1];
    def htfSrc = Fundamental(FundamentalType = src, Period = res);
    def htfSrc1 = Fundamental(FundamentalType = src, Period = res)[1];
    def repSrc = if rep then chartSrc else if isrealtime then chartSrc1 else chartSrc;
    def repHTF = if rep then htfSrc else if isrealtime then htfSrc1 else htfSrc;
    def getSrc = if chartTimeframe then repSrc else repHTF;
    def result = if isrealtime then getSrc else result[1];;
    plot out = if isNaN(result) then 0 else result;
}
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def hh = Highest(h, len);
    def ll = Lowest(l, len);
    def stoch = 100 * (src - ll) / (hh - ll);
    plot return = if isNaN(stoch) then 0 else stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma = fold k = 0 to length with p do
           p  + if(!isNaN(src[k]),src[k],0)  * Power(length - k, powSlow);
    def sumb = fold k1 = 0 to length with p1 do
           p1 + if(!isNaN(src[k1]),src[k1],0) * Power(length - k1, powFast);
    def sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    def sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    def imom = (sumb / sumwb - suma / sumwa);
    plot out = if isNaN(imom) then 0 else imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input highin = high;
    input lowin = low;
    def changeHi = highin - highin[1];
    def changeLo = lowin - lowin[1];
    def demax =  max(changeHi, 0);
    def demin = -min(changeLo, 0);
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = if isNaN(loxxer) then 0 else loxxer;
}
#mfi(src, length) =>
script mfi {
input src = hlc3;
input length = 14;
input v = volume;
    def diff = src - src[1];
    def upper = sum(v * (if diff <= 0 then 0 else src), length);
    def lower = sum(v * (if diff >= 0 then 0 else src), length);
    def mfi = 100 - (100 / (1 + upper / lower));
    def mfiVal = if isNaN(mfi) then mfiVal[1] else mfi;
  plot return = mfiVal;
}
#-- Sources
def bbsrc = pulldat(bbSource, bbAgg, bbRep);
def macdsrc = pulldat(macdSource, macdAgg, macdRep);
def rsisrc =  pulldat(rsiSource, rsiAgg, rsiRep);
def velsrc =  pulldat(VelocitySource, velAgg, velRep);
def ccisrc =  pulldat(cciSource, cciAgg, cciRep);
def stochhi = pulldat(FundamentalType.HIGH,  stochAgg, stochRep); 
def stochlo = pulldat(FundamentalType.LOW,   stochAgg, stochRep);
def stochcl = pulldat(FundamentalType.CLOSE, stochAgg, stochRep);
def loxxhi  = pulldat(FundamentalType.HIGH,  loxxAgg,  loxRep); 
def loxxlo  = pulldat(FundamentalType.LOW,   loxxAgg,  loxRep);
def volSrc = pulldat(FundamentalType.VOLUME, mfiAgg, mfiRep);
def ClSrc = pulldat(FundamentalType.HLC3, mfiAgg, mfiRep);
#-- bb;
def BBbasis = MovingAverage(bbAvgType, bbsrc, BollingerBandLength);
def bbDev = BollingerBandMulti * StDev(bbsrc, BollingerBandLength);
def bbUp = BBbasis + bbDev;
def bbLo = BBbasis - bbDev;
def bbValue = if bbsrc > bbUp then 1 else if bbsrc < bbLo then 0 else bbValue[1];
#--MACD
def emaFast = MovingAverage(macdAvgType, macdsrc, macdFastPeriod);
def emaSlow = MovingAverage(macdAvgType, macdsrc, macdSlowPeriod);
def macdValue = emaFast - emaSlow;
#--CCI
def avgCCI = Average(ccisrc, cciPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - avgCCI) / linDev / 0.015;
#-- Loxxer
def dmark1 = _dm(loxxPeriod, loxxhi, loxxlo);
#--RSI
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
#-- Stoch
def StochK = stoch(stochcl, stochhi, stochlo, periodK);
def stoch1 = Average(StochK, smoothK);
#-- Velocity
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);
#-- MFI
def mfi1 = mfi(ClSrc, mfiLength, volSrc);
#-- Values
def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macdValue)  then macdValue  else macd[1];
def rsi   = if !isNaN(rsi1)   then rsi1   else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(nCCI)   then nCCI   else cci[1];
def vel   = if !isNaN(vel1)   then vel1   else vel[1];
def mfi   = if !isNaN(mfi1)   then mfi1   else mfi[1];
def bb   = if !isNaN(bbValue)   then bbValue   else bb[1];
#-- Trend
def dmarkCol = if enableLoxxer   then if dmark > 50 then 1 else -1 else 0;
def macdCol  = if enableMacd     then if macd  > 0  then 1 else -1 else 0;
def rsiCol   = if enableRsi      then if rsi   > 50 then 1 else -1 else 0;
def stochCol = if enableStochastic then if stoch > 50 then 1 else -1 else 0;
def cciCol   = if enableCci      then if cci   > 0  then 1 else -1 else 0;
def velCol   = if enableVelocity then if vel   > 0  then 1 else -1 else 0;
def mfiCol   = if enableMfi      then if mfi   > 50 then 1 else -1 else 0;
def bbCol   = if enableBollingerBand then if bb > 0 then 1 else -1 else 0;
#-- Long/Short
def loc = enableLoxxer + enableMacd + enableRsi + enableStochastic +
          enableCci + enableVelocity + enableMfi + enableBollingerBand;
def goLong_pre = dmarkCol>=0 and macdCol>=0 and rsiCol>=0 and stochCol>=0 and
                 cciCol>=0 and velCol>=0 and mfiCol>=0 and bbCol>=0;
def goShort_pre = dmarkCol<=0 and macdCol<=0 and rsiCol<=0 and stochCol<=0 and
                  cciCol<=0 and velCol<=0 and mfiCol<=0 and bbCol<=0;
def direction = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def dirSwitch = direction!=direction[1];
def goLong  = goLong_pre and dirSwitch;
def goShort = goShort_pre and dirSwitch;
#-- Strength
def Strength = dmarkCol + macdCol + rsiCol + stochCol + cciCol + velCol + mfiCol + bbCol;
def ExtUp = Strength == loc;
def Up    = Strength >  Ceil(loc/2);
def ExtDn = Strength == -loc;
def Dn    = Strength <  floor(-loc/2);
#--Locations
def loxLoc = if enableLoxxer then 1 else 0;
def macLoc = if enableMacd then loxLoc + 1 else loxLoc;
def rsiLoc = if enableRsi then macLoc + 1 else macLoc;
def stoLoc = if enableStochastic then rsiLoc + 1 else rsiLoc;
def cciLoc = if enableCci then stoLoc + 1 else stoLoc;
def velLoc = if enableVelocity then cciLoc + 1 else cciLoc;
def mfiLoc = if enableMfi then velLoc + 1 else velLoc;
def bbLoc = if enableBollingerBand then mfiLoc + 1 else mfiLoc;
#-- Plots
plot dmarkLine = if enableLoxxer and !last     then 1 else na;
plot macdLine  = if enableMacd and !last       then macLoc else na;
plot rsiLine   = if enableRsi and !last        then rsiLoc else na;
plot stochLine = if enableStochastic and !last then stoLoc else na;
plot cciLine   = if enableCci and !last        then cciLoc else na;
plot velLine   = if enableVelocity and !last   then velLoc else na;
plot mfiLine   = if enableMfi and !last        then mfiLoc else na;
plot bbLine   = if enableBollingerBand and !last then bbLoc else na;
dmarkLine.HideBubble();
macdLine.HideBubble();
rsiLine.HideBubble();
stochLine.HideBubble();
cciLine.HideBubble();
velLine.HideBubble();
mfiLine.HideBubble();
bbLine.HideBubble();
dmarkLine.AssignValueColor(if dmarkCol>0 then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol>0 then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol>0 then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol>0 then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol>0 then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol>0 then GlobalColor("green") else GlobalColor("red"));
mfiLine.AssignValueColor(if mfiCol>0 then GlobalColor("green") else GlobalColor("red"));
bbLine.AssignValueColor(if bbCol>0 then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
macdLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
rsiLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
stochLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
cciLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
velLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
mfiLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
bbLine.SetPaintingStrategy(PaintingStrategy.SQUARES);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);
mfiLine.SetLineWeight(2);
bbLine.SetLineWeight(2);
#-- Signals
#input signalLineDisplay = {Default "Long & Short Above", "Long & Short Below",
#                          "Short Above & Long Below", "Don't Show Signal Line"};
def locLong; def locShort;
Switch (signalLineDisplay) {
Case "Long & Short Below" :
    locLong = 0;
    locShort = 0;
Case "Short Above & Long Below" :
    locLong = 0;
    locShort = loc + 1;
Case "Don't Show Signal Line" :
    locLong = na;
    locShort = na;
Default :
    locLong = loc + 1;
    locShort = loc + 1;
}
plot long = if last then na else if direction>0 then locLong else na;
plot short = if last then na else if direction<0 then locShort else na;
long.HideBubble();
short.HideBubble();
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);
#-- Bar Color
def trigger = if goLong then yes else if goShort then no else trigger[1];
AssignPriceColor(if !colorbars and !ColorTriggerCandle then Color.CURRENT else
                 if ExtUp then Color.GREEN else
                 if    Up then Color.DARK_GREEN else
                 if ExtDn then Color.RED else
                 if    Dn then Color.DARK_RED else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if trigger and !trigger[1] then Color.CYAN else
                 if !trigger and trigger[1] then Color.MAGENTA else Color.CURRENT);
#-- bubbles
def labCond = ShowLabel and last[1];
AddChartBubble(labCond, dmarkLine[2],"Loxxer"   , if dmarkCol[2]>0 then Color.GREEN else Color.RED);
AddChartBubble(labCond, macdLine[2] , "MACD "   , if macdCol[2]>0  then Color.GREEN else Color.RED);
AddChartBubble(labCond, rsiLine[2]  , "RSI"     , if rsiCol[2]>0   then Color.GREEN else Color.RED);
AddChartBubble(labCond, stochLine[2], "Stoch"   , if stochCol[2]>0 then Color.GREEN else Color.RED);
AddChartBubble(labCond, cciLine[2]  , "CCI"     , if cciCol[2]>0   then Color.GREEN else Color.RED);
AddChartBubble(labCond, velLine[2]  , "Velocity", if velCol[2]>0   then Color.GREEN else Color.RED);
AddChartBubble(labCond, mfiLine[2]  , "MFI"     ,  if mfiCol[2]>0  then Color.GREEN else Color.RED);
AddChartBubble(labCond, bbLine[2]   , "BB"      ,  if bbCol[2]>0   then Color.GREEN else Color.RED);

#---- END of Code

CODE: - 03/2023
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
 
Last edited:
Everything You Want To Know About Super 6x And Were Afraid To Ask.
When oscillators cross their midpoint, they are seen as trending.
This indicator displays oscillators above their midpoint (green) or below (red).

Trend is one of the single most important indicators in trading.
Preferably, you want to add this to your chart three times.
Here is why: https://usethinkscript.com/threads/...ay-trading-for-thinkorswim.12209/#post-104699

rU3528a.png

*collinear = https://usethinkscript.com/threads/...nt-to-successful-trading-in-thinkorswim.6114/

The display seen with this indicator is called a dashboard.
Traditionally, dashboards are used as traffic lights. The more green a dashboard is, then the more bullish.

The lines on the chart are identified as follows:
1st line Loxxer
2nd line MACD
3rd line RSI
4th line Stochasitc
5th line CCI
6th line Velocity

The purple triangles indicate that all 6 indicators are currently red.
The blue triangles indicate that all 6 are in the green.
Conversely, the painted bars.....purple indicates the first candle in which all 6 ind. have gone red (for a short opportunity)
and the blue candle indicates the first candle in which all 6 have gone green (for a long opportunity).
Grey colored candles indicate that one or more of the indicators are not in agreement with the others (in other words, somewhat neutral price action).
Red candles = strong downtrend, Green = strong uptrend

The Original Study can be found: https://usethinkscript.com/threads/...ocity-loxx-for-thinkorswim.14670/#post-120946
An interesting variation of this indicator: https://usethinkscript.com/threads/...ocity-loxx-for-thinkorswim.14670/#post-121572

Install instructions: https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
study link: http://tos.mx/ldOfefP Click here for --> Easiest way to load shared links
Start out with extended hours off.

Scans & Watchlists: No. This indicator is too complex for use anywhere other than plotting a chart.
The workaround is to scan for each oscillator separately

This indicator does not work on Tick or Renko charts
No, there is no workaround.

Note: requests to add even more to this indicator are unlikely to be met. This indicator is complex bordering on freezing up your app. Adding more code could put it over the edge.


What Indicators Pair Best With The Super 6x Indicator
All trending strategies work best when combined with:
  • Cycle Indicator
  • Support & Resistance (can be hand-drawn or a study)
  • Volume
 
Last edited:
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
Will this work on TICK charts? looks interesting!

thx!
 
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
Thanks so much for all your work, @samer800! Just wondering, can this also be used with Renko/range bars?
 
Looks Impressive! Any Info on how to use or apply. I've seen something similiar on Tradestation but was year or two ago. Looking forward to some intel. thanks!
 
Thanks, curious what the purple triangles are and the blue/cyan triangles at 0 and 7?
The purple triangles indicate that all 6 indicators are currently red. The blue triangles indicate that all 6 are in the green. Conversely, the painted bars.....purple indicates the first candle in which all 6 ind. have gone red (for a short opportunity) and the blue candle indicates the first candle in which all 6 have gone green (for a long opportunity). Grey colored candles indicate that one or more of the indicators are not in agreement with the others (in other words, somewhat neutral price action). Red candles = strong downtrent, Green = strong uptrend
 
Is there a way to display the triangles ( Blue and Magent as a priceline across the chart ?
It is unlikely that such a thing will become available. This script is too complex to start with. Additional modifications move you into the danger of so complex, that it freezes up and won't update in real time.
 
Last edited:
Anyway to get the triangles to be scannable? I tried, and it says the study is too complex.
 
Last edited:
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
Is there a way to use Super6x as a scan? Thanks.
 
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
Thanks Samer, This is quite a great tool. I used it for the first time today and it helped me to stay in a couple of trades that I may have hopped out of.
 
zYs5ll2.png

Author Message:
Super 6x: RSI , MACD , Stoch , Loxxer, CCI , & Velocity is a combination of 6 indicators into one histogram. This includes the option to allow repainting and not to repaint.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#https://www.tradingview.com/v/U30edqhu/
#// © loxx
#indicator("Super 6x: RSI, MACD, Stoch, Loxxer, CCI, & Velocity [Loxx]", shorttitle="S6XRMSDCV [Loxx]",
# Converted by Sam4Cok@Samer800 - 03/2023
declare lower;

input ColorTriggerCandle = yes;
input colorbars = yes;  # "Color bars?"
input loxxPeriod = 14;     # 'Loxxer Period'
input loxxChartTimeframe = yes;
input loxxAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Loxxer Resolution'
input loxxRepainting = yes;    # 'Loxxer Allow Repainting?'

input macdSource = close;   # 'MACD Source'
input macdFastPeriod = 12;  # 'MACD Fast Period'
input macdSlowPeriod = 26;  # 'MACD Slow Period'
input macdChartTimeframe = yes;
input macdAgg = AggregationPeriod.FIFTEEN_MIN;    # 'MACD Resolution'
input macdRepainting = yes;  # 'MACD Allow Repainting?'

input rsiSource = close;     # 'RSI Source'
input rsiPeriod = 14;        # 'RSI Period'
input rsiChartTimeframe = yes;
input rsiAgg = AggregationPeriod.FIFTEEN_MIN;    # 'RSI Resolution'
input rsiRepainting = yes;   # 'RSI Allow Repainting?'

input VelocitySource = close;     # 'Velocity Source'
input VelocityPeriod = 32;        # "Velocity Period"
input VelocityFastPeriod = 1;     # "Velocity Fast Period"
input VelocitySlowPeriod = 2;     # "Velocity Slow Period"
input VelChartTimeframe = yes;
input velAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Velocity Resolution'
input velRepainting = yes;         # 'Velocity Allow Repainting?'

input cciSource = close;     # "CCI Source"
input cciPeriod = 14;          # "CCI Period"
input cciChartTimeframe = yes;
input cciAgg = AggregationPeriod.FIFTEEN_MIN;    # 'CCI Resolution'
input cciRepainting = yes;         # 'CCI Allow Repainting?'

input periodK = 14;         # "Stochasitc %K Length"
input smoothK = 1;          # "Stochasitc %K Smoothing"
input periodD = 3;          # "Stochasitc %D Smoothing"
input stochChartTimeframe = yes;
input stochAgg = AggregationPeriod.FIFTEEN_MIN;    # 'Stochasitc Resolution'
input stochRepainting = yes;       # 'Stochasitc Allow Repainting?'

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def isrealtime = !IsNaN(close);
########### Theme 1################
DefineGlobalColor("green" , Color.GREEN);
DefineGlobalColor("red"   , Color.RED);
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def stoch = 100 * (src - Lowest(l, len)) / (Highest(h, len) - Lowest(l, len));
    plot return = stoch;
}
#_imom(src, length, powSlow, powFast)=>
script _imom {
    input src = close;
    input length = 32;
    input powSlow = 1;
    input powFast = 2;
    def suma;
    def sumwa;
    def imom;
    def sumb;
    def sumwb;
    suma = fold k = 0 to length with p do
           p  + src[k]  * Power(length - k, powSlow);
    sumb = fold k1 = 0 to length with p1 do
           p1 + src[k1] * Power(length - k1, powFast);
    sumwa = fold k2 = 0 to length with p2 do
           p2 + Power(length - k2, powSlow);
    sumwb = fold k3 = 0 to length with p3 do
           p3 + Power(length - k3, powFast);
    imom = (sumb / sumwb - suma / sumwa);
    plot out = imom;
}
#_dm(per, res, rep)=>
script _dm {
    input per = 14;
    input changeHi = 0;
    input changeLo = 0;
    def demax = if changeHi>0 then changeHi else 0;
    def demin = if changeLo<0 then AbsValue(changeLo) else 0;
    def maxma = Average(demax, per);
    def minma = Average(demin, per);
    def loxxer = 100 * maxma / (maxma + minma);
    plot out = loxxer;
}
def macdsrc = if macdChartTimeframe then
    if macdRepainting then macdSource else if isrealtime then macdSource[1] else macdSource else
    if macdRepainting then close(Period = macdAgg) else if isrealtime then close(Period = macdAgg)[1] else close(Period = macdAgg);
def rsisrc = if rsiChartTimeframe then
    if rsiRepainting then rsiSource else if isrealtime then rsiSource[1] else rsiSource else
    if rsiRepainting then close(Period = rsiAgg) else if isrealtime then close(Period = rsiAgg)[1] else close(Period = rsiAgg);
def velsrc = if VelChartTimeframe then
    if velRepainting then VelocitySource else if isrealtime then VelocitySource[1] else VelocitySource else
    if velRepainting then close(Period = velAgg) else if isrealtime then close(Period = velAgg)[1] else close(Period = velAgg);
def ccisrc = if cciChartTimeframe then
    if cciRepainting then cciSource else if isrealtime then cciSource[1] else cciSource else
    if cciRepainting then close(Period = cciAgg) else if isrealtime then close(Period = cciAgg)[1] else close(Period = cciAgg);
def stochhi = if stochChartTimeframe then
    if stochRepainting then high else if isrealtime then high[1] else high else
    if stochRepainting then high(Period = stochAgg) else if isrealtime then high(Period = stochAgg)[1] else high(Period = stochAgg);
def stochlo = if stochChartTimeframe then
    if stochRepainting then low else if isrealtime then low[1] else low else
    if stochRepainting then low(Period = stochAgg) else if isrealtime then low(Period = stochAgg)[1] else low(Period = stochAgg);
def stochclose = if stochChartTimeframe then
    if stochRepainting then close else if isrealtime then close[1] else close else
    if stochRepainting then close(Period = stochAgg) else if isrealtime then close(Period = stochAgg)[1] else close(Period = stochAgg);
def highin = if loxxChartTimeframe then
    if loxxRepainting then high else if isrealtime then high[1] else high else
    if loxxRepainting then high(Period = loxxAgg) else if isrealtime then high(Period = loxxAgg)[1] else high(Period = loxxAgg);
def lowin = if loxxChartTimeframe then
    if loxxRepainting then low else if isrealtime then low[1] else low else
    if loxxRepainting then low(Period = loxxAgg) else if isrealtime then low(Period = loxxAgg)[1] else low(Period = loxxAgg);

def macdValue = ExpAverage(macdsrc, macdFastPeriod) - ExpAverage(macdsrc, macdSlowPeriod);
def linDev = LinDev(ccisrc, cciPeriod);
def nCCI = if linDev == 0 then 0 else (ccisrc - Average(ccisrc, cciPeriod)) / linDev / 0.015;
def changeHi = highin - highin[1];
def changeLo = lowin - lowin[1];

def dmark1 = _dm(loxxPeriod, changeHi, changeLo);
def macd1  = macdValue;
def rsi1   = RSI(Price = rsisrc, Length = rsiPeriod);
def stoch1 = Average(stoch(stochclose, stochhi, stochlo, periodK), smoothK);
def cci1   = nCCI;
def vel1   = _imom(velsrc, VelocityPeriod, VelocityFastPeriod, VelocitySlowPeriod);

def dmark = if !isNaN(dmark1) then dmark1 else dmark[1];
def macd  = if !isNaN(macd1) then macd1 else macd[1];
def rsi   = if !isNaN(rsi1) then rsi1 else rsi[1];
def stoch = if !isNaN(stoch1) then stoch1 else stoch[1];
def cci   = if !isNaN(cci1) then cci1 else cci[1];
def vel   = if !isNaN(vel1) then vel1 else vel[1];

def dmarkCol = dmark > 50;
def macdCol = macd > 0;
def rsiCol = rsi > 50;
def stochCol = stoch > 50;
def cciCol = cci > 0;
def velCol = vel > 0;
plot dmarkLine = if last then na else 1;
plot macdLine = if last then na else 2;
plot rsiLine = if last then na else 3;
plot stochLine = if last then na else 4;
plot cciLine = if last then na else 5;
plot velLine = if last then na else 6;
dmarkLine.AssignValueColor(if dmarkCol then GlobalColor("green") else GlobalColor("red"));
macdLine.AssignValueColor(if macdCol then GlobalColor("green") else GlobalColor("red"));
rsiLine.AssignValueColor(if rsiCol then  GlobalColor("green") else GlobalColor("red"));
stochLine.AssignValueColor(if stochCol then GlobalColor("green") else GlobalColor("red"));
cciLine.AssignValueColor(if cciCol then  GlobalColor("green") else GlobalColor("red"));
velLine.AssignValueColor(if velCol then GlobalColor("green") else GlobalColor("red"));
dmarkLine.SetPaintingStrategy(PaintingStrategy.POINTS);
macdLine.SetPaintingStrategy(PaintingStrategy.POINTS);
rsiLine.SetPaintingStrategy(PaintingStrategy.POINTS);
stochLine.SetPaintingStrategy(PaintingStrategy.POINTS);
cciLine.SetPaintingStrategy(PaintingStrategy.POINTS);
velLine.SetPaintingStrategy(PaintingStrategy.POINTS);
dmarkLine.SetLineWeight(2);
macdLine.SetLineWeight(2);
rsiLine.SetLineWeight(2);
stochLine.SetLineWeight(2);
cciLine.SetLineWeight(2);
velLine.SetLineWeight(2);

def goLong_pre = dmark > 50 and macd > 0 and rsi > 50 and stoch > 50 and cci > 0 and vel > 0;
def goShort_pre = dmark < 50 and macd < 0 and rsi < 50 and stoch < 50 and cci < 0 and vel < 0;

def contSwitch;
    contSwitch = if goLong_pre then 1 else if goShort_pre then -1 else 0;
def goLong  = goLong_pre and (contSwitch-contSwitch[1]);
def goShort = goShort_pre and (contSwitch-contSwitch[1]);

AssignPriceColor(if !colorbars then Color.CURRENT else
                 if goLong_pre then GlobalColor("green") else if goShort_pre then GlobalColor("red") else Color.GRAY);
AssignPriceColor(if !ColorTriggerCandle then Color.CURRENT else
                 if goLong then Color.CYAN else
                 if goShort then Color.MAGENTA else Color.CURRENT);

plot long = if last then na else if contSwitch>0 then 0 else na;
plot short = if last then na else if contSwitch<0 then 7 else na;
long.SetDefaultColor(Color.CYAN);
short.SetDefaultColor(Color.MAGENTA);
long.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
Short.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
long.SetLineWeight(3);
short.SetLineWeight(3);


#---- END of Code
Looks to me as this indicator misses about half of the potential gains available both on the way up and on the way down. Also looks like Velocity(Loxx), the top red line, is the worst offender, but most of the others don't look very good either.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
253 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top