My bubbles are all over the place instead of being placed above or below candles.

Mr_Wheeler

Active member
This is a momentum indicatos. I'm trying eliminate candle bias by going with white candles, I'm not sure if this a good system but I try to constantly refine my setup. I'm having trouble as the bubbles aren't being projected above the candles. Would you please help me out?




Code:
# avgs_per_diff_00

declare lower;

input avg1Type = Averagetype.simple;
input avg2type = Averagetype.simple;
input Avg1Length = 9;
input Avg2Length = 50;

def avg1 = MovingAverage(avg1Type, close, avg1Length);
def avg2 = MovingAverage(avg2Type, close, avg2Length);
def avgup = (avg1 > avg2);

#def AvgPercent = MovingAverage(avg1Type, close, avg1Length)-MovingAverage(avg2Type, close, avg2Length);
# plot percentDiff = (absValue(avgPercent)/movingaverage(avg1type,close,avg1length)) *100;

def Avg12diff = avg1 - avg2;

plot percentDiff = (absValue(avg12diff)/avg1) *100;
percentDiff.DefineColor("Up", (CreateColor(116, 189, 232)));
percentDiff.DefineColor("Down", color.WHITE);
percentDiff.AssignValueColor(if avgup then percentDiff.color("up") else percentDiff.color("down"));

plot ZeroLine = 0;

#addchartbubble(1,0, avg1 + "\n" + avg2 + "\n" + avg12diff, color.cyan, no);


######################################################################
######################################################################
######################################################################


def yyyyMmDd = getYyyyMmDd();
def session_duration_minutes = (regularTradingEnd(yyyyMmDd) - regularTradingStart(yyyyMmDd)) / AggregationPeriod.MIN;
def interval_size_raw;
def agg  = getAggregationPeriod();
if (agg == AggregationPeriod.DAY) {
    interval_size_raw = session_duration_minutes * 60;
} else if (agg == AggregationPeriod.THREE_DAYS) {
    interval_size_raw = session_duration_minutes * 60 * 3;
} else if (agg == AggregationPeriod.WEEK) {
    interval_size_raw = session_duration_minutes * 60 * 5;
} else if (agg == AggregationPeriod.MONTH or agg == AggregationPeriod.OPT_EXP) {
    interval_size_raw = session_duration_minutes * 60 * 22;
} else if (agg >= AggregationPeriod.MIN) {
    interval_size_raw = agg / AggregationPeriod.MIN;
} else {
    interval_size_raw = agg;
}

##########################################################



def cclose = close(period = agg);
def oopen  = open(period = agg);
def hhigh  = high(period = agg);
def llow   = low(period = agg);
# ########################################################
input smaLength = 40;
def limit = 30;
def AbsHighClose = AbsValue(hhigh - cclose[1]);
def AbsLowClose = AbsValue(llow - cclose[1]);
def AbsCloseOpen = AbsValue(cclose[1] - oopen[1]);
def K = If(AbsHighClose >= AbsLowClose, AbsHighClose, AbsLowClose);
def R = If(AbsHighClose >= AbsLowClose,
        If(AbsHighClose >= (hhigh - llow), AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen),
        If(AbsLowClose >= (hhigh - llow),  AbsLowClose - 0.5 * AbsHighClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen));
def nRes = If(R != 0,
            (50 * (((cclose - cclose[1]) + 0.50 * (cclose - oopen) + 0.25 * (cclose[1] - oopen[1])) / R ) * K / limit) + if !IsNaN(nRes[1]) then nRes[1] else 0,
            0 + if !IsNaN(nRes[1]) then nRes[1] else 0);
def ASI = nRes;
def sma = SimpleMovingAvg(ASI,smaLength);


###########################

#plot Numbers = round(ASI);
#numbers.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);


def momentum = round(ASI);

plot static = momentum;
static.AssignValueColor(color.white);
AddChartBubble(static, high, round(ASI), Color.white, no);

##########################

input barcount = 19;

#NumberS.AssignvalueColor(if IsDescending(close, barcount) then Color.white else Color.green);

7BtxQPm.png
 
