#PriceTimeGrid
#@rlohmeyer shared on UseThinkscript
#Thanks to @OBW, @SleepyZ, and @Generic when I got stuck with code
# 3/11/2021
input increment = 1.00;
input major = 5;
input showMidpoints = yes;
input yourLevel = 0;
DefineGlobalColor ("MAJOR",CreateColor(192, 104, 222));
DefineGlobalColor("INCREMENT",color.light_gray);
def op = open(period = AggregationPeriod.DAY);
def mo = Round(op / major, 0) * major;
def ST = if yourLevel == 0 then Round(op / major, 0) * major else yourLevel;
def MP = INCREMENT/2;
#Plot ST
plot PLS = ST;
PLS.SetDefaultColor(globalColor(“MAJOR”));
PLS.HideTitle();
PLS.SetPaintingStrategy(PaintingStrategy.horizontal);
PLS.SetLineWeight(2);
#ST Up
plot MU1 = if showMidpoints then ST + MP else Double.NaN;
MU1.SetDefaultColor(globalColor(“INCREMENT”));
MU1.HideTitle();
MU1.SetPaintingStrategy(PaintingStrategy.dashes);
MU1.HideBubble();
MU1.SetLineWeight(1);
plot PU1 = if ST > 0 then ST + INCREMENT else Double.NaN;
PU1.SetDefaultColor(globalColor("INCREMENT"));
PU1.HideTitle();
PU1.SetPaintingStrategy(PaintingStrategy.horizontal);
PU1.SetLineWeight(1);
plot MU2 = if showMidpoints then PU1 + MP else Double.NaN;
MU2.SetDefaultColor(globalColor(“INCREMENT”));
MU2.HideTitle();
MU2.SetPaintingStrategy(PaintingStrategy.dashes);
MU2.HideBubble();
MU2.SetLineWeight(1);
plot PU2 = if ST > 0 then ST + (2 * INCREMENT)else Double.NaN;
PU2.SetDefaultColor(globalColor("INCREMENT"));
PU2.HideTitle();
PU2.SetPaintingStrategy(PaintingStrategy.horizontal);
PU2.SetLineWeight(1);
plot MU3 = if showMidpoints then PU2 + MP else Double.NaN;
MU3.SetDefaultColor(globalColor(“INCREMENT”));
MU3.HideTitle();
MU3.SetPaintingStrategy(PaintingStrategy.dashes);
MU3.HideBubble();
MU3.SetLineWeight(1);
plot PU3 = if ST > 0 then ST + (3 * INCREMENT)else Double.NaN;
PU3.SetDefaultColor(globalColor("INCREMENT"));
PU3.HideTitle();
PU3.SetPaintingStrategy(PaintingStrategy.horizontal);
PU3.SetLineWeight(1);
plot MU4 = if showMidpoints then PU3 + MP else Double.NaN;
MU4.SetDefaultColor(globalColor(“INCREMENT”));
MU4.HideTitle();
MU4.SetPaintingStrategy(PaintingStrategy.dashes);
MU4.HideBubble();
MU4.SetLineWeight(1);
plot PU4 = if ST > 0 then ST + (4 * INCREMENT)else Double.NaN;
PU4.SetDefaultColor(globalColor("INCREMENT"));
PU4.HideTitle();
PU4.SetPaintingStrategy(PaintingStrategy.horizontal);
PU4.SetLineWeight(1);
plot MU5 = if showMidpoints then PU4 + MP else Double.NaN;
MU5.SetDefaultColor(globalColor(“INCREMENT”));
MU5.HideTitle();
MU5.SetPaintingStrategy(PaintingStrategy.dashes);
MU5.HideBubble();
MU5.SetLineWeight(1);
plot PU5 = if ST > 0 then ST + (5 * INCREMENT)else Double.NaN;
PU5.AssignValueColor (if (PU5/5)/round((PU5/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PU5.HideTitle();
PU5.SetPaintingStrategy(PaintingStrategy.horizontal);
PU5.SetLineWeight(1);
plot MU6 = if showMidpoints then PU5 + MP else Double.NaN;
MU6.SetDefaultColor(globalColor(“INCREMENT”));
MU6.HideTitle();
MU6.SetPaintingStrategy(PaintingStrategy.dashes);
MU6.HideBubble();
MU6.SetLineWeight(1);
plot PU6 = if ST > 0 then ST + (6 * INCREMENT)else Double.NaN;
PU6.SetDefaultColor(globalColor("INCREMENT"));
PU6.HideTitle();
PU6.SetPaintingStrategy(PaintingStrategy.horizontal);
PU6.SetLineWeight(1);
plot MU7 = if showMidpoints then PU6 + MP else Double.NaN;
MU7.SetDefaultColor(globalColor(“INCREMENT”));
MU7.HideTitle();
MU7.SetPaintingStrategy(PaintingStrategy.dashes);
MU7.HideBubble();
MU7.SetLineWeight(1);
plot PU7 = if ST > 0 then ST + (7 * INCREMENT)else Double.NaN;
PU7.SetDefaultColor(globalColor("INCREMENT"));
PU7.HideTitle();
PU7.SetPaintingStrategy(PaintingStrategy.horizontal);
PU7.SetLineWeight(1);
plot MU8 = if showMidpoints then PU7 + MP else Double.NaN;
MU8.SetDefaultColor(globalColor(“INCREMENT”));
MU8.HideTitle();
MU8.SetPaintingStrategy(PaintingStrategy.dashes);
MU8.HideBubble();
MU8.SetLineWeight(1);
plot PU8 = if ST > 0 then ST + (8 * INCREMENT)else Double.NaN;
PU8.SetDefaultColor(globalColor("INCREMENT"));
PU8.HideTitle();
PU8.SetPaintingStrategy(PaintingStrategy.horizontal);
PU8.SetLineWeight(1);
plot MU9 = if showMidpoints then PU8 + MP else Double.NaN;
MU9.SetDefaultColor(globalColor(“INCREMENT”));
MU9.HideTitle();
MU9.SetPaintingStrategy(PaintingStrategy.dashes);
MU9.HideBubble();
MU9.SetLineWeight(1);
plot PU9 = if ST > 0 then ST + (9 * INCREMENT)else Double.NaN;
PU9.SetDefaultColor(globalColor("INCREMENT"));
PU9.HideTitle();
PU9.SetPaintingStrategy(PaintingStrategy.horizontal);
PU9.SetLineWeight(1);
plot MU10 = if showMidpoints then PU9 + MP else Double.NaN;
MU10.SetDefaultColor(globalColor(“INCREMENT”));
MU10.HideTitle();
MU10.SetPaintingStrategy(PaintingStrategy.dashes);
MU10.HideBubble();
MU10.SetLineWeight(1);
plot PU10 = if ST > 0 then ST + (10 * INCREMENT)else Double.NaN;
PU10.AssignValueColor (if (PU10/5)/round((PU10/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PU10.HideTitle();
PU10.SetPaintingStrategy(PaintingStrategy.horizontal);
PU10.SetLineWeight(1);
plot MU11 = if showMidpoints then PU10 + MP else Double.NaN;
MU11.SetDefaultColor(globalColor(“INCREMENT”));
MU11.HideTitle();
MU11.SetPaintingStrategy(PaintingStrategy.dashes);
MU11.HideBubble();
MU11.SetLineWeight(1);
plot PU11 = if ST > 0 then ST + (11 * INCREMENT)else Double.NaN;
PU11.SetDefaultColor(globalColor(“INCREMENT”));
PU11.HideTitle();
PU11.SetPaintingStrategy(PaintingStrategy.horizontal);
PU11.SetLineWeight(1);
plot MU12 = if showMidpoints then PU11 + MP else Double.NaN;
MU12.SetDefaultColor(globalColor(“INCREMENT”));
MU12.HideTitle();
MU12.SetPaintingStrategy(PaintingStrategy.dashes);
MU12.HideBubble();
MU12.SetLineWeight(1);
plot PU12 = if ST > 0 then ST + (12 * INCREMENT)else Double.NaN;
PU12.SetDefaultColor(globalColor(“INCREMENT”));
PU12.HideTitle();
PU12.SetPaintingStrategy(PaintingStrategy.horizontal);
PU12.SetLineWeight(1);
plot MU13 = if showMidpoints then PU12 + MP else Double.NaN;
MU13.SetDefaultColor(globalColor(“INCREMENT”));
MU13.HideTitle();
MU13.SetPaintingStrategy(PaintingStrategy.dashes);
MU13.HideBubble();
MU13.SetLineWeight(1);
plot PU13 = if ST > 0 then ST + (13 * INCREMENT)else Double.NaN;
PU13.SetDefaultColor(globalColor(“INCREMENT”));
PU13.HideTitle();
PU13.SetPaintingStrategy(PaintingStrategy.horizontal);
PU13.SetLineWeight(1);
plot MU14 = if showMidpoints then PU13 + MP else Double.NaN;
MU14.SetDefaultColor(globalColor(“INCREMENT”));
MU14.HideTitle();
MU14.SetPaintingStrategy(PaintingStrategy.dashes);
MU14.HideBubble();
MU14.SetLineWeight(1);
plot PU14 = if ST > 0 then ST + (14 * INCREMENT)else Double.NaN;
PU14.SetDefaultColor(globalColor(“INCREMENT”));
PU14.HideTitle();
PU14.SetPaintingStrategy(PaintingStrategy.horizontal);
PU14.SetLineWeight(1);
plot MU15 = if showMidpoints then PU14 + MP else Double.NaN;
MU15.SetDefaultColor(globalColor(“INCREMENT”));
MU15.HideTitle();
MU15.SetPaintingStrategy(PaintingStrategy.dashes);
MU15.HideBubble();
MU15.SetLineWeight(1);
plot PU15 = if ST > 0 then ST + (15 * INCREMENT)else Double.NaN;
PU15.AssignValueColor (if (PU15/5)/round((PU15/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PU15.HideTitle();
PU15.SetPaintingStrategy(PaintingStrategy.horizontal);
PU15.SetLineWeight(1);
#STDown
plot MD1 = if showMidpoints then ST - MP else Double.NaN;
MD1.SetDefaultColor(globalColor(“INCREMENT”));
MD1.HideTitle();
MD1.SetPaintingStrategy(PaintingStrategy.dashes);
MD1.HideBubble();
MD1.SetLineWeight(1);
plot PD1 = if ST > 0 then ST - INCREMENT else Double.NaN;
PD1.SetDefaultColor(globalColor("INCREMENT"));
PD1.HideTitle();
PD1.SetPaintingStrategy(PaintingStrategy.horizontal);
PD1.SetLineWeight(1);
plot MD2 = if showMidpoints then PD1 - MP else Double.NaN;
MD2.SetDefaultColor(globalColor(“INCREMENT”));
MD2.HideTitle();
MD2.SetPaintingStrategy(PaintingStrategy.dashes);
MD2.HideBubble();
MD2.SetLineWeight(1);
plot PD2 = if ST > 0 then ST - (2 * INCREMENT) else Double.NaN;
PD2.SetDefaultColor(globalColor("INCREMENT"));
PD2.HideTitle();
PD2.SetPaintingStrategy(PaintingStrategy.horizontal);
PD2.SetLineWeight(1);
plot MD3 = if showMidpoints then PD2 - MP else Double.NaN;
MD3.SetDefaultColor(globalColor(“INCREMENT”));
MD3.HideTitle();
MD3.SetPaintingStrategy(PaintingStrategy.dashes);
MD3.HideBubble();
MD3.SetLineWeight(1);
plot PD3 = if ST > 0 then ST - (3 * INCREMENT)else Double.NaN;
PD3.SetDefaultColor(globalColor("INCREMENT"));
PD3.HideTitle();
PD3.SetPaintingStrategy(PaintingStrategy.horizontal);
PD3.SetLineWeight(1);
plot MD4 = if showMidpoints then PD3 - MP else Double.NaN;
MD4.SetDefaultColor(globalColor(“INCREMENT”));
MD4.HideTitle();
MD4.SetPaintingStrategy(PaintingStrategy.dashes);
MD4.HideBubble();
MD4.SetLineWeight(1);
plot PD4 = if ST > 0 then ST - (4 * INCREMENT)else Double.NaN;
PD4.SetDefaultColor(globalColor("INCREMENT"));
PD4.HideTitle();
PD4.SetPaintingStrategy(PaintingStrategy.horizontal);
PD4.SetLineWeight(1);
plot MD5 = if showMidpoints then PD4 - MP else Double.NaN;
MD5.SetDefaultColor(globalColor(“INCREMENT”));
MD5.HideTitle();
MD5.SetPaintingStrategy(PaintingStrategy.dashes);
MD5.HideBubble();
MD5.SetLineWeight(1);
plot PD5 = if ST > 0 then ST - (5 * INCREMENT)else Double.NaN;
PD5.AssignValueColor (if(PD5/5)/round((PD5/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PD5.HideTitle();
PD5.SetPaintingStrategy(PaintingStrategy.horizontal);
PD5.SetLineWeight(1);
plot MD6 = if showMidpoints then PD5 - MP else Double.NaN;
MD6.SetDefaultColor(globalColor(“INCREMENT”));
MD6.HideTitle();
MD6.SetPaintingStrategy(PaintingStrategy.dashes);
MD6.HideBubble();
MD6.SetLineWeight(1);
plot PD6 = if ST > 0 then ST - (6 * INCREMENT)else Double.NaN;
PD6.SetDefaultColor(globalColor("INCREMENT"));
PD6.HideTitle();
PD6.SetPaintingStrategy(PaintingStrategy.horizontal);
PD6.SetLineWeight(1);
plot MD7 = if showMidpoints then PD6 - MP else Double.NaN;
MD7.SetDefaultColor(globalColor(“INCREMENT”));
MD7.HideTitle();
MD7.SetPaintingStrategy(PaintingStrategy.dashes);
MD7.HideBubble();
MD7.SetLineWeight(1);
plot PD7 = if ST > 0 then ST - (7 * INCREMENT)else Double.NaN;
PD7.SetDefaultColor(globalColor("INCREMENT"));
PD7.HideTitle();
PD7.SetPaintingStrategy(PaintingStrategy.horizontal);
PD7.SetLineWeight(1);
plot MD8 = if showMidpoints then PD7 - MP else Double.NaN;
MD8.SetDefaultColor(globalColor(“INCREMENT”));
MD8.HideTitle();
MD8.SetPaintingStrategy(PaintingStrategy.dashes);
MD8.HideBubble();
MD8.SetLineWeight(1);
plot PD8 = if ST > 0 then ST - (8 * INCREMENT)else Double.NaN;
PD8.SetDefaultColor(globalColor("INCREMENT"));
PD8.HideTitle();
PD8.SetPaintingStrategy(PaintingStrategy.horizontal);
PD8.SetLineWeight(1);
plot MD9 = if showMidpoints then PD8 - MP else Double.NaN;
MD9.SetDefaultColor(globalColor(“INCREMENT”));
MD9.HideTitle();
MD9.SetPaintingStrategy(PaintingStrategy.dashes);
MD9.HideBubble();
MD9.SetLineWeight(1);
plot PD9 = if ST > 0 then ST - (9 * INCREMENT)else Double.NaN;
PD9.SetDefaultColor(globalColor("INCREMENT"));
PD9.HideTitle();
PD9.SetPaintingStrategy(PaintingStrategy.horizontal);
PD9.SetLineWeight(1);
plot MD10 = if showMidpoints then PD9 - MP else Double.NaN;
MD10.SetDefaultColor(globalColor(“INCREMENT”));
MD10.HideTitle();
MD10.SetPaintingStrategy(PaintingStrategy.dashes);
MD10.HideBubble();
MD10.SetLineWeight(1);
plot PD10 = if ST > 0 then ST - (10 * INCREMENT)else Double.NaN;
PD10.AssignValueColor (if (PD10/5)/round((PD10/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PD10.HideTitle();
PD10.SetPaintingStrategy(PaintingStrategy.horizontal);
PD10.SetLineWeight(1);
plot MD11 = if showMidpoints then PD10 - MP else Double.NaN;
MD11.SetDefaultColor(globalColor(“INCREMENT”));
MD11.HideTitle();
MD11.SetPaintingStrategy(PaintingStrategy.dashes);
MD11.HideBubble();
MD11.SetLineWeight(1);
plot PD11 = if ST > 0 then ST - (11 * INCREMENT)else Double.NaN;
PD11.SetDefaultColor(globalColor(“INCREMENT”));
PD11.HideTitle();
PD11.SetPaintingStrategy(PaintingStrategy.horizontal);
PD11.SetLineWeight(1);
plot MD12 = if showMidpoints then PD11 - MP else Double.NaN;
MD12.SetDefaultColor(globalColor(“INCREMENT”));
MD12.HideTitle();
MD12.SetPaintingStrategy(PaintingStrategy.dashes);
MD12.HideBubble();
MD12.SetLineWeight(1);
plot PD12 = if ST > 0 then ST - (12 * INCREMENT)else Double.NaN;
PD12.SetDefaultColor(globalColor(“INCREMENT”));
PD12.HideTitle();
PD12.SetPaintingStrategy(PaintingStrategy.horizontal);
PD12.SetLineWeight(1);
plot MD13 = if showMidpoints then PD12 - MP else Double.NaN;
MD13.SetDefaultColor(globalColor(“INCREMENT”));
MD13.HideTitle();
MD13.SetPaintingStrategy(PaintingStrategy.dashes);
MD13.HideBubble();
MD13.SetLineWeight(1);
plot PD13 = if ST > 0 then ST - (13 * INCREMENT)else Double.NaN;
PD13.SetDefaultColor(globalColor(“INCREMENT”));
PD13.HideTitle();
PD13.SetPaintingStrategy(PaintingStrategy.horizontal);
PD13.SetLineWeight(1);
plot MD14 = if showMidpoints then PD13 - MP else Double.NaN;
MD14.SetDefaultColor(globalColor(“INCREMENT”));
MD14.HideTitle();
MD14.SetPaintingStrategy(PaintingStrategy.dashes);
MD14.HideBubble();
MD14.SetLineWeight(1);
plot PD14 = if ST > 0 then ST - (14 * INCREMENT)else Double.NaN;
PD14.SetDefaultColor(globalColor(“INCREMENT”));
PD14.HideTitle();
PD14.SetPaintingStrategy(PaintingStrategy.horizontal);
PD14.SetLineWeight(1);
plot MD15 = if showMidpoints then PD14 - MP else Double.NaN;
MD15.SetDefaultColor(globalColor(“INCREMENT”));
MD15.HideTitle();
MD15.SetPaintingStrategy(PaintingStrategy.dashes);
MD15.HideBubble();
MD15.SetLineWeight(1);
plot PD15 = if ST > 0 then ST - (15 * INCREMENT)else Double.NaN;
PD15.AssignValueColor (if(PD15/5)/round((PD15/5),0)==1 then CreateColor(192, 104, 222) else COLOR.LIGHT_GRAY);
PD15.HideTitle();
PD15.SetPaintingStrategy(PaintingStrategy.horizontal);
PD15.SetLineWeight(1);
#Vertical Line at minutes interval
#Sleepyz
input verticle_minutes1 = 5;
input verticle_minutes2 = 15;
def NYbegin = 0930;
def NYend = 1600;
def bar = if SecondsTillTime(NYbegin) == 0 and
SecondsFromTime(NYbegin) == 0
then 0
else bar[1] + 1;
input show_vertical_lines= yes;
AddVerticalLine(if show_vertical_lines and SecondsFromTime(NYbegin) >= 0 and secondsfromTime(NYend)<=0
then bar % (ceil(verticle_minutes1) / (GetAggregationPeriod() / 60000)) == 0
else Double.NaN,
color = Color.light_gray, stroke = Curve.short_dash);
AddVerticalLine(if show_vertical_lines and SecondsFromTime(NYbegin) >= 0 and secondsfromTime(NYend)<=0
then bar % (ceil(verticle_minutes2) / (GetAggregationPeriod() / 60000)) == 0
else Double.NaN,
color = Color.light_gray, stroke = Curve.long_dash);