Quarterly Theory For ThinkOrSwim

FutureTony

Well-known member
VIP
This one is a bit out there and more in the category of tool then indicator. But I've seen too much confluence around this concept and decided to make something to help visualize it and share with the community. Quarterly Theory is a time-based concept derived from some early ICT work. As far as I am aware, it was coined and outlined by Trader Daye. I am not the author of these concepts and will not be well suited to answer all questions you might have. I suggest you study Daye's twitter to gain more insight. This is purely a graphical aid for traders to be able to quickly determine Daye's Quarterly Cycles, and save Time while on the charts.
I have been inspired to create this tool for TOS by a very clever creator on Twitter (too) who has published a TradingView version here.
I have focused on the link above - the 6hr cycles and the 90m cycles.
These Quarters represent:
  • A - Accumulation (required for a cycle to occur)
  • M - Manipulation
  • D - Distribution
  • X - Reversal/Continuation
They may occur as A/M/D/X OR X/A/M/D. Again, I have focused on the Daily and intraday cycles:

– Daily Cycle:
The Day can be broken down into 6H quarters. These Times roughly define the sessions of the Trading Day, reinforcing the Theory’s validity.
  • Q1 - 18:00 - 00:00, Asian Session
  • Q2 - 00:00 - 06:00, London Session (True Open, Midnight New York Time)
  • Q3 - 06:00 - 12:00, NY Session
  • Q4 - 12:00 - 18:00, PM Session
– 90 Minute Cycle:
Dividing each of the above Daily Quarters into four, we obtain 90 minute quarters. The first one in a Trading Day – 90min Cycles of the Asian Session – follows as an example, in New York Time.
  • Q1 - 18:00 - 19:30
  • Q2 - 19:30 - 21:00 (True Open)
  • Q3 - 21:00 - 22:30
  • Q4 - 22:30 - 00:00
The idea here is that we are using these quarters to anticipate when and where liquidity might be taken before a move in the opposite direction might begin. Add it to your charts and you will be surprised how often in the future and forex markets that a sharp move will happen during the manipulation quarter, only for price to reverse and trend in the opposite direction.

On to the tool and the options. The current version is intended to work on smaller, intraday timeframes. I recommend using it on 15 minutes or below. I have split the tool into two visual components - an upper study that plots the quarterly divisions, the true opens for each quarter (optional), midnight open (optional) and a label for each new day (optional). There is also an option to show vertical lines for the 6hr quarters vs the 90m quarters (default).

TcII4nJ.png


Please note that the text on the image has been added manually to assist in understanding the intent of the tool.

There are a couple of quirks with how this interacts with TOS. The 'clouds' at the bottom will always have small gaps between them as TOS wants to leave a candle or so space between them. The smaller your selected timeframe, the smaller the gaps appear. Also, because the session day does not actually go until 6pm, I have elected not to put a 'Q4' for the end of the NY session. Would be happy to offer a version with that but it just looks visually off to me. Here is the shared link for the chart exactly as I have shown. I believe the only thing you need to do is minimize the size of your lower indicator:
https://tos.mx/ER6in7e

The study color scheme is configurable - so you can select whichever 4 colors make the most sense for your charts for the 4 'phases' of the chart. And finally, on to the code:
Upper:
Ruby:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def NYClose = 1630;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("trueOpen", Color.ORANGE);

def isMidnight = SecondsFromTime(Midnight) == 0;
def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty = SecondsFromTime(oneThirty) == 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree = SecondsFromTime(three) == 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty = SecondsFromTime(fourThirty) == 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix = SecondsFromTime(six) == 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty = SecondsFromTime(sevenThirty) == 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine = SecondsFromTime(nine) == 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty = SecondsFromTime(tenThirty) == 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon = SecondsFromTime(noon) == 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty = SecondsFromTime(thirteenThirty) == 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen = SecondsFromTime(fifteen) == 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isNYClose = SecondsFromTime(NYClose) == 0;
def isNYClose2 = SecondsFromTime(NYClose) >= 0;
def isEighteen = SecondsFromTime(eighteen) == 0;
def isEighteen2 = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) == 0;
def isNineteenThirty2 = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) == 0;
def isTwentyOne2 = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) == 0;
def isTwentyTwoThirty2 = SecondsFromTime(twentyTwoThirty) >= 0;

input show90 = yes;
input showQ2Opens = yes;
input showMidnight = yes;

def midOpen = if isMidnight then open else midOpen[1];
def today = getDay() == getLastDay();
plot midnightLine = if (today and showMidnight) then midOpen else Double.NaN;
midnightLine.setDefaultColor(GlobalColor("divider"));
midnightLine.setPaintingStrategy(PaintingStrategy.DASHES);

def q2Open = if (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty) then open else q2open[1];
plot trueOpenLine = if showQ2Opens and ((isOneThirty2 and !isFourThirty2) OR (isSevenThirty2 and !isTenThirty2) OR (isThirteenThirty2 and !isNYClose2) OR (isNineteenThirty2 and !isTwentyTwoThirty2)) then q2Open else Double.NaN;
trueOpenLine.setDefaultColor(GlobalColor("trueOpen"));

