ICT NY Session Macros For ThinkOrSwim

Hi,

Here's some code I whipped up to mark the NY session macros using vertical lines. No bells and whistles.

Code:
# ICT Macros

# Futures symbols from: https://www.reddit.com/r/thinkorswim/comments/iee7rv/using_futures_symbols_in_thinkscript/

declare upper;

input show_vertical_lines = yes;

def showem;
# regular futures symbols don't work in custom indicators, so use others from above link
if GetSymbol() == "SPX" {
    showem = show_vertical_lines;
} else if GetSymbol() == "SPY" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/ES:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/MES:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "QQQ" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/NQ:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/MNQ:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "$DXY" {
    showem = show_vertical_lines;
} else {
    showem = !show_vertical_lines;
}

def start1 = 0950;
def end1   = 1010;
def first1 = if SecondsTillTime(start1) == 0 then 1 else 0;
def last1  = if SecondsFromTime(end1) == 0 then 1 else 0;
AddVerticalLine(showem and first1, " 9:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last1, " 10:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start2 = 1050;
def end2   = 1110;
def first2 = if SecondsTillTime(start2) == 0 then 1 else 0;
def last2  = if SecondsFromTime(end2) == 0 then 1 else 0;
AddVerticalLine(showem and first2, " 10:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last2, " 11:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start3 = 1150;
def end3   = 1210;
def first3 = if SecondsTillTime(start3) == 0 then 1 else 0;
def last3  = if SecondsFromTime(end3) == 0 then 1 else 0;
AddVerticalLine(showem and first3, " 11:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last3, " 12:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start4 = 1310;
def end4   = 1340;
def first4 = if SecondsTillTime(start4) == 0 then 1 else 0;
def last4  = if SecondsFromTime(end4) == 0 then 1 else 0;
AddVerticalLine(showem and first4, " 1:10 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last4, " 1:40 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start5 = 1515;
def end5   = 1545;
def first5 = if SecondsTillTime(start5) == 0 then 1 else 0;
def last5  = if SecondsFromTime(end5) == 0 then 1 else 0;
AddVerticalLine(showem and first5, " 3:15 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last5, " 3:45 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def sbstart = 1000;
def sbend   = 1100;
def sbfirst = if SecondsTillTime(sbstart) == 0 then 1 else 0;
def sblast  = if SecondsFromTime(sbend) == 0 then 1 else 0;
AddVerticalLine(showem and sbfirst, " 10:00 SB Begin", Color.LIGHT_GRAY, Curve.FIRM);
AddVerticalLine(showem and sblast, " 11:00 SB End ", Color.LIGHT_GRAY, Curve.FIRM);
 
Hi,

Here's some code I whipped up to mark the NY session macros using vertical lines. No bells and whistles.

Code:
# ICT Macros

# Futures symbols from: https://www.reddit.com/r/thinkorswim/comments/iee7rv/using_futures_symbols_in_thinkscript/

declare upper;

input show_vertical_lines = yes;

def showem;
# regular futures symbols don't work in custom indicators, so use others from above link
if GetSymbol() == "SPX" {
    showem = show_vertical_lines;
} else if GetSymbol() == "SPY" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/ES:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/MES:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "QQQ" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/NQ:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/MNQ:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "$DXY" {
    showem = show_vertical_lines;
} else {
    showem = !show_vertical_lines;
}

def start1 = 0950;
def end1   = 1010;
def first1 = if SecondsTillTime(start1) == 0 then 1 else 0;
def last1  = if SecondsFromTime(end1) == 0 then 1 else 0;
AddVerticalLine(showem and first1, " 9:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last1, " 10:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start2 = 1050;
def end2   = 1110;
def first2 = if SecondsTillTime(start2) == 0 then 1 else 0;
def last2  = if SecondsFromTime(end2) == 0 then 1 else 0;
AddVerticalLine(showem and first2, " 10:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last2, " 11:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start3 = 1150;
def end3   = 1210;
def first3 = if SecondsTillTime(start3) == 0 then 1 else 0;
def last3  = if SecondsFromTime(end3) == 0 then 1 else 0;
AddVerticalLine(showem and first3, " 11:50 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last3, " 12:10 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start4 = 1310;
def end4   = 1340;
def first4 = if SecondsTillTime(start4) == 0 then 1 else 0;
def last4  = if SecondsFromTime(end4) == 0 then 1 else 0;
AddVerticalLine(showem and first4, " 1:10 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last4, " 1:40 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def start5 = 1515;
def end5   = 1545;
def first5 = if SecondsTillTime(start5) == 0 then 1 else 0;
def last5  = if SecondsFromTime(end5) == 0 then 1 else 0;
AddVerticalLine(showem and first5, " 3:15 Start ", Color.GREEN, Curve.MEDIUM_DASH);
AddVerticalLine(showem and last5, " 3:45 End ", Color.ORANGE, Curve.MEDIUM_DASH);


def sbstart = 1000;
def sbend   = 1100;
def sbfirst = if SecondsTillTime(sbstart) == 0 then 1 else 0;
def sblast  = if SecondsFromTime(sbend) == 0 then 1 else 0;
AddVerticalLine(showem and sbfirst, " 10:00 SB Begin", Color.LIGHT_GRAY, Curve.FIRM);
AddVerticalLine(showem and sblast, " 11:00 SB End ", Color.LIGHT_GRAY, Curve.FIRM);
Hello, thank you for providing this script for us TOS users. I usually trade a specific stock $iwm which I've added the script to the chart but no vertical lines are present. I copied the code from words #ict macro to the very bottom, did I do this correctly?
 
Hello, thank you for providing this script for us TOS users. I usually trade a specific stock $iwm which I've added the script to the chart but no vertical lines are present. I copied the code from words #ict macro to the very bottom, did I do this correctly?
The code only works for futures, specifically ES and NQ, and their derivatives since (I think) ICT macros are futures specific. Therefore, this indicator won't work on IWM as is.

To get it to work on IWM, add the following code right before the line of code that says "} else {"

Code:
} else if GetSymbol() == "IWM" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/RTY:XCME" {
    showem = show_vertical_lines;
} else if GetSymbol() == "/M2K:XCME" {
    showem = show_vertical_lines;

Hope this helps.
 

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

Thread starter Similar threads Forum Replies Date
samer800 VWAP Open Session Anchored for ThinkOrSwim Custom 11

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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