Enhanced RevEngRSI indicator (extension and alerts)


Active member
This study shows how you can extend any indicator into the expansion area. It also shows how you can add Alerts to your study. These can be confirmed by also showing chart bubbles, but your charts will be cleaner with them off once you are done with this visual debugging aid.


# Enhancements to RevEngRSI study.
# Author: Kory Gill, @korygill

input length = 14;
input price = close;
input rsiValue = 50;
input onExpansion = Yes;
input smoothingType = {default Wilders, EMA};
input showChartBubbles = yes;
input showAlerts = yes;

def coeff = rsiValue / (100 - rsiValue);
def chg = price - price[1];
def diff;
switch (smoothingType) {
case Wilders:
    diff =  (length - 1) * (WildersAverage(Max(-chg, 0), length) * coeff - WildersAverage(Max(chg, 0), length));
case EMA:
    diff =  (length - 1) * (ExpAverage(Max(-chg, 0), length) * coeff - ExpAverage(Max(chg, 0), length)) / 2;

def value = price + if diff >= 0 then diff else diff / coeff;

def nan = double.NaN;
def lastBar = !IsNaN(price) && IsNaN(price[-1]);
def lastClose = if lastBar then value else if onExpansion and IsNaN(price) then lastClose[1] else value;

plot RevEngRSI = compoundValue(1, lastClose, Double.NaN);

RevEngRSI.DefineColor("Up", GetColor(1));
RevEngRSI.DefineColor("Down", GetColor(0));
RevEngRSI.AssignValueColor(if RevEngRSI > RevEngRSI[1] then RevEngRSI.color("Up") else RevEngRSI.color("Down"));

# alerts
def crossAbove = Crosses(price, RevEngRSI, CrossingDirection.ABOVE);
def crossBelow = Crosses(price, RevEngRSI, CrossingDirection.BELOW);

AddChartBubble(showChartBubbles and crossAbove, price, "Cross Above", GetColor(1), yes);
AddChartBubble(showChartBubbles and crossBelow, price, "Cross Below", GetColor(0), no);

Alert(showAlerts and crossAbove, "Cross Above!", Alert.BAR);
Alert(showAlerts and crossBelow, "Cross Below!", Alert.BAR);

Link to the flexible grid and study


Happy trading,
Kory Gill, @korygill


New member
This was not what I was asking. I wanted an expansion with the same slope as the moving average. this expansion is just sideways its not helpful to use it as a trendline


Well-known member
Sounds like you want a deviation from the plot. Or you could plot additional studies and change the inputs.


Active member
From the original question, it was really unclear what he was after, but I think what you post above is probably it @Playstation. Since this indicator is lagging, how is drawing a trend line like this gonna work when on the next bar it will recalculate and change the line? Would be a little more math and some extra calculations to extend the slope of the line, but would also need to know how many bars back to measure that. I have more questions than answers at this point.


Active member
@korygill I think his request was lost in translation from Discord to this forum thread.
@Aliikhatami Maybe you would like to request again what you need?

I was thinking the math may require much ... deep analysis. Probably a price action, maybe X no. of bars back, then calculate the trajectory angle? Maybe I dunno lol, this math is beyond me.

Similar threads