 # RSI wilders relationship to current price

##### New member
Hello, I'm new to the forum. I base a lot of my trades off extended RSI levels ( to the up or downside ) when they come in contact with Fibonacci levels. I scale in and try to average my price as close to the current price when the RSI recovers (returns above/below 30 or 70). Right now I am guessing how much farther the price will move before the reversal. Does anyone know how to calculate for example: If the RSI went from 30 down to 12, the price of the stock at 30 RSI is \$20, what would the price be when the RSI is 12? I'm trying to make my entries more precise. Does anyone know how to calculate this. I would love to have a chart that calculates this in TOS. Thanks in advance

##### New member
I guess to simplify the question, has anyone created a RS (relative strength) type average for real time use. RS = (Avg Gain)/(Avg Loss) for 14 day period on a stock.

##### New member
I believe I found the average to use to covert from a scale of 0 to 100 to the real price. I have averaging to points and dividing by 100 and multiplying the unknown distance on the RSI. It seems to be getting me close to the conversion. Here is the average i'm using which I found in the stock TOS RSI code:

Code:
``````declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price, length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

plot TC = TotChgAvg / 100;``````

Any input would be appreciated or tell me to F off. Thanks

#### diazlaz

2019 Donor
VIP

##### New member
Thanks for the reply, but I don't think the MACD is related to my RSI question. I think I figured out the math some what. The RSI is on a scale of 0 to 100. TotChgAvg = MovingAverage(averageType, AbsValue(price - price), length); part of TOS RSI calulation, I believe is the difference in price from one bar to the next over 14 days. To find the what each tick of the RSI's is worth in \$USD for a particular stock on a scale of 1 to 100, I took the absValue of the RSI and subtracted the distance from 80 wilder and then multiplied by the TotChgAvg. The figure I get seems pretty accurate It is just a decimal off. I hope this helps. If you are looking to time your entries when the RSI goes past 70 or 30, now you can try to calculate how many cents the price of will go to reach for example 80 or 20 wilder. I'm surprised TOS does not include this, this seem very very important for anyone trying to trade with the RSI indicator for precise trend reversal plays. I know the algo's we are trading against have it all figured out. Again if my math needs adjusting or anybody has any thoughts on this feel free to reply. Below is a simple graph I created to use.

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price, length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSICurVal = 50 * (ChgRatio + 1) - 85 ;
def RSI = 50 * (ChgRatio + 1);

plot RS = TotChgAvg * absValue(RSI - 80);

Last edited:

#### diazlaz

##### Well-known member
2019 Donor
VIP
look at the tos study ReverseEngineeringRSI

##### New member
Thanks diazlaz that was exactly what I was looking for. I figured it was included in TOS

#### sample

##### New member

Code:
``````#RevesedEngineeredRSI_Upper_Lowerbands mod by LAR
input length = 11;
input price = close;
input rsiValue = 65.0;
input smoothingType = {default Wilders, EMA};

def coeff = rsiValue / (100 - rsiValue);
def chg = price - price;
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;
plot RevEngRSI = compoundValue(1, value, Double.NaN);

RevEngRSI.SetDefaultColor(Color.BLACK);

input rsiValue1 = 35.0;

def coeff1 = rsiValue1 / (100 - rsiValue1);
def chg1 = price - price;
def diff1;
switch (smoothingType) {
case Wilders:
diff1 =  (length - 1) * (WildersAverage(Max(-chg1, 0), length) * coeff1 - WildersAverage(Max(chg1, 0), length));
case EMA:
diff1 =  (length - 1) * (ExpAverage(Max(-chg1, 0), length) * coeff1 - ExpAverage(Max(chg1, 0), length)) / 2;
}

def value1 = price + if diff1 >= 0 then diff1 else diff1 / coeff1;
plot RevEngRSI1 = compoundValue(1, value1, Double.NaN);

RevEngRSI1.SetDefaultColor(Color.BLACK);

input rsiValue2 = 50.0;
input smoothingType2 = {default Wilders, EMA};

def coeff2 = rsiValue2 / (100 - rsiValue2);
def chg2 = price - price;
def diff2;
switch (smoothingType2) {
case Wilders:
diff2 =  (length - 1) * (WildersAverage(Max(-chg2, 0), length) * coeff2 - WildersAverage(Max(chg2, 0), length));
case EMA:
diff2 =  (length - 1) * (ExpAverage(Max(-chg2, 0), length) * coeff2 - ExpAverage(Max(chg2, 0), length)) / 2;
}

def value2 = price + if diff2 >= 0 then diff2 else diff2 / coeff2;
plot RevEngRSI2 = compoundValue(1, value2, Double.NaN);

RevEngRSI2.SetDefaultColor(Color.BLACK);