Solution
I haven't checked the code, but looks like your left axis is showing, and it looks like you're mixing declare lower with the upper price subgraph. That'll usually cause this type of issue. If not, I can take a deeper look into it.
I haven't checked the code, but looks like your left axis is showing, and it looks like you're mixing declare lower with the upper price subgraph. That'll usually cause this type of issue. If not, I can take a deeper look into it.
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I haven't checked the code, but looks like your left axis is showing, and it looks like you're mixing declare lower with the upper price subgraph. That'll usually cause this type of issue. If not, I can take a deeper look into it.

That seems to have done it, now I'll work on moving the bubbles up and down candles. Thank you for your help, hope you have a nice day.
 
Code:
def momentum = round(ASI);

plot static = momentum;
static.AssignValueColor(color.white);
AddChartBubble(static, low, round(ASI), Color.white, no);

Code:
# avgs_per_diff_00

#declare lower;

input avg1Type = Averagetype.simple;
input avg2type = Averagetype.simple;
input Avg1Length = 9;
input Avg2Length = 50;

def avg1 = MovingAverage(avg1Type, close, avg1Length);
def avg2 = MovingAverage(avg2Type, close, avg2Length);
def avgup = (avg1 > avg2);

#def AvgPercent = MovingAverage(avg1Type, close, avg1Length)-MovingAverage(avg2Type, close, avg2Length);
# plot percentDiff = (absValue(avgPercent)/movingaverage(avg1type,close,avg1length)) *100;

def Avg12diff = avg1 - avg2;

plot percentDiff = (absValue(avg12diff)/avg1) *100;
percentDiff.DefineColor("Up", (CreateColor(116, 189, 232)));
percentDiff.DefineColor("Down", color.WHITE);
percentDiff.AssignValueColor(if avgup then percentDiff.color("up") else percentDiff.color("down"));

plot ZeroLine = 0;


######################################################################
######################################################################
######################################################################


def yyyyMmDd = getYyyyMmDd();
def session_duration_minutes = (regularTradingEnd(yyyyMmDd) - regularTradingStart(yyyyMmDd)) / AggregationPeriod.MIN;
def interval_size_raw;
def agg  = getAggregationPeriod();
if (agg == AggregationPeriod.DAY) {
    interval_size_raw = session_duration_minutes * 60;
} else if (agg == AggregationPeriod.THREE_DAYS) {
    interval_size_raw = session_duration_minutes * 60 * 3;
} else if (agg == AggregationPeriod.WEEK) {
    interval_size_raw = session_duration_minutes * 60 * 5;
} else if (agg == AggregationPeriod.MONTH or agg == AggregationPeriod.OPT_EXP) {
    interval_size_raw = session_duration_minutes * 60 * 22;
} else if (agg >= AggregationPeriod.MIN) {
    interval_size_raw = agg / AggregationPeriod.MIN;
} else {
    interval_size_raw = agg;
}

##########################################################



def cclose = close(period = agg);
def oopen  = open(period = agg);
def hhigh  = high(period = agg);
def llow   = low(period = agg);
# ########################################################
input smaLength = 40;
def limit = 30;
def AbsHighClose = AbsValue(hhigh - cclose[1]);
def AbsLowClose = AbsValue(llow - cclose[1]);
def AbsCloseOpen = AbsValue(cclose[1] - oopen[1]);
def K = If(AbsHighClose >= AbsLowClose, AbsHighClose, AbsLowClose);
def R = If(AbsHighClose >= AbsLowClose,
        If(AbsHighClose >= (hhigh - llow), AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen),
        If(AbsLowClose >= (hhigh - llow),  AbsLowClose - 0.5 * AbsHighClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen));
def nRes = If(R != 0,
            (50 * (((cclose - cclose[1]) + 0.50 * (cclose - oopen) + 0.25 * (cclose[1] - oopen[1])) / R ) * K / limit) + if !IsNaN(nRes[1]) then nRes[1] else 0,
            0 + if !IsNaN(nRes[1]) then nRes[1] else 0);
def ASI = nRes;
def sma = SimpleMovingAvg(ASI,smaLength);


###########################

#plot Numbers = round(ASI);
#numbers.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);


def momentum = round(ASI);

plot static = momentum;
static.AssignValueColor(color.white);
AddChartBubble(static, low, round(ASI), Color.white, no);

##########################

input barcount = 19;

#NumberS.AssignvalueColor(if IsDescending(close, barcount) then Color.white else Color.green);


I changed it from "high" to "low". Now it looks great.

fCAvjjY.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
347 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