How to add selective cloud?

dmaffo

Member
VIP
Silly question but how to do I add selective cloud?
If I wanted to check mark between different settings inside?

Using ReverseEngineeringMACD.

Inside we have these plots:
plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

If I wanted to choose cloud between only 2 of those how would I write cloud feature on bottom of the code.
Thank you

Here is the default TOS code for ReverseENG.

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

input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;

def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1];
def prevSlowEMA = ExpAverage(price, slowLength)[1];
def prevFastSMA = Average(price, fastLength)[1];
def prevSlowSMA = Average(price, slowLength)[1];
def prevDiff;
def crossDiff;
def denominator;

plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

switch (AverageType) {
case SMA:
crossDiff = slowLength * price[fastLength] - fastLength * price[slowLength];
denominator = slowLength - fastLength;
prevDiff = prevFastSMA - prevSlowSMA;
PMACDlevel = (crossDiff + fastLength * slowLength * (MACDLevel - prevDiff)) / denominator;
if IsNaN(price[1]) {
PMACDeq = Double.NaN;
MA_PMACDeq = Double.NaN;
} else {
PMACDeq = crossDiff / denominator;
MA_PMACDeq = Average(PMACDeq, MACDLength);
}
PMACDsignal = (crossDiff + fastLength * slowLength * (Average(prevDiff, MACDLength - 1) - prevDiff)) / denominator;
case EMA:
crossDiff = prevFastEMA * fastCoeff - prevSlowEMA * slowCoeff;
denominator = fastCoeff - slowCoeff;
prevDiff = prevFastEMA - prevSlowEMA;
PMACDeq = crossDiff / denominator;
PMACDlevel = (MACDLevel - prevDiff + crossDiff) / denominator;
MA_PMACDeq = ExpAverage(PMACDeq, MACDLength);
PMACDsignal = (ExpAverage(prevDiff, MACDLength) - prevDiff + crossDiff) / denominator;
}

PMACDeq.SetDefaultColor(GetColor(1));
MA_PMACDeq.SetDefaultColor(GetColor(8));
PMACDlevel.SetDefaultColor(GetColor(3));
PMACDsignal.SetDefaultColor(GetColor(5));
 
Solution
Silly question but how to do I add selective cloud?
If I wanted to check mark between different settings inside?

Using ReverseEngineeringMACD.

Inside we have these plots:
plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

If I wanted to choose cloud between only 2 of those how would I write cloud feature on bottom of the code.
Thank you

Here is the default TOS code for ReverseENG.

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

input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;

def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1]...
Silly question but how to do I add selective cloud?
If I wanted to check mark between different settings inside?

Using ReverseEngineeringMACD.

Inside we have these plots:
plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

If I wanted to choose cloud between only 2 of those how would I write cloud feature on bottom of the code.
Thank you

Here is the default TOS code for ReverseENG.

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

input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;

def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1];
def prevSlowEMA = ExpAverage(price, slowLength)[1];
def prevFastSMA = Average(price, fastLength)[1];
def prevSlowSMA = Average(price, slowLength)[1];
def prevDiff;
def crossDiff;
def denominator;

plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

switch (AverageType) {
case SMA:
crossDiff = slowLength * price[fastLength] - fastLength * price[slowLength];
denominator = slowLength - fastLength;
prevDiff = prevFastSMA - prevSlowSMA;
PMACDlevel = (crossDiff + fastLength * slowLength * (MACDLevel - prevDiff)) / denominator;
if IsNaN(price[1]) {
PMACDeq = Double.NaN;
MA_PMACDeq = Double.NaN;
} else {
PMACDeq = crossDiff / denominator;
MA_PMACDeq = Average(PMACDeq, MACDLength);
}
PMACDsignal = (crossDiff + fastLength * slowLength * (Average(prevDiff, MACDLength - 1) - prevDiff)) / denominator;
case EMA:
crossDiff = prevFastEMA * fastCoeff - prevSlowEMA * slowCoeff;
denominator = fastCoeff - slowCoeff;
prevDiff = prevFastEMA - prevSlowEMA;
PMACDeq = crossDiff / denominator;
PMACDlevel = (MACDLevel - prevDiff + crossDiff) / denominator;
MA_PMACDeq = ExpAverage(PMACDeq, MACDLength);
PMACDsignal = (ExpAverage(prevDiff, MACDLength) - prevDiff + crossDiff) / denominator;
}

