aceboogie_11
Member
Whats going on, I am writing a script right now that includes clouds. I am wondering how I can write the script to allow for the clouds to fill with a color when specific criteria is met. This is the script I want the criteria to be macd on 4hr to be above zero and cci above 100, and vise versa for the bottom cloud
Code:
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;
input timeframe = AggregationPeriod.DAY;
input timeframe1 = aggregationperiod.day;
input length1 = 21;
input num_dev_dn1 = -2;
input num_dev_up1 = 2;
def sDev = stdev(data = close(period= timeframe) [-displace], length = length);
def sdev1 = stdev(data = close(period= timeframe1) [-displace], length = length1);
#upper
plot MidLine = MovingAverage(averageType, data = close (period=timeframe)[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
plot MidLine1 = MovingAverage(averageType, data = close (period=timeframe)[-displace], length = length);
plot LowerBand1 = MidLine + num_Dev_Dn1 * sDev1;
plot UpperBand1 = MidLine + num_Dev_Up1 * sDev1;
plot mid = (lowerband1 + lowerband)/2;
plot mid1 = (upperband1 + upperband)/2;
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
addcloud(lowerband,lowerband1,color.gray);
addcloud(upperband1,upperband,color.gray);