def DayOfWeek = getDayOfWeek(getYyyyMmDd());
input showDays = yes;
AddVerticalLine(show90 and (isMidnight OR isSix OR isNoon), "Q1", GlobalColor("divider"));
AddVerticalLine(isEighteen,"Q1" + if showDays then (if DayOfWeek == 1 then " - Monday" else if DayOfWeek == 2 then " - Tuesday" else if DayOfWeek == 3 then " - Wednesday" else if DayOfWeek == 4 then " - Thursday" else if DayOfWeek == 5 then " - Friday" else "") else "",GlobalColor("divider"));
AddVerticalLine(show90 and (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty), "Q2", GlobalColor("divider"));
AddVerticalLine(show90 and (isThree OR isNine OR isFifteen OR isTwentyOne), "Q3", GlobalColor("divider"));
AddVerticalLine(show90 and (isFourThirty OR isTenThirty OR isTwentyTwoThirty), "Q4", GlobalColor("divider"));

AddVerticalLine(!show90 and isMidnight, "Q1", GlobalColor("divider"));
AddVerticalLine(!show90 and isSix, "Q2", GlobalColor("divider"));
AddVerticalLine(!show90 and isNoon, "Q3", GlobalColor("divider"));
AddVerticalLine(!show90 and isEighteen, "Q4", GlobalColor("divider"));

# 90m clouds
def isQ1 = (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen2 and !isNineteenThirty2);
def isQ2 = (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty2 and !isTwentyOne2);
def isQ3 = (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isNYClose2) OR (isTwentyOne2 and !isTwentyTwoThirty2);
def isQ4 = (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty);

def q1High = if (isMidnight OR isSix OR isNoon OR isEighteen) then high else if isQ1 and high > q1High[1] then high else q1High[1];
def q1Low = if (isMidnight OR isSix OR isNoon OR isEighteen) then low else if isQ1 and low < q1Low[1] then low else q1Low[1];
input showQ1Levels = yes;
plot q1HighLine = if (showQ1Levels and isQ2) OR (showQ1Levels and isQ3) then q1High else Double.NaN;
q1HighLine.setPaintingStrategy(PaintingStrategy.DASHES);
q1HighLine.setDefaultColor(Color.DARK_GRAY);
plot q1LowLine = if (showQ1Levels and isQ2) OR (showQ1Levels and isQ3) then q1Low else Double.NaN;
q1LowLine.setPaintingStrategy(PaintingStrategy.DASHES);
q1LowLine.setDefaultColor(Color.DARK_GRAY);

Lower:
Code:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare lower;
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isEighteen = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) >= 0;

plot divider = 1;
divider.setDefaultColor(Color.BLACK);