PMACDeq.SetDefaultColor(GetColor(1));
MA_PMACDeq.SetDefaultColor(GetColor(8));
PMACDlevel.SetDefaultColor(GetColor(3));
PMACDsignal.SetDefaultColor(GetColor(5));

You can select an input for a topline and bottomline from the 4 plots for your cloud. You can change the color of the clouds at the input scareen.

Capture.jpg
Ruby:
# TD Ameritrade IP Company, Inc. (c) 2012-2022
#

input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;

def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1];
def prevSlowEMA = ExpAverage(price, slowLength)[1];
def prevFastSMA = Average(price, fastLength)[1];
def prevSlowSMA = Average(price, slowLength)[1];
def prevDiff;
def crossDiff;
def denominator;

plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;

switch (AverageType) {
case SMA:
    crossDiff = slowLength * price[fastLength] - fastLength * price[slowLength];
    denominator = slowLength - fastLength;
    prevDiff = prevFastSMA - prevSlowSMA;
    PMACDlevel = (crossDiff + fastLength * slowLength * (MACDLevel - prevDiff)) / denominator;
    if IsNaN(price[1]) {
        PMACDeq = Double.NaN;
        MA_PMACDeq = Double.NaN;
    } else {
        PMACDeq = crossDiff / denominator;
        MA_PMACDeq = Average(PMACDeq, MACDLength);
    }
    PMACDsignal = (crossDiff + fastLength * slowLength * (Average(prevDiff, MACDLength - 1) - prevDiff)) / denominator;
case EMA:
    crossDiff = prevFastEMA * fastCoeff - prevSlowEMA * slowCoeff;
    denominator = fastCoeff - slowCoeff;
    prevDiff = prevFastEMA - prevSlowEMA;
    PMACDeq = crossDiff / denominator;
    PMACDlevel = (MACDLevel - prevDiff + crossDiff) / denominator;
    MA_PMACDeq = ExpAverage(PMACDeq, MACDLength);
    PMACDsignal = (ExpAverage(prevDiff, MACDLength) - prevDiff + crossDiff) / denominator;
}

PMACDeq.SetDefaultColor(GetColor(1));
MA_PMACDeq.SetDefaultColor(GetColor(8));
PMACDlevel.SetDefaultColor(GetColor(3));
PMACDsignal.SetDefaultColor(GetColor(5));

input showcloud = yes;
input top    = {default PMACDeq, PMACDlevel, MA_PMACDeq, PMACDsignal};
input bottom = {PMACDeq, default PMACDlevel, MA_PMACDeq, PMACDsignal};
def topline;
switch (top){
case PMACDeq:
    topline = PMACDeq;
case PMACDlevel:
    topline = PMACDlevel;
case MA_PMACDeq:
    topline = MA_PMACDeq;
case PMACDsignal:
    topline = PMACDsignal;
}
def bottomline;
switch (bottom){
case PMACDeq:
    bottomline = PMACDeq;
case PMACDlevel:
    bottomline = PMACDlevel;
case MA_PMACDeq:
    bottomline = MA_PMACDeq;
case PMACDsignal:
    bottomline = PMACDsignal;
}
DefineGlobalColor("T", Color.GREEN);
DefineGlobalColor("B", Color.RED);

AddCloud(if !showcloud then Double.NaN else topline, bottomline, GlobalColor("T"), GlobalColor("B"));
 
Solution
When only 2 values in formula I use this:
AddCloud(fastAvg, slowAvg, Color.green, color.red);
But in the rev eng one I am trying to get done there are 4 values and I dont know how to make selective cloud from input menu screen.
 
When only 2 values in formula I use this:
AddCloud(fastAvg, slowAvg, Color.green, color.red);
But in the rev eng one I am trying to get done there are 4 values and I dont know how to make selective cloud from input menu screen.
When only 2 values in formula I use this:
AddCloud(fastAvg, slowAvg, Color.green, color.red);
But in the rev eng one I am trying to get done there are 4 values and I dont know how to make selective cloud from input menu screen.

The part of code was added to your code to allow you to choose what 2 plots can be used to add a cloud. It was in the code provided below the image above. The imputs have a dropdown of choices. Just click on the ones you want to use at each input.

