shugParticipant
Average
even managed to draw a satalight dish on my screen lol.
shugParticipant
Average
// ================================================================
// GBM Projection Cone — Ito's Lemma closed-form solution
// S(t) = S0 * EXP( (mu - 0.5*sigma^2)*t + sigma*W(t) )
// Plotted here as E[S(t)] with a +/- K*sigma*sqrt(t) lognormal band
// ================================================================
DEFPARAM DrawOnLastBarOnly = true
// ---------- inputs ----------
Length = 100 // bars of history used to estimate mu and sigma
Horizon = 30 // bars projected into the future
K = 2 // confidence band width, in std devs of ln(S)
// ---------- estimate mu and sigma from log returns ----------
SumR = 0
SumR2 = 0
FOR i = 0 TO Length-1 DO
r = LOG(Close[i]/Close[i+1])
SumR = SumR + r
SumR2 = SumR2 + r*r
NEXT
Mu = SumR/Length
Var = SumR2/Length - Mu*Mu
Sigma = SQRT(MAX(Var,0))
// ---------- draw the projection cone from the current bar ----------
S0 = Close
PrevMed = S0
PrevUp = S0
PrevDn = S0
FOR t = 1 TO Horizon DO
Med = S0 * EXP((Mu - 0.5*Sigma*Sigma)*t)
Up = Med * EXP(K*Sigma*SQRT(t))
Dn = Med * EXP(-K*Sigma*SQRT(t))
DRAWSEGMENT(BarIndex+t-1, PrevMed, BarIndex+t, Med) COLOURED(0,90,200)
DRAWSEGMENT(BarIndex+t-1, PrevUp, BarIndex+t, Up) COLOURED(160,160,160)
DRAWSEGMENT(BarIndex+t-1, PrevDn, BarIndex+t, Dn) COLOURED(160,160,160)
PrevMed = Med
PrevUp = Up
PrevDn = Dn
NEXT
RETURN
shugParticipant
Average
I’m not endorsing any of the above if someone wants to play with it good luck!