Double RSI

JP782

Active member
Need some help to fix this double RSI Im getting an error msg. This code works but doesnt show the cross(which is the whole point of making the custom study) you see if you just run 2 RSI's w/diff lengths bc I cant change the ABSValue to ABSValueA for the 2nd RSI to differentiate from the 1st one

Suggestions??

Code:
declare lower;

input length = 25;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
RSI.setlineWeight(2);
RSI.setDefaultColor(color.black);

#
input lengthA = 100;
input over_BoughtA = 70;
input over_SoldA = 30;
input priceA = close;
input averageTypeA = AverageType.WILDERS;

def NetChgAvgA = MovingAverage(averageTypeA, priceA - priceA[1], lengthA);
def TotChgAvgA = MovingAverage(averageTypeA, AbsValue(priceA - priceA[1]), lengthA);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;

plot RSI_ = 50 * (ChgRatioA + 1);
RSI_.setlineWeight(2);
RSI_.setDefaultColor(color.red);

8YsmqqF.png
k97LkhS.png
 

Attachments

  • 8YsmqqF.png
    8YsmqqF.png
    117.5 KB · Views: 954
70 views no solution!?
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
Plot Diff=RSIA/RSIB;

This should work
 

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

70 views no solution!?
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
input period3 = 36;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
plot Diff = RSIA / RSIB;
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
Plot Diff2 = RSIB/RSIC;

Diff.SetDefaultColor(Color.CYAN);
Diff2.SetDefaultColor(Color.Blue);

AddCloud(Diff,1,Color.CYAN,Color.MAGENTA);
AddCloud(Diff2,1,Color.Blue,Color.Red);

