Dear Users,
I have a script with two conditions. AddChartBubble() works fine on either condition (simply uncomment the AddChartBubble portion in condition 1 or condition2). However, when I combine the two conditions, AddChartBubble() doesn't display anything (see the last 4 lines of the code).
Any tips on how to rectify this problem?
Thank you.
I have a script with two conditions. AddChartBubble() works fine on either condition (simply uncomment the AddChartBubble portion in condition 1 or condition2). However, when I combine the two conditions, AddChartBubble() doesn't display anything (see the last 4 lines of the code).
Any tips on how to rectify this problem?
Thank you.
Code:
declare upper;
input MovAvgType = AverageType.EXPONENTIAL;
####################### CONDITION 1 ##################################
input length = 7;
def na = Double.NaN;
def price0 = (high + low + close * 2) / 4;
def r0 = MovingAverage(MovAvgType, price0, length);
def r1 = stdev(price0, length);
def r2 = (price0 - r0) * 100 / r1;
def r3 = MovingAverage(MovAvgType, r2, length);
def u = MovingAverage(MovAvgType, r3, length);
def d = MovingAverage(MovAvgType, u, length);
def Buy0 = Crosses(u, d, CrossingDirection.ABOVE);
def Sell0 = Crosses(u, d, CrossingDirection.BELOW);
#AddChartBubble(Buy0, low, "LONG0", Color.GREEN, no);
#AddChartBubble(Sell0, high, "SHORT0", Color.MAGENTA, yes);
#################### END OF CONDITION 1 ##############################
####################### CONDITION 2 ############################
input fastlength = 5;
input slowlength = 35;
input MACDlength=10;
def Value = MACD(fastLength, slowLength, MACDLength, MovAvgType).value;
def Avg = MACD(fastLength, slowLength, MACDLength, MovAvgType).Avg;
def Buy1 = value crosses above avg;
def sell1 = value crosses below avg;
#AddChartBubble(Buy1, low-0.01, "LONG1", Color.GREEN, no);
#AddChartBubble(Sell1, high+0.01, "SHORT1", Color.MAGENTA, yes);
#################### END OF CONDITION 2 ##############################
#################### UNIFY CONDITIONs 1 & 2 ###########################
def Buy = Buy0 and Buy1;
def Sell = Sell0 and Sell1;
AddChartBubble(Buy, low-0.015, "LONG", Color.GREEN, no);
AddChartBubble(Sell, high+0.015, "SHORT", Color.MAGENTA, yes);