# 90m clouds
def isQ1 = (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen and !isNineteenThirty);
AddCloud(if isQ1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
def isQ2 = (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty and !isTwentyOne);
AddCloud(if isQ2 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
def isQ3 = (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isEighteen) OR (isTwentyOne and !isTwentyTwoThirty);
AddCloud(if isQ3 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
def isQ4 = (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty);
AddCloud(if isQ4 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# 6hr clouds
def isQ2_6 = isMidnight2 and !isSix2;
AddCloud(if isQ2_6 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
def isQ3_6 = isSix2 and !isNoon2;
AddCloud(if isQ3_6 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
def isQ4_6 = isNoon2 and !isEighteen;
AddCloud(if isNoon2 and !isEighteen then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
def isQ1_6 = isEighteen;
AddCloud(if isQ1_6 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));

# 90m labels
input showLabels = yes;
AddLabel(showLabels and isQ1_6, "6hr Accumulation", GlobalColor("a"));
AddLabel(showLabels and isQ2_6, "6hr Manipulation", GlobalColor("m"));
AddLabel(showLabels and isQ3_6, "6hr Distribution", GlobalColor("d"));
AddLabel(showLabels and isQ4_6, "6hr Reversal/Continuation", GlobalColor("x"));
AddLabel(showLabels and isQ1, "90m Accumulation", GlobalColor("a"));
AddLabel(showLabels and isQ2, "90m Manipulation", GlobalColor("m"));
AddLabel(showLabels and isQ3, "90m Distribution", GlobalColor("d"));
AddLabel(showLabels and isQ4, "90m Reversal/Continuation", GlobalColor("x"));

# daily clouds 
input showDaily = no;
def DayOfWeek = getDayOfWeek(getYyyyMmDd());
plot divider2 = if showDaily then 0 else Double.NaN;
divider2.setDefaultColor(Color.BLACK);
AddCloud(if showDaily and dayOfWeek == 1 then -1 else Double.NaN, 0, GlobalColor("a"), GlobalColor("a"));
AddCloud(if showDaily and dayOfWeek == 2 then -1 else Double.NaN, 0, GlobalColor("m"), GlobalColor("m"));
AddCloud(if showDaily and dayOfWeek == 3 then -1 else Double.NaN, 0, GlobalColor("d"), GlobalColor("d"));
AddCloud(if showDaily and dayOfWeek == 4 then -1 else Double.NaN, 0, GlobalColor("x"), GlobalColor("x"));
 
Last edited:

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

Added labels to the lower indicator

Code:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
# tradingnumbers - added labels
declare lower;
declare hide_on_daily;

input showLabels = yes;

def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isEighteen = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) >= 0;

plot divider = 1;
divider.setDefaultColor(Color.BLACK);

# 90m clouds
def acc1 = (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen and !isNineteenThirty);
AddCloud(if acc1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
AddChartBubble(showLabels and acc1 and !acc1[1], 1.5, "Accumulation", GlobalColor("a"));

def man1 = (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty and !isTwentyOne);
AddCloud(if man1 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
AddChartBubble(showLabels and man1 and !man1[1], 1.5, "Manipulation", GlobalColor("m"));

def dist1 = (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isEighteen) OR (isTwentyOne and !isTwentyTwoThirty);
AddCloud(if dist1 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
AddChartBubble(showLabels and dist1 and !dist1[1], 1.5, "Distribution", GlobalColor("d"));

def rev1 = (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty);
AddCloud(if rev1 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));
AddChartBubble(showLabels and rev1 and !rev1[1], 1.5, "Rev/Cont", GlobalColor("x"));

# 6hr clouds
def acc2 = isEighteen;
AddCloud(if acc2 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));
AddChartBubble(showLabels and acc2 and !acc2[1], 0.5, "Accumulation", GlobalColor("a"));

def man2 = isMidnight2 and !isSix2;
AddCloud(if man2 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
AddChartBubble(showLabels and man2 and !man2[1], 0.5, "Manipulation", GlobalColor("m"));

def dist2 = isSix2 and !isNoon2;
AddCloud(if dist2 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
AddChartBubble(showLabels and dist2 and !dist2[1], 0.5, "Distribution", GlobalColor("d"));

def rev2 = isNoon2 and !isEighteen;
AddCloud(if rev2 then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
AddChartBubble(showLabels and rev2 and !rev2[1], 0.5, "Rev/Cont", GlobalColor("x"));

lsoeMR9.png
 
This one is a bit out there and more in the category of tool then indicator. But I've seen too much confluence around this concept and decided to make something to help visualize it and share with the community. Quarterly Theory is a time-based concept derived from some early ICT work. As far as I am aware, it was coined and outlined by Trader Daye. I am not the author of these concepts and will not be well suited to answer all questions you might have. I suggest you study Daye's twitter to gain more insight. This is purely a graphical aid for traders to be able to quickly determine Daye's Quarterly Cycles, and save Time while on the charts.
I have been inspired to create this tool for TOS by a very clever creator on Twitter (too) who has published a TradingView version here.
I have focused on the link above - the 6hr cycles and the 90m cycles.
These Quarters represent:
  • A - Accumulation (required for a cycle to occur)
  • M - Manipulation
  • D - Distribution
  • X - Reversal/Continuation
They may occur as A/M/D/X OR X/A/M/D. Again, I have focused on the Daily and intraday cycles:

– Daily Cycle:
The Day can be broken down into 6H quarters. These Times roughly define the sessions of the Trading Day, reinforcing the Theory’s validity.
  • Q1 - 18:00 - 00:00, Asian Session
  • Q2 - 00:00 - 06:00, London Session (True Open, Midnight New York Time)
  • Q3 - 06:00 - 12:00, NY Session
  • Q4 - 12:00 - 18:00, PM Session
– 90 Minute Cycle:
Dividing each of the above Daily Quarters into four, we obtain 90 minute quarters. The first one in a Trading Day – 90min Cycles of the Asian Session – follows as an example, in New York Time.
  • Q1 - 18:00 - 19:30
  • Q2 - 19:30 - 21:00 (True Open)
  • Q3 - 21:00 - 22:30
  • Q4 - 22:30 - 00:00
The idea here is that we are using these quarters to anticipate when and where liquidity might be taken before a move in the opposite direction might begin. Add it to your charts and you will be surprised how often in the future and forex markets that a sharp move will happen during the manipulation quarter, only for price to reverse and trend in the opposite direction.

On to the tool and the options. The current version is intended to work on smaller, intraday timeframes. I recommend using it on 15 minutes or below. I have split the tool into two visual components - an upper study that plots the quarterly divisions, the true opens for each quarter (optional), midnight open (optional) and a label for each new day (optional). There is also an option to show vertical lines for the 6hr quarters vs the 90m quarters (default).

TcII4nJ.png


Please note that the text on the image has been added manually to assist in understanding the intent of the tool.

There are a couple of quirks with how this interacts with TOS. The 'clouds' at the bottom will always have small gaps between them as TOS wants to leave a candle or so space between them. The smaller your selected timeframe, the smaller the gaps appear. Also, because the session day does not actually go until 6pm, I have elected not to put a 'Q4' for the end of the NY session. Would be happy to offer a version with that but it just looks visually off to me. Here is the shared link for the chart exactly as I have shown. I believe the only thing you need to do is minimize the size of your lower indicator:
https://tos.mx/5XbIMfp

The study color scheme is configurable - so you can select whichever 4 colors make the most sense for your charts for the 4 'phases' of the chart. And finally, on to the code:
Upper:
Ruby:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def NYClose = 1630;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("trueOpen", Color.ORANGE);

def isMidnight = SecondsFromTime(Midnight) == 0;
def isOneThirty = SecondsFromTime(oneThirty) == 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree = SecondsFromTime(three) == 0;
def isFourThirty = SecondsFromTime(fourThirty) == 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix = SecondsFromTime(six) == 0;
def isSevenThirty = SecondsFromTime(sevenThirty) == 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine = SecondsFromTime(nine) == 0;
def isTenThirty = SecondsFromTime(tenThirty) == 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon = SecondsFromTime(noon) == 0;
def isThirteenThirty = SecondsFromTime(thirteenThirty) == 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen = SecondsFromTime(fifteen) == 0;
def isNYClose = SecondsFromTime(NYClose) == 0;
def isNYClose2 = SecondsFromTime(NYClose) >= 0;
def isEighteen = SecondsFromTime(eighteen) == 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) == 0;
def isNineteenThirty2 = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) == 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) == 0;
def isTwentyTwoThirty2 = SecondsFromTime(twentyTwoThirty) >= 0;

input show90 = yes;
input showQ2Opens = yes;
input showMidnight = yes;

def midOpen = if isMidnight then open else midOpen[1];
def today = getDay() == getLastDay();
plot midnightLine = if (today and showMidnight) then midOpen else Double.NaN;
midnightLine.setDefaultColor(GlobalColor("divider"));
midnightLine.setPaintingStrategy(PaintingStrategy.DASHES);

def q2Open = if (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty) then open else q2open[1];
plot trueOpenLine = if showQ2Opens and ((isOneThirty2 and !isFourThirty2) OR (isSevenThirty2 and !isTenThirty2) OR (isThirteenThirty2 and !isNYClose2) OR (isNineteenThirty2 and !isTwentyTwoThirty2)) then q2Open else Double.NaN;
trueOpenLine.setDefaultColor(GlobalColor("trueOpen"));

def DayOfWeek = getDayOfWeek(getYyyyMmDd());
input showDays = yes;
AddVerticalLine(show90 and (isMidnight OR isSix OR isNoon), "Q1", GlobalColor("divider"));
AddVerticalLine(isEighteen,"Q1" + if showDays then (if DayOfWeek == 1 then " - Monday" else if DayOfWeek == 2 then " - Tuesday" else if DayOfWeek == 3 then " - Wednesday" else if DayOfWeek == 4 then " - Thursday" else if DayOfWeek == 5 then " - Friday" else "") else "",GlobalColor("divider"));
AddVerticalLine(show90 and (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty), "Q2", GlobalColor("divider"));
AddVerticalLine(show90 and (isThree OR isNine OR isFifteen OR isTwentyOne), "Q3", GlobalColor("divider"));
AddVerticalLine(show90 and (isFourThirty OR isTenThirty OR isTwentyTwoThirty), "Q4", GlobalColor("divider"));

AddVerticalLine(!show90 and isMidnight, "Q1", GlobalColor("divider"));
AddVerticalLine(!show90 and isSix, "Q2", GlobalColor("divider"));
AddVerticalLine(!show90 and isNoon, "Q3", GlobalColor("divider"));
AddVerticalLine(!show90 and isEighteen, "Q4", GlobalColor("divider"));

Lower:
Code:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare lower;
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isEighteen = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) >= 0;

plot divider = 1;
divider.setDefaultColor(Color.BLACK);

# 90m clouds
AddCloud(if (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen and !isNineteenThirty) then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
AddCloud(if (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty and !isTwentyOne) then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
AddCloud(if (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isEighteen) OR (isTwentyOne and !isTwentyTwoThirty) then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
AddCloud(if (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty) then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# 6hr clouds
AddCloud(if isMidnight2 and !isSix2 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
AddCloud(if isSix2 and !isNoon2 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
AddCloud(if isNoon2 and !isEighteen then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
AddCloud(if isEighteen then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));
I have added a couple of things in to the original based on some feedback. By default, it now shows the Q1 (Accumulation) highs and lows for Q2/Q3. These are potential liquidity pools to be ran before the 'real' move happens. In a bearish scenario, we expected the highs from Q1 to be taken out before a move lower - see image below:
xoDosjC.png

Original code and share link have been updated. I have also added in the 6hr and 90m cycle labels as per the image. These are now also activated by default.

I have also added the daily cycles as the lowest quarter on the chart. These are off by default. I'm thinking of adding some time frame logic to activate/deactivate the different levels if you move to higher timeframes.
 
I have added a couple of things in to the original based on some feedback. By default, it now shows the Q1 (Accumulation) highs and lows for Q2/Q3. These are potential liquidity pools to be ran before the 'real' move happens. In a bearish scenario, we expected the highs from Q1 to be taken out before a move lower - see image below:
xoDosjC.png

Original code and share link have been updated. I have also added in the 6hr and 90m cycle labels as per the image. These are now also activated by default.

I have also added the daily cycles as the lowest quarter on the chart. These are off by default. I'm thinking of adding some time frame logic to activate/deactivate the different levels if you move to higher timeframes.
Here is a relatively brief video introducing Quarterly Theory and how it can be utilized in your trading. Enjoy!

By the way, I am working on a higher timeframe version of the indicator that will be more appropriate for swing trading. Should have it done before next weekend.
 
Last edited:
Here is a relatively brief video introducing Quarterly Theory and how it can be utilized in your trading. Enjoy!

By the way, I am working on a higher timeframe version of the indicator that will be more appropriate for swing trading. Should have it done before next weekend.
Alright, I've added the larger timeframe quarters as a separate 'swing' type chart. I recommend using the 1h to 4h timeframe for this one.

reYBIfI.png


Share link: https://tos.mx/mf85Xe7

Ruby:
declare lower;
# HTF Quarterly Breakdown - created by @tony_futures inspired by @traderdaye's concept
declare hide_on_daily;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

plot divider = 1;
divider.setDefaultColor(Color.BLACK);
def DayOfWeek = getDayOfWeek(getYyyyMmDd());
AddCloud(if dayOfWeek == 1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
AddCloud(if dayOfWeek == 2 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
AddCloud(if dayOfWeek == 3 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
AddCloud(if dayOfWeek == 4 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# days of month
# 1-7  1st week
# 8-14  2nd
# 15-21  3rd
# 22-28  4th
def first_week = 1;
def second_week = 7;
def third_week = 14;
def fourth_week = 21;
def last_week = 28;
def daymo = GetDayofMonth( GetYyyyMmDd() );
def weekNumber = if dayOfWeek == 1 and daymo >= first_week and daymo <= second_week then 1 else if dayOfWeek == 1 and daymo > second_week and daymo <= third_week then 2 else if dayOfWeek == 1 and daymo > third_week and daymo <= fourth_week then 3 else if dayOfWeek == 1 and daymo <= last_week then 4 else if dayOfWeek == 1 then 0 else weekNumber[1];
def whichWeek = weekNumber;
AddCloud(if whichWeek == 1 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));
AddCloud(if whichWeek == 2 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
AddCloud(if whichWeek == 3 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
AddCloud(if whichWeek == 4 then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
# ------------------------------------
input showLabels = no;
AddLabel(showLabels and whichWeek == 1, "Weekly Accumulation", GlobalColor("a"));
AddLabel(showLabels and whichWeek == 2, "Weekly Manipulation", GlobalColor("m"));
AddLabel(showLabels and whichWeek == 3, "Weekly Distribution", GlobalColor("d"));
AddLabel(showLabels and whichWeek == 4, "Weekly Reversal/Continuation", GlobalColor("x"));
 
Alright, I've added the larger timeframe quarters as a separate 'swing' type chart. I recommend using the 1h to 4h timeframe for this one.

reYBIfI.png


Share link: https://tos.mx/mf85Xe7

Ruby:
declare lower;
# HTF Quarterly Breakdown - created by @tony_futures inspired by @traderdaye's concept
declare hide_on_daily;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

plot divider = 1;
divider.setDefaultColor(Color.BLACK);
def DayOfWeek = getDayOfWeek(getYyyyMmDd());
AddCloud(if dayOfWeek == 1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
AddCloud(if dayOfWeek == 2 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
AddCloud(if dayOfWeek == 3 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
AddCloud(if dayOfWeek == 4 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# days of month
# 1-7  1st week
# 8-14  2nd
# 15-21  3rd
# 22-28  4th
def first_week = 1;
def second_week = 7;
def third_week = 14;
def fourth_week = 21;
def last_week = 28;
def daymo = GetDayofMonth( GetYyyyMmDd() );
def weekNumber = if dayOfWeek == 1 and daymo >= first_week and daymo <= second_week then 1 else if dayOfWeek == 1 and daymo > second_week and daymo <= third_week then 2 else if dayOfWeek == 1 and daymo > third_week and daymo <= fourth_week then 3 else if dayOfWeek == 1 and daymo <= last_week then 4 else if dayOfWeek == 1 then 0 else weekNumber[1];
def whichWeek = weekNumber;
AddCloud(if whichWeek == 1 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));
AddCloud(if whichWeek == 2 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
AddCloud(if whichWeek == 3 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
AddCloud(if whichWeek == 4 then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
# ------------------------------------
input showLabels = no;
AddLabel(showLabels and whichWeek == 1, "Weekly Accumulation", GlobalColor("a"));
AddLabel(showLabels and whichWeek == 2, "Weekly Manipulation", GlobalColor("m"));
AddLabel(showLabels and whichWeek == 3, "Weekly Distribution", GlobalColor("d"));
AddLabel(showLabels and whichWeek == 4, "Weekly Reversal/Continuation", GlobalColor("x"));

This is such an amazing tool for trading. Thank you soo much!!
 
Last edited by a moderator:
This is such an amazing tool for trading. Thank you soo much!!
I was under the impression that the Quarterly Cycle Theory was applicable to forex trading. Can the sam ebe applied to an Index (such as SPX), ETFs like SOY or QQQ and equities?

Thank you.
 
Glad you like it! I forgot to point out above that the new upper study has an option to turn on lines that show 1/3 ATR and full ATR levels on the charts from the true open lines (which are on by default). You will notice reversals happen around those levels quite a bit. Enjoy!
Any reasons I can't the labels/bubbles to appear for each day; I see the label for THIS week, upper left says Weekly Reversal/Continuation. But I'd love to have each week have a bubble label, like the young man did above our your smaller timeframes. Maybe I can figure it out. Anyways, thank you for your efforts.
 
I was under the impression that the Quarterly Cycle Theory was applicable to forex trading. Can the sam ebe applied to an Index (such as SPX), ETFs like SOY or QQQ and equities?

Thank you.

I only day trade SPY. Obviously its a very volatile ticker no matter time of day but for the most part it does indicate an interesting turning point during the day. I use both version. One for intraday and the other for larger time frame. I would observe it on the equity you'd like and see if it makes sense for your style of trading. It's been a very good indicator for me.
 
Any reasons I can't the labels/bubbles to appear for each day; I see the label for THIS week, upper left says Weekly Reversal/Continuation. But I'd love to have each week have a bubble label, like the young man did above our your smaller timeframes. Maybe I can figure it out. Anyways, thank you for your efforts.
Add this to the bottom of the indicator and you will get the Daily labels. I hadn't included originally b/c they don't change much but here they are for completeness:
Ruby:
AddLabel(showLabels and dayOfWeek == 1, "Daily Accumulation", GlobalColor("a"));
AddLabel(showLabels and dayOfWeek == 2, "Daily Manipulation", GlobalColor("m"));
AddLabel(showLabels and dayOfWeek == 3, "Daily Distribution", GlobalColor("d"));
AddLabel(showLabels and dayOfWeek == 4, "Daily Reversal/Continuation", GlobalColor("x"));
 
I was sent this Notion Workbook that contains a more comprehensive explanation of the theory and what to look for to identify which type of 'quarter' we are currently in or have currently completed. I did not create the documentation but thought I would post in case anyone is interested in the study but not sure what it means. Pretty nice content for those looking to learn more.
 
I was sent this Notion Workbook that contains a more comprehensive explanation of the theory and what to look for to identify which type of 'quarter' we are currently in or have currently completed. I did not create the documentation but thought I would post in case anyone is interested in the study but not sure what it means. Pretty nice content for those looking to learn more.
Amazing code! Would it be possible to have the Q1 lines begin in QA instead of Q2?
 
This one is a bit out there and more in the category of tool then indicator. But I've seen too much confluence around this concept and decided to make something to help visualize it and share with the community. Quarterly Theory is a time-based concept derived from some early ICT work. As far as I am aware, it was coined and outlined by Trader Daye. I am not the author of these concepts and will not be well suited to answer all questions you might have. I suggest you study Daye's twitter to gain more insight. This is purely a graphical aid for traders to be able to quickly determine Daye's Quarterly Cycles, and save Time while on the charts.
I have been inspired to create this tool for TOS by a very clever creator on Twitter (too) who has published a TradingView version here.
I have focused on the link above - the 6hr cycles and the 90m cycles.
These Quarters represent:
  • A - Accumulation (required for a cycle to occur)
  • M - Manipulation
  • D - Distribution
  • X - Reversal/Continuation
They may occur as A/M/D/X OR X/A/M/D. Again, I have focused on the Daily and intraday cycles:

– Daily Cycle:
The Day can be broken down into 6H quarters. These Times roughly define the sessions of the Trading Day, reinforcing the Theory’s validity.
  • Q1 - 18:00 - 00:00, Asian Session
  • Q2 - 00:00 - 06:00, London Session (True Open, Midnight New York Time)
  • Q3 - 06:00 - 12:00, NY Session
  • Q4 - 12:00 - 18:00, PM Session
– 90 Minute Cycle:
Dividing each of the above Daily Quarters into four, we obtain 90 minute quarters. The first one in a Trading Day – 90min Cycles of the Asian Session – follows as an example, in New York Time.
  • Q1 - 18:00 - 19:30
  • Q2 - 19:30 - 21:00 (True Open)
  • Q3 - 21:00 - 22:30
  • Q4 - 22:30 - 00:00
The idea here is that we are using these quarters to anticipate when and where liquidity might be taken before a move in the opposite direction might begin. Add it to your charts and you will be surprised how often in the future and forex markets that a sharp move will happen during the manipulation quarter, only for price to reverse and trend in the opposite direction.

On to the tool and the options. The current version is intended to work on smaller, intraday timeframes. I recommend using it on 15 minutes or below. I have split the tool into two visual components - an upper study that plots the quarterly divisions, the true opens for each quarter (optional), midnight open (optional) and a label for each new day (optional). There is also an option to show vertical lines for the 6hr quarters vs the 90m quarters (default).

TcII4nJ.png


Please note that the text on the image has been added manually to assist in understanding the intent of the tool.

There are a couple of quirks with how this interacts with TOS. The 'clouds' at the bottom will always have small gaps between them as TOS wants to leave a candle or so space between them. The smaller your selected timeframe, the smaller the gaps appear. Also, because the session day does not actually go until 6pm, I have elected not to put a 'Q4' for the end of the NY session. Would be happy to offer a version with that but it just looks visually off to me. Here is the shared link for the chart exactly as I have shown. I believe the only thing you need to do is minimize the size of your lower indicator:
https://tos.mx/ER6in7e

The study color scheme is configurable - so you can select whichever 4 colors make the most sense for your charts for the 4 'phases' of the chart. And finally, on to the code:
Upper:
Ruby:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def NYClose = 1630;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("trueOpen", Color.ORANGE);

def isMidnight = SecondsFromTime(Midnight) == 0;
def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty = SecondsFromTime(oneThirty) == 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree = SecondsFromTime(three) == 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty = SecondsFromTime(fourThirty) == 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix = SecondsFromTime(six) == 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty = SecondsFromTime(sevenThirty) == 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine = SecondsFromTime(nine) == 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty = SecondsFromTime(tenThirty) == 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon = SecondsFromTime(noon) == 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty = SecondsFromTime(thirteenThirty) == 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen = SecondsFromTime(fifteen) == 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isNYClose = SecondsFromTime(NYClose) == 0;
def isNYClose2 = SecondsFromTime(NYClose) >= 0;
def isEighteen = SecondsFromTime(eighteen) == 0;
def isEighteen2 = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) == 0;
def isNineteenThirty2 = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) == 0;
def isTwentyOne2 = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) == 0;
def isTwentyTwoThirty2 = SecondsFromTime(twentyTwoThirty) >= 0;

input show90 = yes;
input showQ2Opens = yes;
input showMidnight = yes;

def midOpen = if isMidnight then open else midOpen[1];
def today = getDay() == getLastDay();
plot midnightLine = if (today and showMidnight) then midOpen else Double.NaN;
midnightLine.setDefaultColor(GlobalColor("divider"));
midnightLine.setPaintingStrategy(PaintingStrategy.DASHES);

def q2Open = if (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty) then open else q2open[1];
plot trueOpenLine = if showQ2Opens and ((isOneThirty2 and !isFourThirty2) OR (isSevenThirty2 and !isTenThirty2) OR (isThirteenThirty2 and !isNYClose2) OR (isNineteenThirty2 and !isTwentyTwoThirty2)) then q2Open else Double.NaN;
trueOpenLine.setDefaultColor(GlobalColor("trueOpen"));

def DayOfWeek = getDayOfWeek(getYyyyMmDd());
input showDays = yes;
AddVerticalLine(show90 and (isMidnight OR isSix OR isNoon), "Q1", GlobalColor("divider"));
AddVerticalLine(isEighteen,"Q1" + if showDays then (if DayOfWeek == 1 then " - Monday" else if DayOfWeek == 2 then " - Tuesday" else if DayOfWeek == 3 then " - Wednesday" else if DayOfWeek == 4 then " - Thursday" else if DayOfWeek == 5 then " - Friday" else "") else "",GlobalColor("divider"));
AddVerticalLine(show90 and (isOneThirty OR isSevenThirty OR isThirteenThirty Or isNineteenThirty), "Q2", GlobalColor("divider"));
AddVerticalLine(show90 and (isThree OR isNine OR isFifteen OR isTwentyOne), "Q3", GlobalColor("divider"));
AddVerticalLine(show90 and (isFourThirty OR isTenThirty OR isTwentyTwoThirty), "Q4", GlobalColor("divider"));

AddVerticalLine(!show90 and isMidnight, "Q1", GlobalColor("divider"));
AddVerticalLine(!show90 and isSix, "Q2", GlobalColor("divider"));
AddVerticalLine(!show90 and isNoon, "Q3", GlobalColor("divider"));
AddVerticalLine(!show90 and isEighteen, "Q4", GlobalColor("divider"));

# 90m clouds
def isQ1 = (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen2 and !isNineteenThirty2);
def isQ2 = (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty2 and !isTwentyOne2);
def isQ3 = (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isNYClose2) OR (isTwentyOne2 and !isTwentyTwoThirty2);
def isQ4 = (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty);

def q1High = if (isMidnight OR isSix OR isNoon OR isEighteen) then high else if isQ1 and high > q1High[1] then high else q1High[1];
def q1Low = if (isMidnight OR isSix OR isNoon OR isEighteen) then low else if isQ1 and low < q1Low[1] then low else q1Low[1];
input showQ1Levels = yes;
plot q1HighLine = if (showQ1Levels and isQ2) OR (showQ1Levels and isQ3) then q1High else Double.NaN;
q1HighLine.setPaintingStrategy(PaintingStrategy.DASHES);
q1HighLine.setDefaultColor(Color.DARK_GRAY);
plot q1LowLine = if (showQ1Levels and isQ2) OR (showQ1Levels and isQ3) then q1Low else Double.NaN;
q1LowLine.setPaintingStrategy(PaintingStrategy.DASHES);
q1LowLine.setDefaultColor(Color.DARK_GRAY);

Lower:
Code:
# Created by @tony_futures inspired by @traderdaye's quarterly theory concept
declare lower;
declare hide_on_daily;
def Midnight = 0000;   #Midnight Open
def oneThirty = 0130;
def three = 0300;
def fourThirty = 0430;
def six = 0600;
def sevenThirty = 0730;
def nine = 0900;
def tenThirty = 1030;
def noon = 1200;
def thirteenThirty = 1330;
def fifteen = 1500;
def eighteen = 1800;
def nineteenThirty = 1930;
def twentyOne = 2100;
def twentyTwoThirty = 2230;

DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

def isMidnight2 = SecondsFromTime(Midnight) >= 0;
def isOneThirty2 = SecondsFromTime(oneThirty) >= 0;
def isThree2 = SecondsFromTime(three) >= 0;
def isFourThirty2 = SecondsFromTime(fourThirty) >= 0;
def isSix2 = SecondsFromTime(six) >= 0;
def isSevenThirty2 = SecondsFromTime(sevenThirty) >= 0;
def isNine2 = SecondsFromTime(nine) >= 0;
def isTenThirty2 = SecondsFromTime(tenThirty) >= 0;
def isNoon2 = SecondsFromTime(noon) >= 0;
def isThirteenThirty2 = SecondsFromTime(thirteenThirty) >= 0;
def isFifteen2 = SecondsFromTime(fifteen) >= 0;
def isEighteen = SecondsFromTime(eighteen) >= 0;
def isNineteenThirty = SecondsFromTime(nineteenThirty) >= 0;
def isTwentyOne = SecondsFromTime(twentyOne) >= 0;
def isTwentyTwoThirty = SecondsFromTime(twentyTwoThirty) >= 0;

plot divider = 1;
divider.setDefaultColor(Color.BLACK);

# 90m clouds
def isQ1 = (isMidnight2 and !isOneThirty2) OR (isSix2 and !isSevenThirty2) OR (isNoon2 and !isThirteenThirty2) OR (isEighteen and !isNineteenThirty);
AddCloud(if isQ1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
def isQ2 = (isOneThirty2 and !isThree2) OR (isSevenThirty2 and !isNine2) OR (isThirteenThirty2 and !isFifteen2) OR (isNineteenThirty and !isTwentyOne);
AddCloud(if isQ2 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
def isQ3 = (isThree2 and !isFourThirty2) OR (isNine2 and !isTenThirty2) OR (isFifteen2 and !isEighteen) OR (isTwentyOne and !isTwentyTwoThirty);
AddCloud(if isQ3 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
def isQ4 = (isFourThirty2 and !isSix2) OR (isTenThirty2 and !isNoon2) OR (isTwentyTwoThirty);
AddCloud(if isQ4 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# 6hr clouds
def isQ2_6 = isMidnight2 and !isSix2;
AddCloud(if isQ2_6 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
def isQ3_6 = isSix2 and !isNoon2;
AddCloud(if isQ3_6 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
def isQ4_6 = isNoon2 and !isEighteen;
AddCloud(if isNoon2 and !isEighteen then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
def isQ1_6 = isEighteen;
AddCloud(if isQ1_6 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));

# 90m labels
input showLabels = yes;
AddLabel(showLabels and isQ1_6, "6hr Accumulation", GlobalColor("a"));
AddLabel(showLabels and isQ2_6, "6hr Manipulation", GlobalColor("m"));
AddLabel(showLabels and isQ3_6, "6hr Distribution", GlobalColor("d"));
AddLabel(showLabels and isQ4_6, "6hr Reversal/Continuation", GlobalColor("x"));
AddLabel(showLabels and isQ1, "90m Accumulation", GlobalColor("a"));
AddLabel(showLabels and isQ2, "90m Manipulation", GlobalColor("m"));
AddLabel(showLabels and isQ3, "90m Distribution", GlobalColor("d"));
AddLabel(showLabels and isQ4, "90m Reversal/Continuation", GlobalColor("x"));

# daily clouds
input showDaily = no;
def DayOfWeek = getDayOfWeek(getYyyyMmDd());
plot divider2 = if showDaily then 0 else Double.NaN;
divider2.setDefaultColor(Color.BLACK);
AddCloud(if showDaily and dayOfWeek == 1 then -1 else Double.NaN, 0, GlobalColor("a"), GlobalColor("a"));
AddCloud(if showDaily and dayOfWeek == 2 then -1 else Double.NaN, 0, GlobalColor("m"), GlobalColor("m"));
AddCloud(if showDaily and dayOfWeek == 3 then -1 else Double.NaN, 0, GlobalColor("d"), GlobalColor("d"));
AddCloud(if showDaily and dayOfWeek == 4 then -1 else Double.NaN, 0, GlobalColor("x"), GlobalColor("x"));
Awesome indicator. Thanks for sharing.

But why don't any lines/squares show for the 4th quarter of the New York PM session?

Alright, I've added the larger timeframe quarters as a separate 'swing' type chart. I recommend using the 1h to 4h timeframe for this one.

reYBIfI.png


Share link: https://tos.mx/mf85Xe7

Ruby:
declare lower;
# HTF Quarterly Breakdown - created by @tony_futures inspired by @traderdaye's concept
declare hide_on_daily;

DefineGlobalColor("divider", Color.WHITE);
DefineGlobalColor("a", Color.DARK_GRAY);
DefineGlobalColor("m", CreateColor(223,83,107));#Color.DARK_RED);
DefineGlobalColor("d", CreateColor(97,208,79));#Color.DARK_GREEN);
DefineGlobalColor("x", CreateColor(34,151,230));#Color.BLUE);

plot divider = 1;
divider.setDefaultColor(Color.BLACK);
def DayOfWeek = getDayOfWeek(getYyyyMmDd());
AddCloud(if dayOfWeek == 1 then 1 else Double.NaN, 2, GlobalColor("a"), GlobalColor("a"));
AddCloud(if dayOfWeek == 2 then 1 else Double.NaN, 2, GlobalColor("m"), GlobalColor("m"));
AddCloud(if dayOfWeek == 3 then 1 else Double.NaN, 2, GlobalColor("d"), GlobalColor("d"));
AddCloud(if dayOfWeek == 4 then 1 else Double.NaN, 2, GlobalColor("x"), GlobalColor("x"));

# days of month
# 1-7  1st week
# 8-14  2nd
# 15-21  3rd
# 22-28  4th
def first_week = 1;
def second_week = 7;
def third_week = 14;
def fourth_week = 21;
def last_week = 28;
def daymo = GetDayofMonth( GetYyyyMmDd() );
def weekNumber = if dayOfWeek == 1 and daymo >= first_week and daymo <= second_week then 1 else if dayOfWeek == 1 and daymo > second_week and daymo <= third_week then 2 else if dayOfWeek == 1 and daymo > third_week and daymo <= fourth_week then 3 else if dayOfWeek == 1 and daymo <= last_week then 4 else if dayOfWeek == 1 then 0 else weekNumber[1];
def whichWeek = weekNumber;
AddCloud(if whichWeek == 1 then 0 else Double.NaN, 1, GlobalColor("a"), GlobalColor("a"));
AddCloud(if whichWeek == 2 then 0 else Double.NaN, 1, GlobalColor("m"), GlobalColor("m"));
AddCloud(if whichWeek == 3 then 0 else Double.NaN, 1, GlobalColor("d"), GlobalColor("d"));
AddCloud(if whichWeek == 4 then 0 else Double.NaN, 1, GlobalColor("x"), GlobalColor("x"));
# ------------------------------------
input showLabels = no;
AddLabel(showLabels and whichWeek == 1, "Weekly Accumulation", GlobalColor("a"));
AddLabel(showLabels and whichWeek == 2, "Weekly Manipulation", GlobalColor("m"));
AddLabel(showLabels and whichWeek == 3, "Weekly Distribution", GlobalColor("d"));
AddLabel(showLabels and whichWeek == 4, "Weekly Reversal/Continuation", GlobalColor("x"));
Good indicator, but I think the true weekly open is incorrect in the upper study. According to the Quarterly Theory, the true weekly open begins on Monday at 18:00 (6:00pm EST). This study has it beginning at New York market open on Tuesday.
 
Amazing code! Would it be possible to have the Q1 lines begin in QA instead of Q2?
If you right-click the study and select 'Edit Sources...' you will see the code. Simply search for "Q1", "Q2", etc and change to whatever you would like. Good luck!
 
Awesome indicator. Thanks for sharing.

But why don't any lines/squares show for the 4th quarter of the New York PM session?


Good indicator, but I think the true weekly open is incorrect in the upper study. According to the Quarterly Theory, the true weekly open begins on Monday at 18:00 (6:00pm EST). This study has it beginning at New York market open on Tuesday.
I'm unsure what you mean about lines/squares for the PM session. There are images above from myself and others showing it there. Maybe send screenshots and I could help you troubleshoot.

And as far as the weekly open, it takes Tuesday's open price (which is Monday at 18:00). Not sure how you are seeing it as Tuesday at 9:30am. If you look at it on an hourly chart (showing extended hours), it clearly begins at 18:00. Maybe you extended hours off and is why it would be completely incorrect. Try that and let me know.
 
Is there anyone who could has turned the 90m, 6hr, Daily & Weekly into upper labels? Having some issues make it happen for some reason.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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