Hi Lordvader,
Since I do not have MS pro ver. I change the question to:
What tomorrow closing price will cause tomorrow RSI crosses the 70 line?
My solution is as follow:
Let u=average increase in the past 14 days including today using Wilder's smoothing method.
d=average decrease in the past 14 days including today using Wilder's smoothing method.
Case 1: Today RSI<70,
Tomorrow to cross 70, price must increase. If tomorrow price increase,
tomorrow 14-day average increase = (14-1)/14*u + 1/14*(c1 - c0)
{c1=tomorrow close, c0=today close}
tomorrow 14-day average decrease= (14-1)/14*d
Tomorrow RSI = ((14-1)/14*u + 1/14*(c1 - c0))/((14-1)/14*u + 1/14*(c1 - c0)+(14-1)/14*d)=70/100
rearrange we have:
c1=((14-1)*(70/100-1)*u+70/100*(14-1)*d+(1-70/100)*c0)/(1-70/100)
Case 2: Today RSI>70,
Tomorrow to cross 70, price must decrease. If tomorrow price decrease,
tomorrow 14-day average increase = (14-1)/14*u
tomorrow 14-day average decrease= (14-1)/14*d + 1/14*(c0-c1)
Tomorrow RSI = ((14-1)/14*u )/((14-1)/14*u +(14-1)/14*d+ 1/14*(c0-c1))=70/100
rearrange we have:
c1=(14-1)*(1-100/70)*u+(14-1)*d+c0
My MS indicator code is as follow:
n:=Input("No. of periods",2,100,14);
y:=Input("RSI level to cross",1,99,70);
x:=y/100;
u:=Max(C-Ref(C,-1),0);
aveu:=Wilders(u,n);
d:=Max(Ref(C,-1)-C,0);
aved:=Wilders(d,n);
xabove:=((n-1)*(x-1)*aveu+(n-1)*x*aved+(1-x)*C)/(1-x);
xbelow:=(n-1)*(1-1/x)*aveu+(n-1)*aved+C;
plot:=If(RSI(C,n)<x,xabove,xbelow);
plot;
I solved this last night before sleep in a hurry and I am a beginner learner of indictor coding. You or any other members please help me to check the solution and coding.