Cloud Proximity Utility Label For ThinkOrSwim

KingsOp

New member
This is a project I've been working on for a few. It is based off of the Ichimoku cloud. I normally only use the cloud itself formed by Span A and Span B. However seeing the cloud all the time on the scree was a bit distracting. I decided to write a utility label that would allow me to be able to know where price action was in relation to the cloud with visual cues as to when PA was getting within a certain distance from the cloud top or bottom, or when in the cloud whether PA was closer to to the top or bottom based off the center of the cloud. This is the result. Currently this displays the price target of cloud top or cloud bottom whether a bullish or bearish cloud formation, as well when in cloud the center point of that cloud. It will also change color depending on relation or price action to the cloud.

Options built in are:
Tenkan period
Kijun Period
Percent distance from cloud top or bottom
color selection for notification

Will be looking to add some conditional plot functionality in future versions


________________________________________________________________________________________________________________________________________________________________________________

# Cloud Proximity Utility Label
# Assembled by TimR of Kings Options LLC in association with TDG
#All rights reserved by TimR
#You do not have permission to share this indicator. Please contact TReid#0007 on Discord for permission.
# Version 1.0

# # <NOTES>
# Based on the Ichimoku System
# This software is licensed for individual use only.
# NOT FOR REDISTRIBUTION PRIVATE/CONFIDENTIAL
# Copyright (c) 2021 Kings Options LLC

input tenkan_period = 9;
input kijun_period = 26;
input Percent = 1.000;
#hint percent: input percent away fromn cloud to be notified visually

def Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
def Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
def "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
def "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
def Chikou = close[-kijun_period];

def bullishcloud = "Span A" > "Span B";
def bearishcloud = "Span B" >= "Span A";

def percentovercloudA = "Span A" + ("Span A" * (Percent / 100));
def percentovercloudB = "Span B" + ("Span B" * (Percent / 100));
def percentundercloudA = "Span A" - ("Span A" * (Percent / 100));


def percentundercloudB = "Span B" - ("Span B" * (Percent / 100));

def Cloudtop = if bullishcloud then "Span A" else if bearishcloud then "Span B" else Double.NaN;
def cloudtoppercent = if bullishcloud then percentovercloudA else if bearishcloud then percentovercloudB else Double.NaN;

def Cloudbottom = if bullishcloud then "Span B" else if bearishcloud then "Span A" else Double.NaN;
def cloudbottompercent = if bullishcloud then percentundercloudB else if bearishcloud then percentundercloudA else Double.NaN;

def condone = (close > cloudtoppercent);
def condtwo = (close >= Cloudtop) and (close <= cloudtoppercent);
def condthree = (close < cloudbottompercent);
def condfour = (close <= Cloudbottom) and (close >= cloudbottompercent);
def Condfive = if bullishcloud then (("Span A" - "Span B") / 2) + "Span B" else if bearishcloud then (("Span B" - "Span A") / 2) + "Span A" else Double.NaN;

AddLabel (yes, if condone then ("Above Cloud: " + Round(Cloudtop, 2))
else if condtwo then ("Cloud Top Close: " + Round(Cloudtop, 2))
else if condthree then ("Below Cloud: " + Round(Cloudbottom, 2))
else if condfour then ("Cloud Btm Close: " + Round(Cloudbottom, 2))
else "In Cloud: " + Condfive,
if condone then GlobalColor("Far Above")
else if condtwo then GlobalColor("Set Percent Above")
else if condthree then GlobalColor("Far Below")
else if condfour then GlobalColor("Set Percent Below")
else GlobalColor("In The Cloud"));

DefineGlobalColor("Far Above", Color.DARK_GREEN);
DefineGlobalColor("Set Percent Above", Color.GREEN);
DefineGlobalColor("Far Below", Color.DARK_RED);
DefineGlobalColor("Set Percent Below", Color.RED);
DefineGlobalColor("In The Cloud", Color.DARK_GRAY);

#hint: This is designed to give you relative positioning to the Ichimoku Cloud for the given chart timeframe. It displays the center of the cloud when price action is inside the cloud so you may know whether you are above or below. It also displays being close to the cloud at a default of 1% away from cloud top or bottom regardless of a bearish or bullish cloud structure. You may change that setting to whatever you deem appropriate. Otherwise beyond that percentage you will be shown the readout for the cloud top if price action is above it or cloud bottom if price action is below.
 
Last edited:

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
330 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