Clouds below the zeroline

PT_Scalper

Member
VIP
Does anyone know how to code the thinkscript clouds to be below a certain point (MACD zeroline in this case)?

I have created this for my visual purposes for the MACD to generate a specific cloud color depending on certain criteria but I cannot figure out and don't know how to code the bottom 4 lines to show the cloud below the zeroline;
AddCloud(value > zeroline and value > value[1] and value > avg, zeroline, Color.GREEN);
AddCloud(value > zeroline and value < value[1] and value > avg, zeroline, Color.cyan);
AddCloud(value > zeroline and value > value[1] and value < avg, zeroline, Color.orange);
AddCloud(value > zeroline and value < value[1] and value < avg, zeroline, Color.red);

AddCloud(value < zeroline and value > value[1] and value > avg, zeroline, Color.GREEN);
AddCloud(value < zeroline and value < value[1] and value > avg, zeroline, Color.cyan);
AddCloud(value < zeroline and value > value[1] and value < avg, zeroline, Color.orange);
AddCloud(value < zeroline and value < value[1] and value < avg, zeroline, Color.red);
If anyone has any ideas, please let me know.

Thanks in advance,
PT_Scalper
 
Does anyone know how to code the thinkscript clouds to be below a certain point (MACD zeroline in this case)?

I have created this for my visual purposes for the MACD to generate a specific cloud color depending on certain criteria but I cannot figure out and don't know how to code the bottom 4 lines to show the cloud below the zeroline;

If anyone has any ideas, please let me know.

Thanks in advance,
PT_Scalper

people, please stop posting partial codes.
it requires others to reconstruct supporting variables and formulas to supply data, to verify an answer.
 
people, please stop posting partial codes.
it requires others to reconstruct supporting variables and formulas to supply data, to verify an answer.

Hi @halcyonguy,

Sorry it's just 8 lines at the end of the standard MACD code;

#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);

plot Diff = Value - Avg;
plot ZeroLine = 0;

plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddCloud(value > zeroline and value > value[1] and value > avg, zeroline, Color.GREEN);
AddCloud(value > zeroline and value < value[1] and value > avg, zeroline, Color.cyan);
AddCloud(value > zeroline and value > value[1] and value < avg, zeroline, Color.orange);
AddCloud(value > zeroline and value < value[1] and value < avg, zeroline, Color.red);

AddCloud(value < zeroline and value > value[1] and value > avg, zeroline, Color.GREEN);
AddCloud(value < zeroline and value < value[1] and value > avg, zeroline, Color.cyan);
AddCloud(value < zeroline and value > value[1] and value < avg, zeroline, Color.orange);
AddCloud(value < zeroline and value < value[1] and value < avg, zeroline, Color.red);
 
Does anyone know how to code the thinkscript clouds to be below a certain point (MACD zeroline in this case)?

I have created this for my visual purposes for the MACD to generate a specific cloud color depending on certain criteria but I cannot figure out and don't know how to code the bottom 4 lines to show the cloud below the zeroline;

If anyone has any ideas, please let me know.

Thanks in advance,
PT_Scalper


you are using boolean expressions as a 0 or 1 for the cloud limits.
if you add a negative sign in front of the expressions AND swap the first 2 parameters, it might work.
addcloud() wants the biggest number first. so it you want a cloud with negative numbers, 0 will have to be first.

i added supporting macd data to drive the clouds

Code:
# macd_cloud_00

declare lower;

def na = double.nan;
input slope_bars = 1;
input min_slope = 0.013;

input macd_fastLength = 12;
input macd_slowLength = 26;
input macd_Length = 9;
input macd_averageType = AverageType.EXPONENTIAL;

def macd_value = MACD(macd_fastLength, macd_slowLength, macd_Length, macd_averageType).value;
def macd_avg = MACD(macd_fastLength, macd_slowLength, macd_Length, macd_averageType).avg;

def zeroline = 0;
def value = macd_value;
def avg = macd_avg;

def a1 = if (value > zeroline and value > value[1] and value > avg) then 1 else na;
def a2 = if (value > zeroline and value < value[1] and value > avg) then 1 else na;
def a3 = if (value > zeroline and value > value[1] and value < avg) then 1 else na;
def a4 = if (value > zeroline and value < value[1] and value < avg) then 1 else na;

AddCloud(a1, zeroline, Color.GREEN);
AddCloud(a2, zeroline, Color.cyan);
AddCloud(a3, zeroline, Color.orange);
AddCloud(a4, zeroline, Color.red);


def b1 = if (value < zeroline and value > value[1] and value > avg) then -1 else na;
def b2 = if (value < zeroline and value < value[1] and value > avg) then -1 else na;
def b3 = if (value < zeroline and value > value[1] and value < avg) then -1 else na;
def b4 = if (value < zeroline and value < value[1] and value < avg) then -1 else na;

AddCloud(zeroline, b1, Color.GREEN);
AddCloud(zeroline, b2, Color.cyan);
AddCloud(zeroline, b3, Color.orange);
AddCloud(zeroline, b4, Color.red);
#

rv90uR0.jpg
 
you are using boolean expressions as a 0 or 1 for the cloud limits.
if you add a negative sign in front of the expressions AND swap the first 2 parameters, it might work.
addcloud() wants the biggest number first. so it you want a cloud with negative numbers, 0 will have to be first.

i added supporting macd data to drive the clouds

Code:
# macd_cloud_00

declare lower;

def na = double.nan;
input slope_bars = 1;
input min_slope = 0.013;

input macd_fastLength = 12;
input macd_slowLength = 26;
input macd_Length = 9;
input macd_averageType = AverageType.EXPONENTIAL;

def macd_value = MACD(macd_fastLength, macd_slowLength, macd_Length, macd_averageType).value;
def macd_avg = MACD(macd_fastLength, macd_slowLength, macd_Length, macd_averageType).avg;

def zeroline = 0;
def value = macd_value;
def avg = macd_avg;

def a1 = if (value > zeroline and value > value[1] and value > avg) then 1 else na;
def a2 = if (value > zeroline and value < value[1] and value > avg) then 1 else na;
def a3 = if (value > zeroline and value > value[1] and value < avg) then 1 else na;
def a4 = if (value > zeroline and value < value[1] and value < avg) then 1 else na;

AddCloud(a1, zeroline, Color.GREEN);
AddCloud(a2, zeroline, Color.cyan);
AddCloud(a3, zeroline, Color.orange);
AddCloud(a4, zeroline, Color.red);


def b1 = if (value < zeroline and value > value[1] and value > avg) then -1 else na;
def b2 = if (value < zeroline and value < value[1] and value > avg) then -1 else na;
def b3 = if (value < zeroline and value > value[1] and value < avg) then -1 else na;
def b4 = if (value < zeroline and value < value[1] and value < avg) then -1 else na;

AddCloud(zeroline, b1, Color.GREEN);
AddCloud(zeroline, b2, Color.cyan);
AddCloud(zeroline, b3, Color.orange);
AddCloud(zeroline, b4, Color.red);
#

rv90uR0.jpg
Absolutely AMAZING work @halcyonguy.

Sorry about the original post...

Regards,
PT_Scalper
 

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