Having trouble getting an infinite vertical cloud to plot on upper chart

lmk99

Member
VIP
Hi all, I don't understand why this isn't working because I recycled the AddCloud code from another study that I made in which it works correctly:

Code:
def hasbuysignal = if (buysignal1 or buysignal2 or buysignal3 or buysignal4 or buysignal5 or buysignal6 or buysignal7 or buysignal8) then 1 else 0;

def hasbuysignalonlycloud = if (hasbuysignal ==1 and !KBArUp) then Double.POSITIVE_INFINITY else Double.Nan;
AddCloud(hasbuysignalonlycloud, -hasbuysignalonlycloud, Color.WHITE, Color.Black);

Any idea why this wouldn't work?
 

Hguru

Member
Looking for code to make a vertical cloud for the background of the upper chart to turn color at trigger point till next trigger point.

I know the entire background can turn color but I do not want the entire background I want to be able to see the lines for the turns easily

Example:

If I want the background to color at the 8 ema crossing the 21 ema up turn green and stay green till it crosses to the opposite way crossing down and turns red.

so lets say my code creates a trigger we would see green till the code says trigger is over or no trigger yet. so say background is black or white the cloud would show green then no trigger so then normal background of black or white and then trigger so green or red vertical cloud. If that makes sense.

I have seen it so I know it can be done I just cant find that study where I saw it .Thanks
 

SleepyZ

Well-known member
Looking for code to make a vertical cloud for the background of the upper chart to turn color at trigger point till next trigger point.

I know the entire background can turn color but I do not want the entire background I want to be able to see the lines for the turns easily

Example:

If I want the background to color at the 8 ema crossing the 21 ema up turn green and stay green till it crosses to the opposite way crossing down and turns red.

so lets say my code creates a trigger we would see green till the code says trigger is over or no trigger yet. so say background is black or white the cloud would show green then no trigger so then normal background of black or white and then trigger so green or red vertical cloud. If that makes sense.

I have seen it so I know it can be done I just cant find that study where I saw it .Thanks

Try this

Screenshot-2021-08-05-145256.png
Ruby:
plot ema1 = ExpAverage(close, 8);
plot ema2 = ExpAverage(close, 21);
def emaup = ema1 > ema2;

def cond1 = if emaup
          then Double.POSITIVE_INFINITY
          else Double.NEGATIVE_INFINITY;
def cond2 = if !emaup
          then Double.POSITIVE_INFINITY
          else Double.NEGATIVE_INFINITY;
input showclouds = yes;
AddCloud(if showclouds
         then cond1
         else Double.NaN,
         cond2,
         Color.GREEN, Color.RED);
 

SleepyZ

Well-known member
Looking for code to make a vertical cloud for the background of the upper chart to turn color at trigger point till next trigger point.

I know the entire background can turn color but I do not want the entire background I want to be able to see the lines for the turns easily

Example:

If I want the background to color at the 8 ema crossing the 21 ema up turn green and stay green till it crosses to the opposite way crossing down and turns red.

so lets say my code creates a trigger we would see green till the code says trigger is over or no trigger yet. so say background is black or white the cloud would show green then no trigger so then normal background of black or white and then trigger so green or red vertical cloud. If that makes sense.

I have seen it so I know it can be done I just cant find that study where I saw it .Thanks

This will get you a 'spaced' version at the change overs in case that is what you were looking to get.

Ruby:
plot ema1 = ExpAverage(close, 8);
plot ema2 = ExpAverage(close, 21);
def emaup = ema1 > ema2;

input showclouds = yes;
AddCloud(if showclouds and emaup
         then  Double.POSITIVE_INFINITY
         else Double.NaN,
         Double.negative_INFINITY,
         Color.GREEN, Color.green);
AddCloud(if showclouds and !emaup
         then  Double.POSITIVE_INFINITY
         else Double.NaN,
         Double.negative_INFINITY,
         Color.red, Color.RED)
 

Similar threads

Top