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);