//Version 2.1
//DEFPARAM DrawOnLastBarOnly = true
Timeframe(Daily,UpdateOnClose)
//Timeframe(Hourly,UpdateOnClose)
//ONCE DTE = 15 //15 bars
//ONCE pcUP = 5 //5% each move
//ONCE pcDN = -5
ONCE tUP = 0 //tally
ONCE tDN = 0
//ONCE n = 0 //tally 15-period chunks
//ONCE BarInc = DTE //0/1 = tally ALL big moves even if consecutive, 2...= tally only in chunks
AnchorDate = 20200127 //Date anchor YYYYMMDD format
if date=anchordate then
startbar=barindex
endif
lookback = max(1,barindex-startbar)
if lookback>0 and date>=AnchorDate then
ONCE BarStart = period
if closeVSrange = 1 then
pcMove = 100 * (close - close[period]) / close[period]
elsif closeVSrange = 0 then
pcMove = 100 * (highest[period](high) - lowest[period](low)) / lowest[period](low)
endif
pcMove = 100 * (close - close[DTE]) / close[DTE]
sigma = std[period](pcmove)
pcMoveCorr = pcMove / sigma
pcUPmod = pcUP/sigma
pcDNmod = pcDN/sigma
tUP = 0
tDN = 0
IF BarIndex >= BarStart THEN
for i = 1 to barindex-barstart
if pcMoveCorr[i] > pcUpmod then
tUP = tUP + 1
elsif pcMoveCorr[i] <- pcDnmod then
tDN = tDN + 1
endif
next
PerCentUP = tUP * 100 / (barindex-barstart )//n
PerCentDN = tDN * 100 / (barindex-barstart )//n
endif
endif
RETURN PerCentUP coloured (0,255,0) style (line,2) as "Percent Chance P Moves Up to Target %", PerCentDN coloured (255,0,0) style (line,2) as "Percent Chance P Moves Down to Target %"
//, pcUP/sigma coloured (0,210,0), pcDN/sigma coloured (210,0,0)//t AS "Tally", PerCent as "%"