```
input CorrelationWithSecurity = "SPY";
input alternateTimeFrame = no;
input agg = AggregationPeriod.HOUR;
def AP = GetAggregationPeriod();
def timeframe = if !alternateTimeFrame then AP else agg;
def close2 = close(CorrelationWithSecurity,period = timeframe);
declare lower;
input Period1 = 3;
input Period2 = 5;
input Period3 = 8;
input Period4 = 10;
input Period5 = 12;
input Period6 = 15;
input Period7 = 30;
input Period8 = 35;
input Period9 = 40;
input Period10 = 45;
input Period11 = 50;
input Period12 = 60;
input Dotsize = 3;
input Paintbars =0;
def pctchgA = 100 * (close(period = timeframe) / close(period = timeframe)[period1] - 1);
def pctchgspyA = 100 * (close2 / close2[period1] - 1);
def pmcA = pctchgA - pctchgspyA;
def pmcmaA = expaverage(pmcA, 3);
def pctchgB = 100 * (close(period = timeframe) / close(period = timeframe)[period2] - 1);
def pctchgspyB = 100 * (close2 / close2[period2] - 1);
def pmcB = pctchgB - pctchgspyB;
def pmcmaB = expaverage(pmcB, 3);
def pctchgC = 100 * (close(period = timeframe) / close(period = timeframe)[period3] - 1);
def pctchgspyC = 100 * (close2 / close2[period3] - 1);
def pmcC = pctchgC - pctchgspyC;
def pmcmaC = expaverage(pmcC, 3);
def pctchgD = 100 * (close(period = timeframe) / close(period = timeframe)[period4] - 1);
def pctchgspyD = 100 * (close2 / close2[period4] - 1);
def pmcD = pctchgD - pctchgspyD;
def pmcmaD = expaverage(pmcD, 3);
def pctchgE = 100 * (close(period = timeframe) / close(period = timeframe)[period5] - 1);
def pctchgspyE = 100 * (close2 / close2[period5] - 1);
def pmcE = pctchgE - pctchgspyE;
def pmcmaE = expaverage(pmcE, 3);
def pctchgF = 100 * (close(period = timeframe) / close(period = timeframe)[period6] - 1);
def pctchgspyF = 100 * (close2 / close2[period6] - 1);
def pmcF = pctchgF - pctchgspyF;
def pmcmaF = expaverage(pmcF, 3);
def pctchgG = 100 * (close(period = timeframe) / close(period = timeframe)[period7] - 1);
def pctchgspyG = 100 * (close2 / close2[period7] - 1);
def pmcG = pctchgG - pctchgspyG;
def pmcmaG = expaverage(pmcG, 7);
def pctchgH = 100 * (close(period = timeframe) / close(period = timeframe)[period8] - 1);
def pctchgspyH = 100 * (close2 / close2[period8] - 1);
def pmcH = pctchgH - pctchgspyH;
def pmcmaH = expaverage(pmcH, 7);
def pctchgI = 100 * (close(period = timeframe) / close(period = timeframe)[period9] - 1);
def pctchgspyI = 100 * (close2 / close2[period9] - 1);
def pmcI = pctchgI - pctchgspyI;
def pmcmaI = expaverage(pmcI, 7);
def pctchgJ = 100 * (close(period = timeframe) / close(period = timeframe)[period10] - 1);
def pctchgspyJ = 100 * (close2 / close2[period10] - 1);
def pmcJ = pctchgJ - pctchgspyJ;
def pmcmaJ = expaverage(pmcJ, 7);
def pctchgK = 100 * (close(period = timeframe) / close(period = timeframe)[period11] - 1);
def pctchgspyK = 100 * (close2 / close2[period11] - 1);
def pmcK = pctchgK - pctchgspyK;
def pmcmaK = expaverage(pmcK, 7);
def pctchgL = 100 * (close(period = timeframe) / close(period = timeframe)[period12] - 1);
def pctchgspyL = 100 * (close2 / close2[period12] - 1);
def pmcL = pctchgL - pctchgspyL;
def pmcmaL = expaverage(pmcL, 7);
plot A1_Dot = if IsNaN(Close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if pmcA>=0 and pmcA>=pmcmaA then color.cyan else if pmcA>=0 and pmcA<=pmcmaA then color.blue else if pmcA<=0 and pmcA<=pmcmaA then color.red else color.magenta);
plot A2_Dot = if IsNaN(Close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if pmcB>=0 and pmcB>=pmcmaB then color.cyan else if pmcB>=0 and pmcB<=pmcmaB then color.blue else if pmcB<=0 and pmcB<=pmcmaB then color.red else color.magenta);
plot A3_Dot = if IsNaN(Close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if pmcC>=0 and pmcC>=pmcmaC then color.cyan else if pmcC>=0 and pmcC<=pmcmaC then color.blue else if pmcC<=0 and pmcC<=pmcmaC then color.red else color.magenta);
plot A4_Dot = if IsNaN(Close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if pmcD>=0 and pmcD>=pmcmaD then color.cyan else if pmcD>=0 and pmcD<=pmcmaD then color.blue else if pmcD<=0 and pmcD<=pmcmaD then color.red else color.magenta);
plot A5_Dot = if IsNaN(Close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if pmcE>=0 and pmcE>=pmcmaE then color.cyan else if pmcE>=0 and pmcE<=pmcmaE then color.blue else if pmcE<=0 and pmcE<=pmcmaE then color.red else color.magenta);
plot A6_Dot = if IsNaN(Close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if pmcF>=0 and pmcF>=pmcmaF then color.cyan else if pmcF>=0 and pmcF<=pmcmaF then color.blue else if pmcF<=0 and pmcF<=pmcmaF then color.red else color.magenta);
plot B7_Dot = if IsNaN(Close) then Double.NaN else 7;
B7_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B7_Dot.SetLineWeight(DotSize);
B7_Dot.AssignValueColor(if pmcG>=0 and pmcG>=pmcmaG then color.cyan else if pmcG>=0 and pmcG<=pmcmaG then color.blue else if pmcG<=0 and pmcG<=pmcmaG then color.red else color.magenta);
plot B8_Dot = if IsNaN(Close) then Double.NaN else 8;
B8_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B8_Dot.SetLineWeight(DotSize);
B8_Dot.AssignValueColor(if pmcH>=0 and pmcH>=pmcmaH then color.cyan else if pmcH>=0 and pmcH<=pmcmaH then color.blue else if pmcH<=0 and pmcH<=pmcmaH then color.red else color.magenta);
plot B9_Dot = if IsNaN(Close) then Double.NaN else 9;
B9_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B9_Dot.SetLineWeight(DotSize);
B9_Dot.AssignValueColor(if pmcI>=0 and pmcI>=pmcmaI then color.cyan else if pmcI>=0 and pmcI<=pmcmaI then color.blue else if pmcI<=0 and pmcI<=pmcmaI then color.red else color.magenta);
plot B10_Dot = if IsNaN(Close) then Double.NaN else 10;
B10_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B10_Dot.SetLineWeight(DotSize);
B10_Dot.AssignValueColor(if pmcJ>=0 and pmcJ>=pmcmaJ then color.cyan else if pmcJ>=0 and pmcJ<=pmcmaJ then color.blue else if pmcJ<=0 and pmcJ<=pmcmaJ then color.red else color.magenta);
plot B11_Dot = if IsNaN(Close) then Double.NaN else 11;
B11_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B11_Dot.SetLineWeight(DotSize);
B11_Dot.AssignValueColor(if pmcK>=0 and pmcK>=pmcmaK then color.cyan else if pmcK>=0 and pmcK<=pmcmaK then color.blue else if pmcK<=0 and pmcK<=pmcmaK then color.red else color.magenta);
plot B12_Dot = if IsNaN(Close) then Double.NaN else 12;
B12_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
B12_Dot.SetLineWeight(DotSize);
B12_Dot.AssignValueColor(if pmcL>=0 and pmcL>=pmcmaL then color.cyan else if pmcL>=0 and pmcL<=pmcmaL then color.blue else if pmcL<=0 and pmcL<=pmcmaL Then color.red else color.magenta);
```