Highlight Trading Hours In ThinkOrSwim

Mr_Wheeler

Active member
I'm stuck on modifying it to let you select custom colors, but this script's concept has been on my chest for a while now.

https://tos.mx/DA9uwBy

Code:
input premarket_start = 700;
input premarket_end = 930;


def inZone1 = secondsTillTime(premarket_start) <= 0 and secondsTillTime(premarket_end) >= 0;

def highBar1 = if inZone1 then highestAll(high) else double.nan;
def lowBar1 = if inZone1 then lowestAll(low) else double.nan;

input after_market_start = 1600;
input after_market_end = 2000;

def inZone2 = secondsTillTime(after_market_start) <= 0 and secondsTillTime(after_market_end) >= 0;

def highBar2 = if inZone2 then highestAll(high) else double.nan;
def lowBar2 = if inZone2 then lowestAll(low) else double.nan;

addCloud(lowBar1, highBar1, color.green);
addCloud(lowBar2, highBar2, color.red);
 

Attachments

  • sdfdsfdfsfd.png
    sdfdsfdfsfd.png
    298.9 KB · Views: 148
Solution
I'm stuck on modifying it to let you select custom colors, but this script's concept has been on my chest for a while now.

https://tos.mx/DA9uwBy

Code:
input premarket_start = 700;
input premarket_end = 930;


def inZone1 = secondsTillTime(premarket_start) <= 0 and secondsTillTime(premarket_end) >= 0;

def highBar1 = if inZone1 then highestAll(high) else double.nan;
def lowBar1 = if inZone1 then lowestAll(low) else double.nan;

input after_market_start = 1600;
input after_market_end = 2000;

def inZone2 = secondsTillTime(after_market_start) <= 0 and secondsTillTime(after_market_end) >= 0;

def highBar2 = if inZone2 then highestAll(high) else double.nan;
def lowBar2 = if inZone2 then lowestAll(low) else double.nan...
I'm stuck on modifying it to let you select custom colors, but this script's concept has been on my chest for a while now.

https://tos.mx/DA9uwBy

Code:
input premarket_start = 700;
input premarket_end = 930;


def inZone1 = secondsTillTime(premarket_start) <= 0 and secondsTillTime(premarket_end) >= 0;

def highBar1 = if inZone1 then highestAll(high) else double.nan;
def lowBar1 = if inZone1 then lowestAll(low) else double.nan;

input after_market_start = 1600;
input after_market_end = 2000;

def inZone2 = secondsTillTime(after_market_start) <= 0 and secondsTillTime(after_market_end) >= 0;

def highBar2 = if inZone2 then highestAll(high) else double.nan;
def lowBar2 = if inZone2 then lowestAll(low) else double.nan;

addCloud(lowBar1, highBar1, color.green);
addCloud(lowBar2, highBar2, color.red);

The use of Global coloring should help.

In the image, the 2 parts of addcloud colors are set to be green and red for the 2 cloud periods. The image shows the selection of cyan and magenta at the input screen.

Screenshot 2023-07-23 062020.jpg

Code:
input premarket_start = 700;
input premarket_end = 930;


def inZone1 = SecondsTillTime(premarket_start) <= 0 and SecondsTillTime(premarket_end) >= 0;

def highBar1 = if inZone1 then HighestAll(high) else Double.NaN;
def lowBar1 = if inZone1 then LowestAll(low) else Double.NaN;

input after_market_start = 1600;
input after_market_end = 2000;

def inZone2 = SecondsTillTime(after_market_start) <= 0 and SecondsTillTime(after_market_end) >= 0;

def highBar2 = if inZone2 then HighestAll(high) else Double.NaN;
def lowBar2 = if inZone2 then LowestAll(low) else Double.NaN;

DefineGlobalColor("PRE", Color.GREEN);
DefineGlobalColor("AFTER", Color.RED);

AddCloud(lowBar1, highBar1, GlobalColor("PRE"), GlobalColor("PRE") );
AddCloud(lowBar2, highBar2, GlobalColor("AFTER"), GlobalColor("AFTER") );
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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