Ruby:
input showcloud = yes;
input top    = {default PMACDeq, PMACDlevel, MA_PMACDeq, PMACDsignal};
input bottom = {PMACDeq, default PMACDlevel, MA_PMACDeq, PMACDsignal};
def topline;
switch (top){
case PMACDeq:
    topline = PMACDeq;
case PMACDlevel:
    topline = PMACDlevel;
case MA_PMACDeq:
    topline = MA_PMACDeq;
case PMACDsignal:
    topline = PMACDsignal;
}
def bottomline;
switch (bottom){
case PMACDeq:
    bottomline = PMACDeq;
case PMACDlevel:
    bottomline = PMACDlevel;
case MA_PMACDeq:
    bottomline = MA_PMACDeq;
case PMACDsignal:
    bottomline = PMACDsignal;
}
DefineGlobalColor("T", Color.GREEN);
DefineGlobalColor("B", Color.RED);

AddCloud(if !showcloud then Double.NaN else topline, bottomline, GlobalColor("T"), GlobalColor("B"));
 
amazing thank you! Havent seen that code before in any other indicator Ive used, so thank you. If i wanted arrows is there a global feature for that too?
 
amazing thank you! Havent seen that code before in any other indicator Ive used, so thank you. If i wanted arrows is there a global feature for that too?

Here is an example of controlling the plot of Arrows through an Input ShowArrows. You can also control the color of the arrows at thee Input screen.

The image shows the arrows limited to the count set at 2.

Capture.jpg
Ruby:
def Data = close crosses above average(close, 8);

input showarrows = {default all, count, none};

#Limiter to only Plot number of Arrows based on Arrowcount
input arrowcount = 2;
def Count    = CompoundValue(1, if data then Count[1] + 1 else Count[1], 0);
def Display  = (HighestAll(Count) - Count) + 1;
#

plot arrow = if showarrows==showarrows.none or showarrows==showarrows.count and display> arrowcount then double.nan else data;
defineGlobalColor("A", color.green);
arrow.setpaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
arrow.setdefaultColor(globalColor("A"));
arrow.setlineWeight(5);
 
Much appreciated but I cant get this to work for some reason. I copied and applied but it doesnt paint like the other arrow scripts. Still playing around with it. Thank you and do admire always everyone here that takes time to help!
 
Much appreciated but I cant get this to work for some reason. I copied and applied but it doesnt paint like the other arrow scripts. Still playing around with it. Thank you and do admire always everyone here that takes time to help!

Here is both up/down arrows that may be more what you were looking to see.. You can control the plots and colors of the arrows at the input screen.

Code:
def Data = if close crosses above Average(close, 8) then 1 else if close crosses below Average(close, 8) then -1 else 0;

input showarrows = {default all, count, none};

#Limiter to only Plot number of Arrows based on Arrowcount
input arrowcount = 2;
def Count    = CompoundValue(1, if Data then Count[1] + 1 else Count[1], 0);
def Display  = (HighestAll(Count) - Count) + 1;
#

DefineGlobalColor("A", Color.GREEN);
DefineGlobalColor("D", Color.RED);

plot arrowup = if showarrows == showarrows.none or showarrows == showarrows.count and Display > arrowcount then Double.NaN else Data == 1;

arrowup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
arrowup.AssignValueColor(if Data == 1 then GlobalColor("A") else GlobalColor("D"));
arrowup.SetLineWeight(5);

plot arrowdn = if showarrows == showarrows.none or showarrows == showarrows.count and Display > arrowcount then Double.NaN else Data == -1;
arrowdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
arrowdn.AssignValueColor(if Data == 1 then GlobalColor("A") else GlobalColor("D"));
arrowdn.SetLineWeight(5);
 
Still cant get these ****ers to show up. I like the indicator and arrows just catches my eye when I chose to not have the clouds on.
I tried even using numerical and up down arrows in input screen. But no arrows show up with script pasted or as mentioned numerical option. I must be missing something really simple. ALL count none no matter what I chose nothing prints.
Thank you
 
Still cant get these ****ers to show up. I like the indicator and arrows just catches my eye when I chose to not have the clouds on.
I tried even using numerical and up down arrows in input screen. But no arrows show up with script pasted or as mentioned numerical option. I must be missing something really simple. ALL count none no matter what I chose nothing prints.
Thank you

I just copied and pasted the above code and it worked. Here is a link https://tos.mx/IBoLxQa to the image below.
Capture.jpg
 

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