Addchartbubble not Showing on chart

british43

Member
I'm not sure what I'm doing wrong but my bubbles are not showing. Can someone please assist thanks.

Code:
declare lower;
input price = close;

def "4%Model" = reference ZigZagPercent(price,10)."ZZ%";
#plot t= "4%Model"*.002;
plot t= "4%Model";
t.SetDefaultColor(GetColor(8));
t.EnableApproximation();

input length = 200;
input length1 = 10;
input displace = 0;
input showBreakoutSignals = no;

#plot AvgExp = ExpAverage(price[-displace], length);
#plot AvgExp1 = ExpAverage(price[-displace], length1);

input displace1 = -5;
input length2 = 16;

plot LowerBand = Lowest(low[-displace1 + 1], length2);
LowerBand.SetDefaultColor(color.yellow);

plot UpperBand = Highest(high[-displace1 + 1], length2);
UpperBand.SetDefaultColor(Color.cyan);

AddChartBubble(t crosses upperband, upperband, "SE", Color.red, no);

AddChartBubble(t crosses lowerBand, lowerband, "LE", Color.green, yes);
 

XeoNoX

Well-known member
VIP
because your probably didn't define correctly what you want the bubble to show, and you didn't explain to us what you want the bubble to show.
 

SleepyZ

Well-known member
I saw what I was doing wrong. Thanks. Is there a way to add date and time in a bubble when EMAs crosses?
You may find this helpful. It does not work on all timeframes as noted in script header.
2021-03-07-TOS-CHARTS.png
Code:
#Example EMA Cross Time Happened
#20171217 Sleepz modified  20210307
#Times seem to work on most intraday rth aggs currently except 4m, 20m and 1hr

input timezone  = {default "ET", "CT", "MT", "PT"};
input rthbegin  = 0930;
input rthend    = 1600;
input labels    = yes;
input timebubbles   = yes;
input datebubbles   = yes;

def CountActive = if SecondsTillTime(rthend) > 0 and SecondsFromTime(rthbegin) >= 0 then 1 else 0;
def StartBar    = if SecondsFromTime(rthbegin) >= 0 and SecondsFromTime(rthbegin) < 2 then 1 else 0;
def BarStart    = if StartBar then BarNumber() else BarStart[1];
def BarCount    = if CountActive then BarNumber() - BarStart else Double.NaN;
def timehr      = if  (GetAggregationPeriod() / 60000 == 4 or GetAggregationPeriod() / 60000 == 20 or GetAggregationPeriod() / 60000 == 60)
                  then Double.NaN
                  else (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) +
                 Round(BarCount / (60 / (GetAggregationPeriod() / 60000)) , 0);
def timemin    = Round(60 * (.5 + (BarCount / 60 * GetAggregationPeriod() / 60000 - (Round(BarCount / 60 * GetAggregationPeriod() / 60000, 0)))), 0);

plot ema1 = ExpAverage(length = 8,  data = close);
plot ema2 = ExpAverage(length = 13, data = close);

def  cond = if Crosses(data1 = ema1, data2 = ema2) then 1 else 0;
def cross = if cond == 1 then Round(close) else cross[1];
def hihr  = if CountActive and cond then  timehr else hihr[1];
def himin = if CountActive and cond then  timemin else himin[1];

plot cross_ = if cond == 1 then close else Double.NaN;

AddLabel(labels, "Last RTH EMA Cross" + " " +
           (AsPrice(GetYYYYMMDD())) + " " +
           (hihr + ":") +
           (if himin < 10
            then "0" + himin + " - " + asdollars(cross)
            else  "" + himin + " - " + asdollars(cross)) , if ema1 > ema2 then Color.GREEN else Color.RED);

AddChartBubble(timebubbles and !IsNaN(timehr) and IsNaN(cross_[1]) and cross_, ema1,
               timehr + ":" + if timemin < 10
                              then "0" + timemin + " - " + asdollars(cross)
                              else "" + timemin + " - " + asdollars(cross), if ema1 > ema2 then Color.GREEN else Color.RED, if ema1 > ema2 then no else yes);
AddChartBubble(datebubbles and !IsNaN(timehr) and IsNaN(cross_[1]) and cross_, ema1,
               AsPrice(GetYYYYMMDD()), Color.GRAY, if ema1 > ema2 then no else yes);
 

Similar threads

Top