Plot UZ = Average(Diff,34) + (1.3185*StDev(Diff,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(1);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(Diff,34) - (1.3185*StDev(Diff,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(1);
LZ.SetDefaultColor(Color.Yellow);


This should work for you.

Three RSI's
 
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
Plot Diff=RSIA/RSIB;

This should work
Thanks... Im trying to learn this, so why was this line removed from factory script? def Price = (open + close) / 2;
Does the Plot Diff=RSIA/RSIB; do the same thing?
 
Dividing a faster RSI by a slower one , gives the percentage above or below the Slower RSI

so a reading of 1.02 is 2 pct above the slow RSI, a reading of .98 is 2 pct below the Slow RSI

1 is the base line

If I were to write it Plot Diff=RSIA-RSIB;

then 0 would be the base line but I wouldn't have the percentage above or below. I would have the distance
 
Ive been looking for lower study for more accurate indication, MACD is slow in many cases, trying the Normalized MACD but problem with that is it goes flat line at top of moves and you dont know if direction will continue or not until a drastic obvious move....

Saw dbl RSI used this video...
 
Ive been looking for lower study for more accurate indication, MACD is slow in many cases, trying the Normalized MACD but problem with that is it goes flat line at top of moves and you dont know if direction will continue or not until a drastic obvious move....

Saw dbl RSI used this video...
I was curious about your original request. I think what @henry1224 provided is very neat too. I am going to study that further.

This is more academic in nature but I wanted to understand this space better myself.
The main issue is that TOS auto-scales and makes you believe there was a cross-over. However, if you hover the mouse you will notice that RSI_1 and RSI_2 are already above each other around this area.

I reused existing TOS methods and wrote this simple 2 RSI script. The real cross-over seems to have happened much earlier around 7:13 AM market time.

here is all of the code in that new script. Again, this may be useless right now, but there is an explanation for it :)

Rich (BB code):
declare Lower;
input period1 = 25;
input period2 = 100;


plot RSIA = RSI(length=period1);
plot RSIB = RSI(length=period2);
 
I was curious about your original request. I think what @henry1224 provided is very neat too. I am going to study that further.

This is more academic in nature but I wanted to understand this space better myself.
The main issue is that TOS auto-scales and makes you believe there was a cross-over. However, if you hover the mouse you will notice that RSI_1 and RSI_2 are already above each other around this area.

I reused existing TOS methods and wrote this simple 2 RSI script. The real cross-over seems to have happened much earlier around 7:13 AM market time.

here is all of the code in that new script. Again, this may be useless right now, but there is an explanation for it :)

Rich (BB code):
declare Lower;
input period1 = 25;
input period2 = 100;


plot RSIA = RSI(length=period1);
plot RSIB = RSI(length=period2);
??? Isnt the RSI in this script telling TOS to use their base RSI study... isnt this just a short form of it??
 
??? Isnt the RSI in this script telling TOS to use their base RSI study... isnt this just a short form of it??
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
Input Arrows = no;
input Dotsize = 3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
plot Diff = RSIA / RSIB;
Diff.SetDefaultColor(Color.CYAN);
AddCloud(Diff,1,Color.CYAN,Color.MAGENTA);
Plot UZ = Average(Diff,34) + (1.3185*StDev(Diff,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(1);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(Diff,34) - (1.3185*StDev(Diff,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(1);
LZ.SetDefaultColor(Color.Yellow);
#ARROWS
plot ArrowDown = if arrows and (Diff Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Diff crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if arrows and (Diff Crosses below UZ) then UZ else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize);

plot ArrowUp2 = if arrows and (Diff crosses above LZ ) then LZ else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Dark_Orange);
ArrowUp2.setLineWeight(dotsize);

This is Two RSI Diff w Arrows
 
This is Two RSI Diff w Arrows
This is Three RSI Diff w Arrows
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
input period3 = 36;
input arrows= no;
input Dotsize =3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
plot Diff = RSIA / RSIB;
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
Plot Diff2 = RSIB/RSIC;

Diff.SetDefaultColor(Color.CYAN);
Diff2.SetDefaultColor(Color.Blue);

AddCloud(Diff,1,Color.CYAN,Color.MAGENTA);
AddCloud(Diff2,1,Color.Blue,Color.Red);

Plot UZ = Average(Diff,34) + (1.3185*StDev(Diff,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(1);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(Diff,34) - (1.3185*StDev(Diff,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(1);
LZ.SetDefaultColor(Color.Yellow);
#ARROWS
plot ArrowDown = if arrows and (Diff Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Diff crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDownA = if arrows and (Diff2 Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUpA = if arrows and (Diff2 crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Blue);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if arrows and (Diff Crosses below UZ) then UZ else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize);

plot ArrowUp2 = if arrows and (Diff crosses above LZ ) then LZ else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Dark_Orange);
ArrowUp2.setLineWeight(dotsize);
 
This is Three RSI Diff w Arrows
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
input period3 = 36;
input arrows= no;
input Dotsize =3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
plot Diff = RSIA / RSIB;
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
Plot Diff2 = RSIB/RSIC;

Diff.SetDefaultColor(Color.CYAN);
Diff2.SetDefaultColor(Color.Blue);

AddCloud(Diff,1,Color.CYAN,Color.MAGENTA);
AddCloud(Diff2,1,Color.Blue,Color.Red);

Plot UZ = Average(Diff,34) + (1.3185*StDev(Diff,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(1);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(Diff,34) - (1.3185*StDev(Diff,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(1);
LZ.SetDefaultColor(Color.Yellow);
#ARROWS
plot ArrowDown = if arrows and (Diff Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Diff crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDownA = if arrows and (Diff2 Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUpA = if arrows and (Diff2 crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Blue);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if arrows and (Diff Crosses below UZ) then UZ else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize);

plot ArrowUp2 = if arrows and (Diff crosses above LZ ) then LZ else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Dark_Orange);
ArrowUp2.setLineWeight(dotsize);
 
Here is the GEM

Two RSI Diff w Guppy Binary
Code:
# dividing a RSI by a slower RSI "using a ratio of 1 to 4"gives a base line of 1 any reading above 1 is bullish and colored Cyan for short term Blue for longer term. Any Reading below 1 is bearish and colored magenta for short term Red for a longer term pertains to Lines 1,4,7,10,13,16,19,22,25,28,31,34,& 37.
#Using 4 colors to determine Bullish Rising "Green", Bullish Falling "Dark_Green", Bearish Rising "Light_Red", and Bearish Falling "Dark_Red" Pertains to Lines 2,5,8,11,14,17,20,23,26,29,32,35,38
#using Standard Deviation channels on the faster RSI, A yellow dot shows when the RSI is above the Upper dev Channel. An Orange Dot shows when the RSI is below the Lower Dev Channel. Pertains to Lines 3,6,9,12,15,18,21,24,27,30,33,36,39
#Changing the APC input from 0 to which ever line you input will change the price color to reflect the selected line. Pertains to all Lines
input period1 = 3;
input period2 = 5;
input period3 = 8;
input period4 = 10;
input period5 = 12;
input period6 = 15;
input period7 = 20;
input period8 = 30;
input period9 = 32;
input period10 = 35;
input period11 = 40;
input period12 = 45;
input period13 = 48;
input period14 = 50;
input period15 = 60;
input period16 = 80;
input period17 = 120;
input period18 = 140;
input period19 = 160;
input period20 = 180;
input period21 = 200;
input period22 = 240;

input APC = 0;
Input dotsize = 3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
def NetChgAvgD = MovingAverage(averageType, Price - Price[1], period4);
def TotChgAvgD = MovingAverage(averageType, AbsValue(Price - Price[1]), period4);
def ChgRatioD = if TotChgAvgD != 0 then NetChgAvgD / TotChgAvgD else 0;
def RSID = 50 * (ChgRatioD + 1);
def NetChgAvgE = MovingAverage(averageType, Price - Price[1], period5);
def TotChgAvgE = MovingAverage(averageType, AbsValue(Price - Price[1]), period5);
def ChgRatioE = if TotChgAvgE != 0 then NetChgAvgE / TotChgAvgE else 0;
def RSIE = 50 * (ChgRatioE + 1);
def NetChgAvgF = MovingAverage(averageType, Price - Price[1], period6);
def TotChgAvgF = MovingAverage(averageType, AbsValue(Price - Price[1]), period6);
def ChgRatioF = if TotChgAvgF != 0 then NetChgAvgF / TotChgAvgF else 0;
def RSIF = 50 * (ChgRatioF + 1);
def NetChgAvgG = MovingAverage(averageType, Price - Price[1], period7);
def TotChgAvgG = MovingAverage(averageType, AbsValue(Price - Price[1]), period7);
def ChgRatioG = if TotChgAvgG != 0 then NetChgAvgG / TotChgAvgG else 0;
def RSIG = 50 * (ChgRatioG + 1);
def NetChgAvgH = MovingAverage(averageType, Price - Price[1], period8);
def TotChgAvgH = MovingAverage(averageType, AbsValue(Price - Price[1]), period8);
def ChgRatioH = if TotChgAvgH != 0 then NetChgAvgH / TotChgAvgH else 0;
def RSIH = 50 * (ChgRatioH + 1);
def NetChgAvgI = MovingAverage(averageType, Price - Price[1], period9);
def TotChgAvgI = MovingAverage(averageType, AbsValue(Price - Price[1]), period9);
def ChgRatioI = if TotChgAvgI != 0 then NetChgAvgI / TotChgAvgI else 0;
def RSII = 50 * (ChgRatioI + 1);
def NetChgAvgJ = MovingAverage(averageType, Price - Price[1], period10);
def TotChgAvgJ = MovingAverage(averageType, AbsValue(Price - Price[1]), period10);
def ChgRatioJ = if TotChgAvgJ != 0 then NetChgAvgJ / TotChgAvgJ else 0;
def RSIJ = 50 * (ChgRatioJ + 1);
def NetChgAvgK = MovingAverage(averageType, Price - Price[1], period11);
def TotChgAvgK = MovingAverage(averageType, AbsValue(Price - Price[1]), period11);
def ChgRatioK = if TotChgAvgK != 0 then NetChgAvgK / TotChgAvgK else 0;
def RSIK = 50 * (ChgRatioK + 1);
def NetChgAvgL = MovingAverage(averageType, Price - Price[1], period12);
def TotChgAvgL = MovingAverage(averageType, AbsValue(Price - Price[1]), period12);
def ChgRatioL = if TotChgAvgL != 0 then NetChgAvgL / TotChgAvgL else 0;
def RSIL = 50 * (ChgRatioL + 1);
def NetChgAvgM = MovingAverage(averageType, Price - Price[1], period13);
def TotChgAvgM = MovingAverage(averageType, AbsValue(Price - Price[1]), period13);
def ChgRatioM = if TotChgAvgM != 0 then NetChgAvgM / TotChgAvgM else 0;
def RSIM = 50 * (ChgRatioM + 1);
def NetChgAvgN = MovingAverage(averageType, Price - Price[1], period14);
def TotChgAvgN = MovingAverage(averageType, AbsValue(Price - Price[1]), period14);
def ChgRatioN = if TotChgAvgN != 0 then NetChgAvgN / TotChgAvgN else 0;
def RSIN = 50 * (ChgRatioN + 1);
def NetChgAvgO = MovingAverage(averageType, Price - Price[1], period15);
def TotChgAvgO = MovingAverage(averageType, AbsValue(Price - Price[1]), period15);
def ChgRatioO = if TotChgAvgO != 0 then NetChgAvgO / TotChgAvgO else 0;
def RSIO = 50 * (ChgRatioO + 1);
def NetChgAvgP = MovingAverage(averageType, Price - Price[1], period16);
def TotChgAvgP = MovingAverage(averageType, AbsValue(Price - Price[1]), period16);
def ChgRatioP = if TotChgAvgP != 0 then NetChgAvgP / TotChgAvgP else 0;
def RSIP = 50 * (ChgRatioP + 1);
def NetChgAvgQ = MovingAverage(averageType, Price - Price[1], period17);
def TotChgAvgQ = MovingAverage(averageType, AbsValue(Price - Price[1]), period17);
def ChgRatioQ = if TotChgAvgQ != 0 then NetChgAvgQ / TotChgAvgQ else 0;
def RSIQ = 50 * (ChgRatioQ + 1);
def NetChgAvgR = MovingAverage(averageType, Price - Price[1], period18);
def TotChgAvgR = MovingAverage(averageType, AbsValue(Price - Price[1]), period18);
def ChgRatioR = if TotChgAvgR != 0 then NetChgAvgR / TotChgAvgR else 0;
def RSIR = 50 * (ChgRatioR + 1);
def NetChgAvgS = MovingAverage(averageType, Price - Price[1], period19);
def TotChgAvgS = MovingAverage(averageType, AbsValue(Price - Price[1]), period19);
def ChgRatioS = if TotChgAvgS != 0 then NetChgAvgS / TotChgAvgS else 0;
def RSIS = 50 * (ChgRatioS + 1);
def NetChgAvgT = MovingAverage(averageType, Price - Price[1], period20);
def TotChgAvgT = MovingAverage(averageType, AbsValue(Price - Price[1]), period20);
def ChgRatioT = if TotChgAvgT != 0 then NetChgAvgT / TotChgAvgT else 0;
def RSIT = 50 * (ChgRatioT + 1);
def NetChgAvgU = MovingAverage(averageType, Price - Price[1], period21);
def TotChgAvgU = MovingAverage(averageType, AbsValue(Price - Price[1]), period21);
def ChgRatioU = if TotChgAvgU != 0 then NetChgAvgU / TotChgAvgU else 0;
def RSIU = 50 * (ChgRatioU + 1);
def NetChgAvgV = MovingAverage(averageType, Price - Price[1], period22);
def TotChgAvgV = MovingAverage(averageType, AbsValue(Price - Price[1]), period22);
def ChgRatioV = if TotChgAvgV != 0 then NetChgAvgV / TotChgAvgV else 0;
def RSIV = 50 * (ChgRatioV + 1);


def Diff1 = RSIA/RSIE;
def Diff2 = RSIB/RSIG;
def Diff3 = RSIC/RSII;
def Diff4 = RSID/RSIK;
def Diff5 = RSIE/RSIM;
def Diff6 = RSIF/RSIO;
def Diff7 = RSIG/RSIP;
def Diff8 = RSIH/RSIS;
def Diff9 = RSIJ/RSIR;
def Diff10 = RSIK/RSIS;
def Diff11 = RSIL/RSIT;
def Diff12 = RSIN/RSIU;
def Diff13 = RSIO/RSIV;


def UZA = Average(Diff1,34) + (1.3185*StDev(Diff1,34));
def LZA = Average(Diff1,34) - (1.3185*StDev(Diff1,34));
def UZB = Average(Diff2,34) + (1.3185*StDev(Diff2,34));
def LZB = Average(Diff2,34) - (1.3185*StDev(Diff2,34));
def UZC = Average(Diff3,34) + (1.3185*StDev(Diff3,34));
def LZC = Average(Diff3,34) - (1.3185*StDev(Diff3,34));
def UZD = Average(Diff4,34) + (1.3185*StDev(Diff4,34));
def LZD = Average(Diff4,34) - (1.3185*StDev(Diff4,34));
def UZE = Average(Diff5,34) + (1.3185*StDev(Diff5,34));
def LZE = Average(Diff5,34) - (1.3185*StDev(Diff5,34));
def UZF = Average(Diff6,34) + (1.3185*StDev(Diff6,34));
def LZF = Average(Diff6,34) - (1.3185*StDev(Diff6,34));
def UZG = Average(Diff7,34) + (1.3185*StDev(Diff7,34));
def LZG = Average(Diff7,34) - (1.3185*StDev(Diff7,34));
def UZH = Average(Diff8,34) + (1.3185*StDev(Diff8,34));
def LZH = Average(Diff8,34) - (1.3185*StDev(Diff8,34));
def UZI = Average(Diff9,34) + (1.3185*StDev(Diff9,34));
def LZI = Average(Diff9,34) - (1.3185*StDev(Diff9,34));
def UZJ = Average(Diff10,34) + (1.3185*StDev(Diff10,34));
def LZJ = Average(Diff10,34) - (1.3185*StDev(Diff10,34));
def UZK = Average(Diff11,34) + (1.3185*StDev(Diff11,34));
def LZK = Average(Diff11,34) - (1.3185*StDev(Diff11,34));
def UZL = Average(Diff12,34) + (1.3185*StDev(Diff12,34));
def LZL = Average(Diff12,34) - (1.3185*StDev(Diff12,34));
def UZM = Average(Diff13,34) + (1.3185*StDev(Diff13,34));
def LZM = Average(Diff13,34) - (1.3185*StDev(Diff13,34));

Def Con1A = Diff1 >= 1;
Def Con2A = Diff1 < 1;
Def Con3A = Diff1 >= Diff1[1];
Def Con4A = Diff1 < Diff1[1];
Def Con1B = Diff2 >= 1;
Def Con2B = Diff2 < 1;
Def Con3B = Diff2 >= Diff2[1];
Def Con4B = Diff2 < Diff2[1];
Def Con1C = Diff3 >= 1;
Def Con2C = Diff3 < 1;
Def Con3C = Diff3 >= Diff3[1];
Def Con4C = Diff3 < Diff3[1];
Def Con1D = Diff4 >= 1;
Def Con2D = Diff4 < 1;
Def Con3D = Diff4 >= Diff4[1];
Def Con4D = Diff4 < Diff4[1];
Def Con1E = Diff5 >= 1;
Def Con2E = Diff5 < 1;
Def Con3E = Diff5 >= Diff5[1];
Def Con4E = Diff5 < Diff5[1];
Def Con1F = Diff6 >= 1;
Def Con2F = Diff6 < 1;
Def Con3F = Diff6 >= Diff6[1];
Def Con4F = Diff6 < Diff6[1];
Def Con1G = Diff7 >= 1;
Def Con2G = Diff7 < 1;
Def Con3G = Diff7 >= Diff7[1];
Def Con4G = Diff7 < Diff7[1];
Def Con1H = Diff8 >= 1;
Def Con2H = Diff8 < 1;
Def Con3H = Diff8 >= Diff8[1];
Def Con4H = Diff8 < Diff8[1];
Def Con1I = Diff9 >= 1;
Def Con2I = Diff9 < 1;
Def Con3I = Diff9 >= Diff9[1];
Def Con4I = Diff9 < Diff9[1];
Def Con1J = Diff10 >= 1;
Def Con2J = Diff10 < 1;
Def Con3J = Diff10 >= Diff10[1];
Def Con4J = Diff10 < Diff10[1];
Def Con1K = Diff11 >= 1;
Def Con2K = Diff11 < 1;
Def Con3K = Diff11 >= Diff11[1];
Def Con4K = Diff11 < Diff11[1];
Def Con1L = Diff12 >= 1;
Def Con2L = Diff12 < 1;
Def Con3L = Diff12 >= Diff12[1];
Def Con4L = Diff12 < Diff12[1];
Def Con1M = Diff13 >= 1;
Def Con2M = Diff13 < 1;
Def Con3M = Diff13 >= Diff13[1];
Def Con4M = Diff13 < Diff13[1];


plot A1_Dot = if IsNaN(close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A1_Dot.SetLineWeight(Dotsize);
A1_Dot.AssignValueColor(if Diff1>=1 then Color.CYAN else Color.Magenta);

plot A2_Dot = if IsNaN(close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A2_Dot.SetLineWeight(Dotsize);
A2_Dot.AssignValueColor(if Con1A and Con3A then Color.Green else if Con1A and Con4A then Color.Dark_Green else if Con2A and Con3A then Color.Light_Red else if Con2A and Con4A then Color.Dark_Red else Color.Black);

plot A3_Dot = if IsNaN(close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A3_Dot.SetLineWeight(Dotsize+1);
A3_Dot.AssignValueColor(if Diff1>=UZA then Color.YELLOW else IF Diff1 < LZA then Color.Dark_Orange else Color.Black);

plot A4_Dot = if IsNaN(close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A4_Dot.SetLineWeight(Dotsize);
A4_Dot.AssignValueColor(if Diff2>=1 then Color.CYAN else Color.Magenta);

plot A5_Dot = if IsNaN(close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A5_Dot.SetLineWeight(Dotsize);
A5_Dot.AssignValueColor(if Con1B and Con3B then Color.Green else if Con1B and Con4B then Color.Dark_Green else if Con2B and Con3B then Color.Light_Red else if Con2B and Con4B then Color.Dark_Red else Color.Black);

plot A6_Dot = if IsNaN(close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A6_Dot.SetLineWeight(Dotsize+1);
A6_Dot.AssignValueColor(if Diff2>=UZB then Color.YELLOW else IF Diff2 < LZB then Color.Dark_Orange else Color.Black);

plot A7_Dot = if IsNaN(close) then Double.NaN else 7;
A7_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A7_Dot.SetLineWeight(Dotsize);
A7_Dot.AssignValueColor(if Diff3>=1 then Color.CYAN else Color.Magenta);

plot A8_Dot = if IsNaN(close) then Double.NaN else 8;
A8_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A8_Dot.SetLineWeight(Dotsize);
A8_Dot.AssignValueColor(if Con1C and Con3C then Color.Green else if Con1C and Con4C then Color.Dark_Green else if Con2C and Con3C then Color.Light_Red else if Con2C and Con4C then Color.Dark_Red else Color.Black);

plot A9_Dot = if IsNaN(close) then Double.NaN else 9;
A9_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A9_Dot.SetLineWeight(Dotsize+1);
A9_Dot.AssignValueColor(if Diff3>=UZC then Color.YELLOW else IF Diff3 < LZC then Color.Dark_Orange else Color.Black);

plot A10_Dot = if IsNaN(close) then Double.NaN else 10;
A10_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A10_Dot.SetLineWeight(Dotsize);
A10_Dot.AssignValueColor(if Diff4>=1 then Color.CYAN else Color.Magenta);

plot A11_Dot = if IsNaN(close) then Double.NaN else 11;
A11_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A11_Dot.SetLineWeight(Dotsize);
A11_Dot.AssignValueColor(if Con1D and Con3D then Color.Green else if Con1D and Con4D then Color.Dark_Green else if Con2D and Con3D then Color.Light_Red else if Con2D and Con4D then Color.Dark_Red else Color.Black);

plot A12_Dot = if IsNaN(close) then Double.NaN else 12;
A12_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A12_Dot.SetLineWeight(Dotsize+1);
A12_Dot.AssignValueColor(if Diff4>=UZD then Color.YELLOW else IF Diff4 < LZD then Color.Dark_Orange else Color.Black);

plot A13_Dot = if IsNaN(close) then Double.NaN else 13;
A13_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A13_Dot.SetLineWeight(Dotsize);
A13_Dot.AssignValueColor(if Diff5>=1 then Color.CYAN else Color.Magenta);

plot A14_Dot = if IsNaN(close) then Double.NaN else 14;
A14_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A14_Dot.SetLineWeight(Dotsize);
A14_Dot.AssignValueColor(if Con1E and Con3E then Color.Green else if Con1E and Con4E then Color.Dark_Green else if Con2E and Con3E then Color.Light_Red else if Con2E and Con4E then Color.Dark_Red else Color.Black);

plot A15_Dot = if IsNaN(close) then Double.NaN else 15;
A15_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A15_Dot.SetLineWeight(Dotsize+1);
A15_Dot.AssignValueColor(if Diff5>=UZE then Color.YELLOW else IF Diff5 < LZE then Color.Dark_Orange else Color.Black);

plot A16_Dot = if IsNaN(close) then Double.NaN else 16;
A16_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A16_Dot.SetLineWeight(Dotsize);
A16_Dot.AssignValueColor(if Diff6>=1 then Color.CYAN else Color.Magenta);

plot A17_Dot = if IsNaN(close) then Double.NaN else 17;
A17_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A17_Dot.SetLineWeight(Dotsize);
A17_Dot.AssignValueColor(if Con1F and Con3F then Color.Green else if Con1F and Con4F then Color.Dark_Green else if Con2F and Con3F then Color.Light_Red else if Con2F and Con4F then Color.Dark_Red else Color.Black);

plot A18_Dot = if IsNaN(close) then Double.NaN else 18;
A18_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A18_Dot.SetLineWeight(Dotsize+1);
A18_Dot.AssignValueColor(if Diff6>=UZF then Color.YELLOW else IF Diff6 < LZF then Color.Dark_Orange else Color.Black);

plot A19_Dot = if IsNaN(close) then Double.NaN else 19;
A19_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A19_Dot.SetLineWeight(Dotsize);
A19_Dot.AssignValueColor(if Diff7>=1 then Color.BLUE else Color.RED);

plot A20_Dot = if IsNaN(close) then Double.NaN else 20;
A20_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A20_Dot.SetLineWeight(Dotsize);
A20_Dot.AssignValueColor(if Con1G and Con3G then Color.Green else if Con1G and Con4G then Color.Dark_Green else if Con2G and Con3G then Color.Light_Red else if Con2G and Con4G then Color.Dark_Red else Color.Black);

plot A21_Dot = if IsNaN(close) then Double.NaN else 21;
A21_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A21_Dot.SetLineWeight(Dotsize+1);
A21_Dot.AssignValueColor(if Diff7>=UZG then Color.YELLOW else IF Diff7 < LZG then Color.Dark_Orange else Color.Black);

plot A22_Dot = if IsNaN(close) then Double.NaN else 22;
A22_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A22_Dot.SetLineWeight(Dotsize);
A22_Dot.AssignValueColor(if Diff8>=1 then Color.BLUE else Color.RED);

plot A23_Dot = if IsNaN(close) then Double.NaN else 23;
A23_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A23_Dot.SetLineWeight(Dotsize);
A23_Dot.AssignValueColor(if Con1H and Con3H then Color.Green else if Con1H and Con4H then Color.Dark_Green else if Con2H and Con3H then Color.Light_Red else if Con2H and Con4H then Color.Dark_Red else Color.Black);

plot A24_Dot = if IsNaN(close) then Double.NaN else 24;
A24_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A24_Dot.SetLineWeight(Dotsize+1);
A24_Dot.AssignValueColor(if Diff8>=UZH then Color.YELLOW else IF Diff8 < LZH then Color.Dark_Orange else Color.Black);

plot A25_Dot = if IsNaN(close) then Double.NaN else 25;
A25_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A25_Dot.SetLineWeight(Dotsize);
A25_Dot.AssignValueColor(if Diff9>=1 then Color.BLUE else Color.RED);

plot A26_Dot = if IsNaN(close) then Double.NaN else 26;
A26_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A26_Dot.SetLineWeight(Dotsize);
A26_Dot.AssignValueColor(if Con1I and Con3I then Color.Green else if Con1I and Con4I then Color.Dark_Green else if Con2I and Con3I then Color.Light_Red else if Con2I and Con4I then Color.Dark_Red else Color.Black);

plot A27_Dot = if IsNaN(close) then Double.NaN else 27;
A27_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A27_Dot.SetLineWeight(Dotsize+1);
A27_Dot.AssignValueColor(if Diff9>=UZI then Color.YELLOW else IF Diff9 < LZI then Color.Dark_Orange else Color.Black);

plot A28_Dot = if IsNaN(close) then Double.NaN else 28;
A28_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A28_Dot.SetLineWeight(Dotsize);
A28_Dot.AssignValueColor(if Diff10>=1 then Color.BLUE else Color.RED);

plot A29_Dot = if IsNaN(close) then Double.NaN else 29;
A29_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A29_Dot.SetLineWeight(Dotsize);
A29_Dot.AssignValueColor(if Con1J and Con3J then Color.Green else if Con1J and Con4J then Color.Dark_Green else if Con2J and Con3J then Color.Light_Red else if Con2J and Con4J then Color.Dark_Red else Color.Black);

plot A30_Dot = if IsNaN(close) then Double.NaN else 30;
A30_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A30_Dot.SetLineWeight(Dotsize+1);
A30_Dot.AssignValueColor(if Diff10>=UZJ then Color.YELLOW else IF Diff10 < LZJ then Color.Dark_Orange else Color.Black);

plot A31_Dot = if IsNaN(close) then Double.NaN else 31;
A31_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A31_Dot.SetLineWeight(Dotsize);
A31_Dot.AssignValueColor(if Diff11>=1 then Color.BLUE else Color.RED);

plot A32_Dot = if IsNaN(close) then Double.NaN else 32;
A32_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A32_Dot.SetLineWeight(Dotsize);
A32_Dot.AssignValueColor(if Con1K and Con3K then Color.Green else if Con1K and Con4K then Color.Dark_Green else if Con2K and Con3K then Color.Light_Red else if Con2K and Con4K then Color.Dark_Red else Color.Black);

plot A33_Dot = if IsNaN(close) then Double.NaN else 33;
A33_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A33_Dot.SetLineWeight(Dotsize+1);
A33_Dot.AssignValueColor(if Diff11>=UZK then Color.YELLOW else IF Diff11 < LZK then Color.Dark_Orange else Color.Black);

plot A34_Dot = if IsNaN(close) then Double.NaN else 34;
A34_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A34_Dot.SetLineWeight(Dotsize);
A34_Dot.AssignValueColor(if Diff12>=1 then Color.BLUE else Color.RED);

plot A35_Dot = if IsNaN(close) then Double.NaN else 35;
A35_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A35_Dot.SetLineWeight(Dotsize);
A35_Dot.AssignValueColor(if Con1L and Con3L then Color.Green else if Con1L and Con4L then Color.Dark_Green else if Con2L and Con3L then Color.Light_Red else if Con2L and Con4L then Color.Dark_Red else Color.Black);

plot A36_Dot = if IsNaN(close) then Double.NaN else 36;
A36_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A36_Dot.SetLineWeight(Dotsize+1);
A36_Dot.AssignValueColor(if Diff12>=UZL then Color.YELLOW else IF Diff12 < LZL then Color.Dark_Orange else Color.Black);

plot A37_Dot = if IsNaN(close) then Double.NaN else 37;
A37_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A37_Dot.SetLineWeight(Dotsize);
A37_Dot.AssignValueColor(if Diff13>=1 then Color.BLUE else Color.RED);

plot A38_Dot = if IsNaN(close) then Double.NaN else 38;
A38_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A38_Dot.SetLineWeight(Dotsize);
A38_Dot.AssignValueColor(if Con1M and Con3M then Color.Green else if Con1M and Con4M then Color.Dark_Green else if Con2M and Con3M then Color.Light_Red else if Con2M and Con4M then Color.Dark_Red else Color.Black);

plot A39_Dot = if IsNaN(close) then Double.NaN else 39;
A39_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A39_Dot.SetLineWeight(Dotsize+1);
A39_Dot.AssignValueColor(if Diff13>=UZM then Color.YELLOW else IF Diff13 < LZM then Color.Dark_Orange else Color.Black);


AssignPriceColor(if APC== 1 and Diff1 >= 1 then Color.Cyan else if APC== 1 and Diff1 < 1 then Color.Magenta else if APC== 2 and Con1A and Con3A then Color.Green else if APC ==2 and Con1A and Con4A then Color.Dark_Green else if APC ==2 and Con2A and Con3A then Color.Light_Red else if APC == 2 and Con2A and Con4A then Color.Dark_Red else if APC ==3 and Diff1>=UZA then Color.YELLOW else if APC ==3 and Diff1 < LZA then Color.Dark_Orange else if APC ==3 then Color.Dark_Gray else
 if APC== 4 and Diff2 >= 1 then Color.Cyan else if APC== 4 and Diff2 < 1 then Color.Magenta else if APC== 5 and Con1B and Con3B then Color.Green else if APC ==5 and Con1B and Con4B then Color.Dark_Green else if APC ==5 and Con2B and Con3B then Color.Light_Red else if APC == 5 and Con2B and Con4B then Color.Dark_Red else if APC ==6 and Diff2>=UZB then Color.YELLOW else if APC ==6 and Diff2 < LZB then Color.Dark_Orange else if APC ==6 then Color.Dark_Gray else
 if APC== 7 and Diff3 >= 1 then Color.Cyan else if APC== 7 and Diff3 < 1 then Color.Magenta else if APC== 8 and Con1C and Con3C then Color.Green else if APC ==8 and Con1C and Con4C then Color.Dark_Green else if APC ==8 and Con2C and Con3C then Color.Light_Red else if APC == 8 and Con2C and Con4C then Color.Dark_Red else if APC ==9 and Diff3>=UZC then Color.YELLOW else if APC ==9 and Diff3 < LZC then Color.Dark_Orange else if APC ==9 then Color.Dark_Gray else
if APC== 10 and Diff4 >= 1 then Color.Cyan else if APC== 10 and Diff4 < 1 then Color.Magenta else if APC== 11 and Con1D and Con3D then Color.Green else if APC ==11 and Con1D and Con4D then Color.Dark_Green else if APC ==11 and Con2D and Con3D then Color.Light_Red else if APC == 11 and Con2D and Con4D then Color.Dark_Red else if APC ==12 and Diff4>=UZD then Color.YELLOW else if APC ==12 and Diff4 < LZD then Color.Dark_Orange else if APC ==12 then Color.Dark_Gray else
if  APC== 13 and Diff5 >= 1 then Color.Cyan else if APC== 13 and Diff5 < 1 then Color.Magenta else if APC== 14 and Con1E and Con3E then Color.Green else if APC ==14 and Con1E and Con4E then Color.Dark_Green else if APC ==14 and Con2E and Con3E then Color.Light_Red else if APC == 14 and Con2E and Con4E then Color.Dark_Red else if APC ==15 and Diff5>=UZE then Color.YELLOW else if APC ==15 and Diff5 < LZE then Color.Dark_Orange else if APC ==15 then Color.Dark_Gray else
if APC== 16 and Diff6 >= 1 then Color.Cyan else if APC== 16 and Diff6 < 1 then Color.Magenta else if APC== 17 and Con1F and Con3F then Color.Green else if APC ==17 and Con1F and Con4F then Color.Dark_Green else if APC ==17 and Con2F and Con3F then Color.Light_Red else if APC == 17 and Con2F and Con4F then Color.Dark_Red else if APC ==18 and Diff6>=UZF then Color.YELLOW else if APC ==18 and Diff6 < LZF then Color.Dark_Orange else if APC ==18 then Color.Dark_Gray else
if APC== 19 and Diff7 >= 1 then Color.BLUE else if APC== 19 and Diff7 < 1 then Color.RED else if APC== 20 and Con1G and Con3G then Color.Green else if APC ==20 and Con1G and Con4G then Color.Dark_Green else if APC ==20 and Con2G and Con3G then Color.Light_Red else if APC == 20 and Con2G and Con4G then Color.Dark_Red else if APC ==21 and Diff7>=UZG then Color.YELLOW else if APC ==21 and Diff7 < LZG then Color.Dark_Orange else if APC ==21 then Color.Dark_Gray else
if APC== 22 and Diff8 >= 1 then Color.BLUE else if APC== 22 and Diff8 < 1 then Color.RED else if APC== 23 and Con1H and Con3H then Color.Green else if APC ==23 and Con1H and Con4H then Color.Dark_Green else if APC ==23 and Con2H and Con3H then Color.Light_Red else if APC == 23 and Con2H and Con4H then Color.Dark_Red else if APC ==24 and Diff8>=UZH then Color.YELLOW else if APC ==24 and Diff8 < LZH then Color.Dark_Orange else if APC ==24 then Color.Dark_Gray else
if APC== 25 and Diff9 >= 1 then Color.BLUE else if APC== 25 and Diff9 < 1 then Color.RED else if APC== 26 and Con1I and Con3I then Color.Green else if APC ==26 and Con1I and Con4I then Color.Dark_Green else if APC ==26 and Con2I and Con3I then Color.Light_Red else if APC == 26 and Con2I and Con4I then Color.Dark_Red else if APC ==27 and Diff9>=UZI then Color.YELLOW else if APC ==27 and Diff9 < LZI then Color.Dark_Orange else if APC ==27 then Color.Dark_Gray else
if APC== 28 and Diff10 >= 1 then Color.BLUE else if APC== 28 and Diff10 < 1 then Color.RED else if APC== 29 and Con1J and Con3J then Color.Green else if APC ==29 and Con1J and Con4J then Color.Dark_Green else if APC ==29 and Con2J and Con3J then Color.Light_Red else if APC == 29 and Con2J and Con4J then Color.Dark_Red else if APC ==30 and Diff10>=UZJ then Color.YELLOW else if APC ==30 and Diff10 < LZJ then Color.Dark_Orange else if APC ==30 then Color.Dark_Gray else
if APC== 31 and Diff11 >= 1 then Color.BLUE else if APC== 31 and Diff11 < 1 then Color.RED else if APC== 32 and Con1K and Con3K then Color.Green else if APC ==32 and Con1K and Con4K then Color.Dark_Green else if APC ==32 and Con2K and Con3K then Color.Light_Red else if APC == 32 and Con2K and Con4K then Color.Dark_Red else if APC ==33 and Diff11>=UZK then Color.YELLOW else if APC ==33 and Diff11 < LZK then Color.Dark_Orange else if APC ==33 then Color.Dark_Gray else
if APC== 34 and Diff12 >= 1 then Color.BLUE else if APC== 34 and Diff12 < 1 then Color.RED else if APC== 35 and Con1L and Con3L then Color.Green else if APC ==35 and Con1L and Con4L then Color.Dark_Green else if APC ==35 and Con2L and Con3L then Color.Light_Red else if APC == 35 and Con2L and Con4L then Color.Dark_Red else if APC ==36 and Diff12>=UZL then Color.YELLOW else if APC ==36 and Diff12 < LZL then Color.Dark_Orange else if APC ==36 then Color.Dark_Gray else
if APC== 37 and Diff13 >= 1 then Color.BLUE else if APC== 37 and Diff13 < 1 then Color.RED else if APC== 38 and Con1M and Con3M then Color.Green else if APC ==38 and Con1M and Con4M then Color.Dark_Green else if APC ==38 and Con2M and Con3M then Color.Light_Red else if APC == 38 and Con2M and Con4M then Color.Dark_Red else if APC ==39 and Diff13>=UZM then Color.YELLOW else if APC ==39 and Diff13 < LZM then Color.Dark_Orange else if APC ==39 then Color.Dark_Gray else Color.Current);
 
Here is the GEM

Two RSI Diff w Guppy Binary
Code:
# dividing a RSI by a slower RSI "using a ratio of 1 to 4"gives a base line of 1 any reading above 1 is bullish and colored Cyan for short term Blue for longer term. Any Reading below 1 is bearish and colored magenta for short term Red for a longer term pertains to Lines 1,4,7,10,13,16,19,22,25,28,31,34,& 37.
#Using 4 colors to determine Bullish Rising "Green", Bullish Falling "Dark_Green", Bearish Rising "Light_Red", and Bearish Falling "Dark_Red" Pertains to Lines 2,5,8,11,14,17,20,23,26,29,32,35,38
#using Standard Deviation channels on the faster RSI, A yellow dot shows when the RSI is above the Upper dev Channel. An Orange Dot shows when the RSI is below the Lower Dev Channel. Pertains to Lines 3,6,9,12,15,18,21,24,27,30,33,36,39
#Changing the APC input from 0 to which ever line you input will change the price color to reflect the selected line. Pertains to all Lines
input period1 = 3;
input period2 = 5;
input period3 = 8;
input period4 = 10;
input period5 = 12;
input period6 = 15;
input period7 = 20;
input period8 = 30;
input period9 = 32;
input period10 = 35;
input period11 = 40;
input period12 = 45;
input period13 = 48;
input period14 = 50;
input period15 = 60;
input period16 = 80;
input period17 = 120;
input period18 = 140;
input period19 = 160;
input period20 = 180;
input period21 = 200;
input period22 = 240;

input APC = 0;
Input dotsize = 3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
def NetChgAvgD = MovingAverage(averageType, Price - Price[1], period4);
def TotChgAvgD = MovingAverage(averageType, AbsValue(Price - Price[1]), period4);
def ChgRatioD = if TotChgAvgD != 0 then NetChgAvgD / TotChgAvgD else 0;
def RSID = 50 * (ChgRatioD + 1);
def NetChgAvgE = MovingAverage(averageType, Price - Price[1], period5);
def TotChgAvgE = MovingAverage(averageType, AbsValue(Price - Price[1]), period5);
def ChgRatioE = if TotChgAvgE != 0 then NetChgAvgE / TotChgAvgE else 0;
def RSIE = 50 * (ChgRatioE + 1);
def NetChgAvgF = MovingAverage(averageType, Price - Price[1], period6);
def TotChgAvgF = MovingAverage(averageType, AbsValue(Price - Price[1]), period6);
def ChgRatioF = if TotChgAvgF != 0 then NetChgAvgF / TotChgAvgF else 0;
def RSIF = 50 * (ChgRatioF + 1);
def NetChgAvgG = MovingAverage(averageType, Price - Price[1], period7);
def TotChgAvgG = MovingAverage(averageType, AbsValue(Price - Price[1]), period7);
def ChgRatioG = if TotChgAvgG != 0 then NetChgAvgG / TotChgAvgG else 0;
def RSIG = 50 * (ChgRatioG + 1);
def NetChgAvgH = MovingAverage(averageType, Price - Price[1], period8);
def TotChgAvgH = MovingAverage(averageType, AbsValue(Price - Price[1]), period8);
def ChgRatioH = if TotChgAvgH != 0 then NetChgAvgH / TotChgAvgH else 0;
def RSIH = 50 * (ChgRatioH + 1);
def NetChgAvgI = MovingAverage(averageType, Price - Price[1], period9);
def TotChgAvgI = MovingAverage(averageType, AbsValue(Price - Price[1]), period9);
def ChgRatioI = if TotChgAvgI != 0 then NetChgAvgI / TotChgAvgI else 0;
def RSII = 50 * (ChgRatioI + 1);
def NetChgAvgJ = MovingAverage(averageType, Price - Price[1], period10);
def TotChgAvgJ = MovingAverage(averageType, AbsValue(Price - Price[1]), period10);
def ChgRatioJ = if TotChgAvgJ != 0 then NetChgAvgJ / TotChgAvgJ else 0;
def RSIJ = 50 * (ChgRatioJ + 1);
def NetChgAvgK = MovingAverage(averageType, Price - Price[1], period11);
def TotChgAvgK = MovingAverage(averageType, AbsValue(Price - Price[1]), period11);
def ChgRatioK = if TotChgAvgK != 0 then NetChgAvgK / TotChgAvgK else 0;
def RSIK = 50 * (ChgRatioK + 1);
def NetChgAvgL = MovingAverage(averageType, Price - Price[1], period12);
def TotChgAvgL = MovingAverage(averageType, AbsValue(Price - Price[1]), period12);
def ChgRatioL = if TotChgAvgL != 0 then NetChgAvgL / TotChgAvgL else 0;
def RSIL = 50 * (ChgRatioL + 1);
def NetChgAvgM = MovingAverage(averageType, Price - Price[1], period13);
def TotChgAvgM = MovingAverage(averageType, AbsValue(Price - Price[1]), period13);
def ChgRatioM = if TotChgAvgM != 0 then NetChgAvgM / TotChgAvgM else 0;
def RSIM = 50 * (ChgRatioM + 1);
def NetChgAvgN = MovingAverage(averageType, Price - Price[1], period14);
def TotChgAvgN = MovingAverage(averageType, AbsValue(Price - Price[1]), period14);
def ChgRatioN = if TotChgAvgN != 0 then NetChgAvgN / TotChgAvgN else 0;
def RSIN = 50 * (ChgRatioN + 1);
def NetChgAvgO = MovingAverage(averageType, Price - Price[1], period15);
def TotChgAvgO = MovingAverage(averageType, AbsValue(Price - Price[1]), period15);
def ChgRatioO = if TotChgAvgO != 0 then NetChgAvgO / TotChgAvgO else 0;
def RSIO = 50 * (ChgRatioO + 1);
def NetChgAvgP = MovingAverage(averageType, Price - Price[1], period16);
def TotChgAvgP = MovingAverage(averageType, AbsValue(Price - Price[1]), period16);
def ChgRatioP = if TotChgAvgP != 0 then NetChgAvgP / TotChgAvgP else 0;
def RSIP = 50 * (ChgRatioP + 1);
def NetChgAvgQ = MovingAverage(averageType, Price - Price[1], period17);
def TotChgAvgQ = MovingAverage(averageType, AbsValue(Price - Price[1]), period17);
def ChgRatioQ = if TotChgAvgQ != 0 then NetChgAvgQ / TotChgAvgQ else 0;
def RSIQ = 50 * (ChgRatioQ + 1);
def NetChgAvgR = MovingAverage(averageType, Price - Price[1], period18);
def TotChgAvgR = MovingAverage(averageType, AbsValue(Price - Price[1]), period18);
def ChgRatioR = if TotChgAvgR != 0 then NetChgAvgR / TotChgAvgR else 0;
def RSIR = 50 * (ChgRatioR + 1);
def NetChgAvgS = MovingAverage(averageType, Price - Price[1], period19);
def TotChgAvgS = MovingAverage(averageType, AbsValue(Price - Price[1]), period19);
def ChgRatioS = if TotChgAvgS != 0 then NetChgAvgS / TotChgAvgS else 0;
def RSIS = 50 * (ChgRatioS + 1);
def NetChgAvgT = MovingAverage(averageType, Price - Price[1], period20);
def TotChgAvgT = MovingAverage(averageType, AbsValue(Price - Price[1]), period20);
def ChgRatioT = if TotChgAvgT != 0 then NetChgAvgT / TotChgAvgT else 0;
def RSIT = 50 * (ChgRatioT + 1);
def NetChgAvgU = MovingAverage(averageType, Price - Price[1], period21);
def TotChgAvgU = MovingAverage(averageType, AbsValue(Price - Price[1]), period21);
def ChgRatioU = if TotChgAvgU != 0 then NetChgAvgU / TotChgAvgU else 0;
def RSIU = 50 * (ChgRatioU + 1);
def NetChgAvgV = MovingAverage(averageType, Price - Price[1], period22);
def TotChgAvgV = MovingAverage(averageType, AbsValue(Price - Price[1]), period22);
def ChgRatioV = if TotChgAvgV != 0 then NetChgAvgV / TotChgAvgV else 0;
def RSIV = 50 * (ChgRatioV + 1);


def Diff1 = RSIA/RSIE;
def Diff2 = RSIB/RSIG;
def Diff3 = RSIC/RSII;
def Diff4 = RSID/RSIK;
def Diff5 = RSIE/RSIM;
def Diff6 = RSIF/RSIO;
def Diff7 = RSIG/RSIP;
def Diff8 = RSIH/RSIS;
def Diff9 = RSIJ/RSIR;
def Diff10 = RSIK/RSIS;
def Diff11 = RSIL/RSIT;
def Diff12 = RSIN/RSIU;
def Diff13 = RSIO/RSIV;


def UZA = Average(Diff1,34) + (1.3185*StDev(Diff1,34));
def LZA = Average(Diff1,34) - (1.3185*StDev(Diff1,34));
def UZB = Average(Diff2,34) + (1.3185*StDev(Diff2,34));
def LZB = Average(Diff2,34) - (1.3185*StDev(Diff2,34));
def UZC = Average(Diff3,34) + (1.3185*StDev(Diff3,34));
def LZC = Average(Diff3,34) - (1.3185*StDev(Diff3,34));
def UZD = Average(Diff4,34) + (1.3185*StDev(Diff4,34));
def LZD = Average(Diff4,34) - (1.3185*StDev(Diff4,34));
def UZE = Average(Diff5,34) + (1.3185*StDev(Diff5,34));
def LZE = Average(Diff5,34) - (1.3185*StDev(Diff5,34));
def UZF = Average(Diff6,34) + (1.3185*StDev(Diff6,34));
def LZF = Average(Diff6,34) - (1.3185*StDev(Diff6,34));
def UZG = Average(Diff7,34) + (1.3185*StDev(Diff7,34));
def LZG = Average(Diff7,34) - (1.3185*StDev(Diff7,34));
def UZH = Average(Diff8,34) + (1.3185*StDev(Diff8,34));
def LZH = Average(Diff8,34) - (1.3185*StDev(Diff8,34));
def UZI = Average(Diff9,34) + (1.3185*StDev(Diff9,34));
def LZI = Average(Diff9,34) - (1.3185*StDev(Diff9,34));
def UZJ = Average(Diff10,34) + (1.3185*StDev(Diff10,34));
def LZJ = Average(Diff10,34) - (1.3185*StDev(Diff10,34));
def UZK = Average(Diff11,34) + (1.3185*StDev(Diff11,34));
def LZK = Average(Diff11,34) - (1.3185*StDev(Diff11,34));
def UZL = Average(Diff12,34) + (1.3185*StDev(Diff12,34));
def LZL = Average(Diff12,34) - (1.3185*StDev(Diff12,34));
def UZM = Average(Diff13,34) + (1.3185*StDev(Diff13,34));
def LZM = Average(Diff13,34) - (1.3185*StDev(Diff13,34));

Def Con1A = Diff1 >= 1;
Def Con2A = Diff1 < 1;
Def Con3A = Diff1 >= Diff1[1];
Def Con4A = Diff1 < Diff1[1];
Def Con1B = Diff2 >= 1;
Def Con2B = Diff2 < 1;
Def Con3B = Diff2 >= Diff2[1];
Def Con4B = Diff2 < Diff2[1];
Def Con1C = Diff3 >= 1;
Def Con2C = Diff3 < 1;
Def Con3C = Diff3 >= Diff3[1];
Def Con4C = Diff3 < Diff3[1];
Def Con1D = Diff4 >= 1;
Def Con2D = Diff4 < 1;
Def Con3D = Diff4 >= Diff4[1];
Def Con4D = Diff4 < Diff4[1];
Def Con1E = Diff5 >= 1;
Def Con2E = Diff5 < 1;
Def Con3E = Diff5 >= Diff5[1];
Def Con4E = Diff5 < Diff5[1];
Def Con1F = Diff6 >= 1;
Def Con2F = Diff6 < 1;
Def Con3F = Diff6 >= Diff6[1];
Def Con4F = Diff6 < Diff6[1];
Def Con1G = Diff7 >= 1;
Def Con2G = Diff7 < 1;
Def Con3G = Diff7 >= Diff7[1];
Def Con4G = Diff7 < Diff7[1];
Def Con1H = Diff8 >= 1;
Def Con2H = Diff8 < 1;
Def Con3H = Diff8 >= Diff8[1];
Def Con4H = Diff8 < Diff8[1];
Def Con1I = Diff9 >= 1;
Def Con2I = Diff9 < 1;
Def Con3I = Diff9 >= Diff9[1];
Def Con4I = Diff9 < Diff9[1];
Def Con1J = Diff10 >= 1;
Def Con2J = Diff10 < 1;
Def Con3J = Diff10 >= Diff10[1];
Def Con4J = Diff10 < Diff10[1];
Def Con1K = Diff11 >= 1;
Def Con2K = Diff11 < 1;
Def Con3K = Diff11 >= Diff11[1];
Def Con4K = Diff11 < Diff11[1];
Def Con1L = Diff12 >= 1;
Def Con2L = Diff12 < 1;
Def Con3L = Diff12 >= Diff12[1];
Def Con4L = Diff12 < Diff12[1];
Def Con1M = Diff13 >= 1;
Def Con2M = Diff13 < 1;
Def Con3M = Diff13 >= Diff13[1];
Def Con4M = Diff13 < Diff13[1];


plot A1_Dot = if IsNaN(close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A1_Dot.SetLineWeight(Dotsize);
A1_Dot.AssignValueColor(if Diff1>=1 then Color.CYAN else Color.Magenta);

plot A2_Dot = if IsNaN(close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A2_Dot.SetLineWeight(Dotsize);
A2_Dot.AssignValueColor(if Con1A and Con3A then Color.Green else if Con1A and Con4A then Color.Dark_Green else if Con2A and Con3A then Color.Light_Red else if Con2A and Con4A then Color.Dark_Red else Color.Black);

plot A3_Dot = if IsNaN(close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A3_Dot.SetLineWeight(Dotsize+1);
A3_Dot.AssignValueColor(if Diff1>=UZA then Color.YELLOW else IF Diff1 < LZA then Color.Dark_Orange else Color.Black);

plot A4_Dot = if IsNaN(close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A4_Dot.SetLineWeight(Dotsize);
A4_Dot.AssignValueColor(if Diff2>=1 then Color.CYAN else Color.Magenta);

plot A5_Dot = if IsNaN(close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A5_Dot.SetLineWeight(Dotsize);
A5_Dot.AssignValueColor(if Con1B and Con3B then Color.Green else if Con1B and Con4B then Color.Dark_Green else if Con2B and Con3B then Color.Light_Red else if Con2B and Con4B then Color.Dark_Red else Color.Black);

plot A6_Dot = if IsNaN(close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A6_Dot.SetLineWeight(Dotsize+1);
A6_Dot.AssignValueColor(if Diff2>=UZB then Color.YELLOW else IF Diff2 < LZB then Color.Dark_Orange else Color.Black);

plot A7_Dot = if IsNaN(close) then Double.NaN else 7;
A7_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A7_Dot.SetLineWeight(Dotsize);
A7_Dot.AssignValueColor(if Diff3>=1 then Color.CYAN else Color.Magenta);

plot A8_Dot = if IsNaN(close) then Double.NaN else 8;
A8_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A8_Dot.SetLineWeight(Dotsize);
A8_Dot.AssignValueColor(if Con1C and Con3C then Color.Green else if Con1C and Con4C then Color.Dark_Green else if Con2C and Con3C then Color.Light_Red else if Con2C and Con4C then Color.Dark_Red else Color.Black);

plot A9_Dot = if IsNaN(close) then Double.NaN else 9;
A9_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A9_Dot.SetLineWeight(Dotsize+1);
A9_Dot.AssignValueColor(if Diff3>=UZC then Color.YELLOW else IF Diff3 < LZC then Color.Dark_Orange else Color.Black);

plot A10_Dot = if IsNaN(close) then Double.NaN else 10;
A10_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A10_Dot.SetLineWeight(Dotsize);
A10_Dot.AssignValueColor(if Diff4>=1 then Color.CYAN else Color.Magenta);

plot A11_Dot = if IsNaN(close) then Double.NaN else 11;
A11_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A11_Dot.SetLineWeight(Dotsize);
A11_Dot.AssignValueColor(if Con1D and Con3D then Color.Green else if Con1D and Con4D then Color.Dark_Green else if Con2D and Con3D then Color.Light_Red else if Con2D and Con4D then Color.Dark_Red else Color.Black);

plot A12_Dot = if IsNaN(close) then Double.NaN else 12;
A12_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A12_Dot.SetLineWeight(Dotsize+1);
A12_Dot.AssignValueColor(if Diff4>=UZD then Color.YELLOW else IF Diff4 < LZD then Color.Dark_Orange else Color.Black);

plot A13_Dot = if IsNaN(close) then Double.NaN else 13;
A13_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A13_Dot.SetLineWeight(Dotsize);
A13_Dot.AssignValueColor(if Diff5>=1 then Color.CYAN else Color.Magenta);

plot A14_Dot = if IsNaN(close) then Double.NaN else 14;
A14_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A14_Dot.SetLineWeight(Dotsize);
A14_Dot.AssignValueColor(if Con1E and Con3E then Color.Green else if Con1E and Con4E then Color.Dark_Green else if Con2E and Con3E then Color.Light_Red else if Con2E and Con4E then Color.Dark_Red else Color.Black);

plot A15_Dot = if IsNaN(close) then Double.NaN else 15;
A15_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A15_Dot.SetLineWeight(Dotsize+1);
A15_Dot.AssignValueColor(if Diff5>=UZE then Color.YELLOW else IF Diff5 < LZE then Color.Dark_Orange else Color.Black);

plot A16_Dot = if IsNaN(close) then Double.NaN else 16;
A16_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A16_Dot.SetLineWeight(Dotsize);
A16_Dot.AssignValueColor(if Diff6>=1 then Color.CYAN else Color.Magenta);

plot A17_Dot = if IsNaN(close) then Double.NaN else 17;
A17_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A17_Dot.SetLineWeight(Dotsize);
A17_Dot.AssignValueColor(if Con1F and Con3F then Color.Green else if Con1F and Con4F then Color.Dark_Green else if Con2F and Con3F then Color.Light_Red else if Con2F and Con4F then Color.Dark_Red else Color.Black);

plot A18_Dot = if IsNaN(close) then Double.NaN else 18;
A18_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A18_Dot.SetLineWeight(Dotsize+1);
A18_Dot.AssignValueColor(if Diff6>=UZF then Color.YELLOW else IF Diff6 < LZF then Color.Dark_Orange else Color.Black);

plot A19_Dot = if IsNaN(close) then Double.NaN else 19;
A19_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A19_Dot.SetLineWeight(Dotsize);
A19_Dot.AssignValueColor(if Diff7>=1 then Color.BLUE else Color.RED);

plot A20_Dot = if IsNaN(close) then Double.NaN else 20;
A20_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A20_Dot.SetLineWeight(Dotsize);
A20_Dot.AssignValueColor(if Con1G and Con3G then Color.Green else if Con1G and Con4G then Color.Dark_Green else if Con2G and Con3G then Color.Light_Red else if Con2G and Con4G then Color.Dark_Red else Color.Black);

plot A21_Dot = if IsNaN(close) then Double.NaN else 21;
A21_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A21_Dot.SetLineWeight(Dotsize+1);
A21_Dot.AssignValueColor(if Diff7>=UZG then Color.YELLOW else IF Diff7 < LZG then Color.Dark_Orange else Color.Black);

plot A22_Dot = if IsNaN(close) then Double.NaN else 22;
A22_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A22_Dot.SetLineWeight(Dotsize);
A22_Dot.AssignValueColor(if Diff8>=1 then Color.BLUE else Color.RED);

plot A23_Dot = if IsNaN(close) then Double.NaN else 23;
A23_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A23_Dot.SetLineWeight(Dotsize);
A23_Dot.AssignValueColor(if Con1H and Con3H then Color.Green else if Con1H and Con4H then Color.Dark_Green else if Con2H and Con3H then Color.Light_Red else if Con2H and Con4H then Color.Dark_Red else Color.Black);

plot A24_Dot = if IsNaN(close) then Double.NaN else 24;
A24_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A24_Dot.SetLineWeight(Dotsize+1);
A24_Dot.AssignValueColor(if Diff8>=UZH then Color.YELLOW else IF Diff8 < LZH then Color.Dark_Orange else Color.Black);

plot A25_Dot = if IsNaN(close) then Double.NaN else 25;
A25_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A25_Dot.SetLineWeight(Dotsize);
A25_Dot.AssignValueColor(if Diff9>=1 then Color.BLUE else Color.RED);

plot A26_Dot = if IsNaN(close) then Double.NaN else 26;
A26_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A26_Dot.SetLineWeight(Dotsize);
A26_Dot.AssignValueColor(if Con1I and Con3I then Color.Green else if Con1I and Con4I then Color.Dark_Green else if Con2I and Con3I then Color.Light_Red else if Con2I and Con4I then Color.Dark_Red else Color.Black);

plot A27_Dot = if IsNaN(close) then Double.NaN else 27;
A27_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A27_Dot.SetLineWeight(Dotsize+1);
A27_Dot.AssignValueColor(if Diff9>=UZI then Color.YELLOW else IF Diff9 < LZI then Color.Dark_Orange else Color.Black);

plot A28_Dot = if IsNaN(close) then Double.NaN else 28;
A28_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A28_Dot.SetLineWeight(Dotsize);
A28_Dot.AssignValueColor(if Diff10>=1 then Color.BLUE else Color.RED);

plot A29_Dot = if IsNaN(close) then Double.NaN else 29;
A29_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A29_Dot.SetLineWeight(Dotsize);
A29_Dot.AssignValueColor(if Con1J and Con3J then Color.Green else if Con1J and Con4J then Color.Dark_Green else if Con2J and Con3J then Color.Light_Red else if Con2J and Con4J then Color.Dark_Red else Color.Black);

plot A30_Dot = if IsNaN(close) then Double.NaN else 30;
A30_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A30_Dot.SetLineWeight(Dotsize+1);
A30_Dot.AssignValueColor(if Diff10>=UZJ then Color.YELLOW else IF Diff10 < LZJ then Color.Dark_Orange else Color.Black);

plot A31_Dot = if IsNaN(close) then Double.NaN else 31;
A31_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A31_Dot.SetLineWeight(Dotsize);
A31_Dot.AssignValueColor(if Diff11>=1 then Color.BLUE else Color.RED);

plot A32_Dot = if IsNaN(close) then Double.NaN else 32;
A32_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A32_Dot.SetLineWeight(Dotsize);
A32_Dot.AssignValueColor(if Con1K and Con3K then Color.Green else if Con1K and Con4K then Color.Dark_Green else if Con2K and Con3K then Color.Light_Red else if Con2K and Con4K then Color.Dark_Red else Color.Black);

plot A33_Dot = if IsNaN(close) then Double.NaN else 33;
A33_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A33_Dot.SetLineWeight(Dotsize+1);
A33_Dot.AssignValueColor(if Diff11>=UZK then Color.YELLOW else IF Diff11 < LZK then Color.Dark_Orange else Color.Black);

plot A34_Dot = if IsNaN(close) then Double.NaN else 34;
A34_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A34_Dot.SetLineWeight(Dotsize);
A34_Dot.AssignValueColor(if Diff12>=1 then Color.BLUE else Color.RED);

plot A35_Dot = if IsNaN(close) then Double.NaN else 35;
A35_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A35_Dot.SetLineWeight(Dotsize);
A35_Dot.AssignValueColor(if Con1L and Con3L then Color.Green else if Con1L and Con4L then Color.Dark_Green else if Con2L and Con3L then Color.Light_Red else if Con2L and Con4L then Color.Dark_Red else Color.Black);

plot A36_Dot = if IsNaN(close) then Double.NaN else 36;
A36_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A36_Dot.SetLineWeight(Dotsize+1);
A36_Dot.AssignValueColor(if Diff12>=UZL then Color.YELLOW else IF Diff12 < LZL then Color.Dark_Orange else Color.Black);

plot A37_Dot = if IsNaN(close) then Double.NaN else 37;
A37_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A37_Dot.SetLineWeight(Dotsize);
A37_Dot.AssignValueColor(if Diff13>=1 then Color.BLUE else Color.RED);

plot A38_Dot = if IsNaN(close) then Double.NaN else 38;
A38_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A38_Dot.SetLineWeight(Dotsize);
A38_Dot.AssignValueColor(if Con1M and Con3M then Color.Green else if Con1M and Con4M then Color.Dark_Green else if Con2M and Con3M then Color.Light_Red else if Con2M and Con4M then Color.Dark_Red else Color.Black);

plot A39_Dot = if IsNaN(close) then Double.NaN else 39;
A39_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
A39_Dot.SetLineWeight(Dotsize+1);
A39_Dot.AssignValueColor(if Diff13>=UZM then Color.YELLOW else IF Diff13 < LZM then Color.Dark_Orange else Color.Black);


AssignPriceColor(if APC== 1 and Diff1 >= 1 then Color.Cyan else if APC== 1 and Diff1 < 1 then Color.Magenta else if APC== 2 and Con1A and Con3A then Color.Green else if APC ==2 and Con1A and Con4A then Color.Dark_Green else if APC ==2 and Con2A and Con3A then Color.Light_Red else if APC == 2 and Con2A and Con4A then Color.Dark_Red else if APC ==3 and Diff1>=UZA then Color.YELLOW else if APC ==3 and Diff1 < LZA then Color.Dark_Orange else if APC ==3 then Color.Dark_Gray else
 if APC== 4 and Diff2 >= 1 then Color.Cyan else if APC== 4 and Diff2 < 1 then Color.Magenta else if APC== 5 and Con1B and Con3B then Color.Green else if APC ==5 and Con1B and Con4B then Color.Dark_Green else if APC ==5 and Con2B and Con3B then Color.Light_Red else if APC == 5 and Con2B and Con4B then Color.Dark_Red else if APC ==6 and Diff2>=UZB then Color.YELLOW else if APC ==6 and Diff2 < LZB then Color.Dark_Orange else if APC ==6 then Color.Dark_Gray else
 if APC== 7 and Diff3 >= 1 then Color.Cyan else if APC== 7 and Diff3 < 1 then Color.Magenta else if APC== 8 and Con1C and Con3C then Color.Green else if APC ==8 and Con1C and Con4C then Color.Dark_Green else if APC ==8 and Con2C and Con3C then Color.Light_Red else if APC == 8 and Con2C and Con4C then Color.Dark_Red else if APC ==9 and Diff3>=UZC then Color.YELLOW else if APC ==9 and Diff3 < LZC then Color.Dark_Orange else if APC ==9 then Color.Dark_Gray else
if APC== 10 and Diff4 >= 1 then Color.Cyan else if APC== 10 and Diff4 < 1 then Color.Magenta else if APC== 11 and Con1D and Con3D then Color.Green else if APC ==11 and Con1D and Con4D then Color.Dark_Green else if APC ==11 and Con2D and Con3D then Color.Light_Red else if APC == 11 and Con2D and Con4D then Color.Dark_Red else if APC ==12 and Diff4>=UZD then Color.YELLOW else if APC ==12 and Diff4 < LZD then Color.Dark_Orange else if APC ==12 then Color.Dark_Gray else
if  APC== 13 and Diff5 >= 1 then Color.Cyan else if APC== 13 and Diff5 < 1 then Color.Magenta else if APC== 14 and Con1E and Con3E then Color.Green else if APC ==14 and Con1E and Con4E then Color.Dark_Green else if APC ==14 and Con2E and Con3E then Color.Light_Red else if APC == 14 and Con2E and Con4E then Color.Dark_Red else if APC ==15 and Diff5>=UZE then Color.YELLOW else if APC ==15 and Diff5 < LZE then Color.Dark_Orange else if APC ==15 then Color.Dark_Gray else
if APC== 16 and Diff6 >= 1 then Color.Cyan else if APC== 16 and Diff6 < 1 then Color.Magenta else if APC== 17 and Con1F and Con3F then Color.Green else if APC ==17 and Con1F and Con4F then Color.Dark_Green else if APC ==17 and Con2F and Con3F then Color.Light_Red else if APC == 17 and Con2F and Con4F then Color.Dark_Red else if APC ==18 and Diff6>=UZF then Color.YELLOW else if APC ==18 and Diff6 < LZF then Color.Dark_Orange else if APC ==18 then Color.Dark_Gray else
if APC== 19 and Diff7 >= 1 then Color.BLUE else if APC== 19 and Diff7 < 1 then Color.RED else if APC== 20 and Con1G and Con3G then Color.Green else if APC ==20 and Con1G and Con4G then Color.Dark_Green else if APC ==20 and Con2G and Con3G then Color.Light_Red else if APC == 20 and Con2G and Con4G then Color.Dark_Red else if APC ==21 and Diff7>=UZG then Color.YELLOW else if APC ==21 and Diff7 < LZG then Color.Dark_Orange else if APC ==21 then Color.Dark_Gray else
if APC== 22 and Diff8 >= 1 then Color.BLUE else if APC== 22 and Diff8 < 1 then Color.RED else if APC== 23 and Con1H and Con3H then Color.Green else if APC ==23 and Con1H and Con4H then Color.Dark_Green else if APC ==23 and Con2H and Con3H then Color.Light_Red else if APC == 23 and Con2H and Con4H then Color.Dark_Red else if APC ==24 and Diff8>=UZH then Color.YELLOW else if APC ==24 and Diff8 < LZH then Color.Dark_Orange else if APC ==24 then Color.Dark_Gray else
if APC== 25 and Diff9 >= 1 then Color.BLUE else if APC== 25 and Diff9 < 1 then Color.RED else if APC== 26 and Con1I and Con3I then Color.Green else if APC ==26 and Con1I and Con4I then Color.Dark_Green else if APC ==26 and Con2I and Con3I then Color.Light_Red else if APC == 26 and Con2I and Con4I then Color.Dark_Red else if APC ==27 and Diff9>=UZI then Color.YELLOW else if APC ==27 and Diff9 < LZI then Color.Dark_Orange else if APC ==27 then Color.Dark_Gray else
if APC== 28 and Diff10 >= 1 then Color.BLUE else if APC== 28 and Diff10 < 1 then Color.RED else if APC== 29 and Con1J and Con3J then Color.Green else if APC ==29 and Con1J and Con4J then Color.Dark_Green else if APC ==29 and Con2J and Con3J then Color.Light_Red else if APC == 29 and Con2J and Con4J then Color.Dark_Red else if APC ==30 and Diff10>=UZJ then Color.YELLOW else if APC ==30 and Diff10 < LZJ then Color.Dark_Orange else if APC ==30 then Color.Dark_Gray else
if APC== 31 and Diff11 >= 1 then Color.BLUE else if APC== 31 and Diff11 < 1 then Color.RED else if APC== 32 and Con1K and Con3K then Color.Green else if APC ==32 and Con1K and Con4K then Color.Dark_Green else if APC ==32 and Con2K and Con3K then Color.Light_Red else if APC == 32 and Con2K and Con4K then Color.Dark_Red else if APC ==33 and Diff11>=UZK then Color.YELLOW else if APC ==33 and Diff11 < LZK then Color.Dark_Orange else if APC ==33 then Color.Dark_Gray else
if APC== 34 and Diff12 >= 1 then Color.BLUE else if APC== 34 and Diff12 < 1 then Color.RED else if APC== 35 and Con1L and Con3L then Color.Green else if APC ==35 and Con1L and Con4L then Color.Dark_Green else if APC ==35 and Con2L and Con3L then Color.Light_Red else if APC == 35 and Con2L and Con4L then Color.Dark_Red else if APC ==36 and Diff12>=UZL then Color.YELLOW else if APC ==36 and Diff12 < LZL then Color.Dark_Orange else if APC ==36 then Color.Dark_Gray else
if APC== 37 and Diff13 >= 1 then Color.BLUE else if APC== 37 and Diff13 < 1 then Color.RED else if APC== 38 and Con1M and Con3M then Color.Green else if APC ==38 and Con1M and Con4M then Color.Dark_Green else if APC ==38 and Con2M and Con3M then Color.Light_Red else if APC == 38 and Con2M and Con4M then Color.Dark_Red else if APC ==39 and Diff13>=UZM then Color.YELLOW else if APC ==39 and Diff13 < LZM then Color.Dark_Orange else if APC ==39 then Color.Dark_Gray else Color.Current);

Hi henry1224 - Thank you for efforts with this but I tried it and it doesn't display anything. Anyone else got it working?
 
Hi henry1224 - Thank you for efforts with this but I tried it and it doesn't display anything. Anyone else got it working?

Once you add the indicator to a chart, you can adjust the inputs. If you go down the list of inputs you'll come across one that named APC.
You can input the line number say 22 and the upper price bars will paint to the colors of line 22

Line 1 is when the fastest RSI is greater than or Less than the Slower RSI
Line 2 is when the Difference is above 1 and rising, above 1 and falling, below 1 and falling and below 1 and rising
Line 3 is when the Faster RSI is above the Deviation channel "Yellow" or Below "Orange"

Look for Cyan or Blue "Bullish", Magenta or Red are "bearish"
Look for Green or Light_Red on line 2 "Bullish" or Dark_Green or Dark_Red "Bearish"
 
Last edited:
Im actually interested this too. I have uploaded and the scripts above and I cant none of them to chart as the video does. What am I missing. I even changed the 25 100 inputs but no cigar yet.
 
Im actually interested this too. I have uploaded and the scripts above and I cant none of them to chart as the video does. What am I missing. I even changed the 25 100 inputs but no cigar yet.
Do you have enough data loaded in your charts?
In the image that I attached that is a daily chart with 3 years of data

If the chart just sits there and takes awhile to load, Just click on the zoom in button in the lower right corner of the chart.
 
Last edited:
This is Three RSI Diff w Arrows
Code:
declare Lower;
input period1 = 3;
input period2 = 12;
input period3 = 36;
input arrows= no;
input Dotsize =3;
def Price = (open + close) / 2;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, Price - Price[1], period1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(Price - Price[1]), period1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, Price - Price[1], period2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(Price - Price[1]), period2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
plot Diff = RSIA / RSIB;
def NetChgAvgC = MovingAverage(averageType, Price - Price[1], period3);
def TotChgAvgC = MovingAverage(averageType, AbsValue(Price - Price[1]), period3);
def ChgRatioC = if TotChgAvgC != 0 then NetChgAvgC / TotChgAvgC else 0;
def RSIC = 50 * (ChgRatioC + 1);
Plot Diff2 = RSIB/RSIC;

Diff.SetDefaultColor(Color.CYAN);
Diff2.SetDefaultColor(Color.Blue);

AddCloud(Diff,1,Color.CYAN,Color.MAGENTA);
AddCloud(Diff2,1,Color.Blue,Color.Red);

Plot UZ = Average(Diff,34) + (1.3185*StDev(Diff,34));
UZ.SetPaintingStrategy(PaintingStrategy.Line);
UZ.SetLineWeight(1);
UZ.SetDefaultColor(Color.Yellow);
Plot LZ = Average(Diff,34) - (1.3185*StDev(Diff,34));
LZ.SetPaintingStrategy(PaintingStrategy.Line);
LZ.SetLineWeight(1);
LZ.SetDefaultColor(Color.Yellow);
#ARROWS
plot ArrowDown = if arrows and (Diff Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);

plot ArrowUp = if arrows and (Diff crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);

plot ArrowDownA = if arrows and (Diff2 Crosses below 1) then 1 else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Red);
ArrowDown.setLineWeight(dotsize);

plot ArrowUpA = if arrows and (Diff2 crosses above 1) then 1 else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Blue);
ArrowUp.setLineWeight(dotsize);

plot ArrowDown2 = if arrows and (Diff Crosses below UZ) then UZ else double.nan;
ArrowDown2.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown2.setDefaultColor(color.Yellow);
ArrowDown2.setLineWeight(dotsize);

plot ArrowUp2 = if arrows and (Diff crosses above LZ ) then LZ else double.nan;
ArrowUp2.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp2.setDefaultColor(color.Dark_Orange);
ArrowUp2.setLineWeight(dotsize);

Henry1224, thank you for posting this thoughtful Thinkscript. Even to my untrained eye, there is quite a lot of useful information discerned while running it on one of the major indices such as /ES or /NQ, although I wonder if I'm making even close to the optimal use of what it's saying. Clearly, the transition upwards through the 1.0 line is bullish, and downwards through that line is bearish. However, what is the significance of the green versus green/blue shading? Likewise with the purple vs. purple/red shading? I assume the yellow arrow is intended to warn that a bullish trend may be coming to an end? Likewise, an orange arrow appears to warn that a bearish trend is coming to an end? Concerning the latter, I'm struck how prescient the orange arrow appears to be. Would appreciate your thoughts. In any case, it's a pristine Thinkscript and thank you for sharing it.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
296 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