Distribution Of Returns

Category: Indicators By: Vonasi Created: May 22, 2019, 9:29 AM
May 22, 2019, 9:29 AM
Indicators
1 Comment

This indicator checks all the candles between the latest one and whatever start date you set (or all of the candles on the chart if you set StartDate to zero) and calculates the rate of return from close to close of each candle. It then counts how many candles returns fit into each specific range (in buckets of 0.25%) from -5% return to +5% return and displays it as a bar chart.

The values above the bars represent the (rounded) percentage of candles whose rate of return fell into that specific range.

The values below the chart indicates rate of return. Each bar represents a 0.25% range  (so 0.0% to 0.25% then 0.25% to 0.5% and so on). The bars at either end of the chart represent returns greater than 5% and returns lower than -5%.

An arrow is shown that represents which group the most recent still forming candles rate of return is in.

Add it as a separate indicator and zoom into the latest candles. Making the indicator full screen also makes it easier to read.

Originally intended for use on daily charts but it can also be used on other time frames. On faster time frames it is of less use as the rate of return of each candle is usually much smaller than the minimum 0.25%.

//Distribution Of Returns Indicator v1.1
//Coded by Vonasi
//Date 20190221

defparam drawonlastbaronly = true

//startdate = 20170101 //Set to zero to analyse all dates.

if opendate >= startdate or startdate = 0 then
dailyreturn = ((close - close[1]) / close[1]) * 100

t = 0

if dailyreturn >= 0 and dailyreturn < 0.25 then
dr025 = dr025 + 1
x = barindex - 20
y = dr025
t = 1
endif

if dailyreturn >= 0.25 and dailyreturn < 0.50 then
dr050 = dr050 + 1
x = barindex - 19
y = dr050
t = 1
endif

if dailyreturn >= 0.50 and dailyreturn < 0.75 then
dr075 = dr075 + 1
x = barindex - 18
y = dr075
t = 1
endif

if dailyreturn >= 0.75 and dailyreturn < 1.00 then
dr100 = dr100 + 1
x = barindex - 17
y = dr100
t = 1
endif

if dailyreturn >= 1 and dailyreturn < 1.25 then
dr125 = dr125 + 1
x = barindex - 16
y = dr125
t = 1
endif

if dailyreturn >= 1.25 and dailyreturn < 1.50 then
dr150 = dr150 + 1
x = barindex - 15
y = dr150
t = 1
endif

if dailyreturn >= 1.50 and dailyreturn < 1.75 then
dr175 = dr175 + 1
x = barindex - 14
y = dr175
t = 1
endif

if dailyreturn >= 1.75 and dailyreturn < 2.00 then
dr200 = dr200 + 1
x = barindex - 13
y = dr200
t = 1
endif

if dailyreturn >= 2.00 and dailyreturn < 2.25 then
dr225 = dr225 + 1
x = barindex - 12
y = dr225
t = 1
endif

if dailyreturn >= 2.25 and dailyreturn < 2.50 then
dr250 = dr250 + 1
x = barindex - 11
y = dr250
t = 1
endif

if dailyreturn >= 2.50 and dailyreturn < 2.75 then
dr275 = dr275 + 1
x = barindex - 10
y = dr275
t = 1
endif

if dailyreturn >= 2.75 and dailyreturn < 3.00 then
dr300 = dr300 + 1
x = barindex - 9
y = dr300
t = 1
endif

if dailyreturn >= 3.00 and dailyreturn < 3.25 then
dr325 = dr325 + 1
x = barindex - 8
y = dr325
t = 1
endif

if dailyreturn >= 3.25 and dailyreturn < 3.50 then
dr350 = dr350 + 1
x = barindex - 7
y = dr350
t = 1
endif

if dailyreturn >= 3.50 and dailyreturn < 3.75 then
dr375 = dr375 + 1
x = barindex - 6
y = dr375
t = 1
endif

if dailyreturn >= 3.75 and dailyreturn < 4.00 then
dr400 = dr400 + 1
x = barindex - 5
y = dr400
t = 1
endif

if dailyreturn >= 4.00 and dailyreturn < 4.25 then
dr425 = dr425 + 1
x = barindex - 4
y = dr425
t = 1
endif

if dailyreturn >= 4.25 and dailyreturn < 4.50 then
dr450 = dr450 + 1
x = barindex - 3
y = dr450
t = 1
endif

if dailyreturn >= 4.50 and dailyreturn < 4.75 then
dr475 = dr475 + 1
x = barindex - 2
y = dr475
t = 1
endif

if dailyreturn >= 4.75 and dailyreturn < 5.00 then
dr500 = dr500 + 1
x = barindex - 1
y = dr500
t = 1
endif

if dailyreturn >= 5.00 then
dr525 = dr525 + 1
x = barindex
y = dr525
t = 1
endif


if dailyreturn < 0 and dailyreturn > -0.25 then
dr025n = dr025n + 1
x = barindex - 22
y = dr025n
t = -1
endif

if dailyreturn <= -0.25 and dailyreturn > -0.50 then
dr050n = dr050n + 1
x = barindex - 23
y = dr050n
t = -1
endif

if dailyreturn <= -0.50 and dailyreturn > -0.75 then
dr075n = dr075n + 1
x = barindex - 24
y = dr075n
t = -1
endif

if dailyreturn <= -0.75 and dailyreturn > -1.00 then
dr100n = dr100n + 1
x = barindex - 25
y = dr100n
t = -1
endif

if dailyreturn <= -1.00 and dailyreturn > -1.25 then
dr125n = dr125n + 1
x = barindex - 26
y = dr125
t = -1
endif

if dailyreturn <= -1.25 and dailyreturn > -1.50 then
dr150n = dr150n + 1
x = barindex - 27
y = dr150n
t = -1
endif

if dailyreturn <= -1.50 and dailyreturn > -1.75 then
dr175n = dr175n + 1
x = barindex - 28
y = dr175n
t = -1
endif

if dailyreturn <= -1.75 and dailyreturn > -2.00 then
dr200n = dr200n + 1
x = barindex - 29
y = dr200n
t = -1
endif

if dailyreturn <= -2.00 and dailyreturn > -2.25 then
dr225n = dr225n + 1
x = barindex - 30
y = dr225n
t = -1
endif

if dailyreturn <= -2.25 and dailyreturn > -2.50 then
dr250n = dr250n + 1
x = barindex - 31
y = dr250n
t = -1
endif

if dailyreturn <= -2.50 and dailyreturn > -2.75 then
dr275n = dr275n + 1
x = barindex - 32
y = dr275n
t = -1
endif

if dailyreturn <= -2.75 and dailyreturn > -3.00 then
dr300n = dr300n + 1
x = barindex - 33
y = dr300n
t = -1
endif

if dailyreturn <= -3.00 and dailyreturn > -3.25 then
dr325n = dr325n + 1
x = barindex - 34
y = dr325n
t = -1
endif

if dailyreturn <= -3.25 and dailyreturn > -3.50 then
dr350n = dr350n + 1
x = barindex - 35
y = dr350n
t = -1
endif

if dailyreturn <= -3.50 and dailyreturn > -3.75 then
dr375n = dr375n + 1
x = barindex - 36
y = dr375n
t = -1
endif

if dailyreturn <= -3.75 and dailyreturn > -4.00 then
dr400n = dr400n + 1
x = barindex - 37
y = dr400n
t = -1
endif

if dailyreturn <= -4.00 and dailyreturn > -4.25 then
dr425n = dr425n + 1
x = barindex - 38
y = dr425n
t = -1
endif

if dailyreturn <= -4.25 and dailyreturn > -4.50 then
dr450n = dr450n + 1
x = barindex - 39
y = dr450n
t = -1
endif

if dailyreturn <= -4.50 and dailyreturn > -4.75 then
dr475n = dr475n + 1
x = barindex - 40
y = dr475n
t = -1
endif

if dailyreturn <= -4.75 and dailyreturn > -5.00 then
dr500n = dr500n + 1
x = barindex - 41
y = dr500n
t = -1
endif

if dailyreturn <= -5.00 then
dr525n = dr525n + 1
x = barindex - 42
y = dr525n
t = -1
endif

total = total + 1

upperline = max(dr025,dr025n) * 1.02
lowerline = 0 - (upperline * 0.02)
endif

dr525perc = round((dr525 / total) * 100)
dr500perc = round((dr500 / total) * 100)
dr475perc = round((dr475 / total) * 100)
dr450perc = round((dr450 / total) * 100)
dr425perc = round((dr425 / total) * 100)
dr400perc = round((dr400 / total) * 100)
dr375perc = round((dr375 / total) * 100)
dr350perc = round((dr350 / total) * 100)
dr325perc = round((dr325 / total) * 100)
dr300perc = round((dr300 / total) * 100)
dr275perc = round((dr275 / total) * 100)
dr250perc = round((dr250 / total) * 100)
dr225perc = round((dr225 / total) * 100)
dr200perc = round((dr200 / total) * 100)
dr175perc = round((dr175 / total) * 100)
dr150perc = round((dr150 / total) * 100)
dr125perc = round((dr125 / total) * 100)
dr100perc = round((dr100 / total) * 100)
dr075perc = round((dr075 / total) * 100)
dr050perc = round((dr050 / total) * 100)
dr025perc = round((dr025 / total) * 100)

dr525nperc = round((dr525n / total) * 100)
dr500nperc = round((dr500n / total) * 100)
dr475nperc = round((dr475n / total) * 100)
dr450nperc = round((dr450n / total) * 100)
dr425nperc = round((dr425n / total) * 100)
dr400nperc = round((dr400n / total) * 100)
dr375nperc = round((dr375n / total) * 100)
dr350nperc = round((dr350n / total) * 100)
dr325nperc = round((dr325n / total) * 100)
dr300nperc = round((dr300n / total) * 100)
dr275nperc = round((dr275n / total) * 100)
dr250nperc = round((dr250n / total) * 100)
dr225nperc = round((dr225n / total) * 100)
dr200nperc = round((dr200n / total) * 100)
dr175nperc = round((dr175n / total) * 100)
dr150nperc = round((dr150n / total) * 100)
dr125nperc = round((dr125n / total) * 100)
dr100nperc = round((dr100n / total) * 100)
dr075nperc = round((dr075n / total) * 100)
dr050nperc = round((dr050n / total) * 100)
dr025nperc = round((dr025n / total) * 100)
dr025nperc = round((dr025n / total) * 100)

drawrectangle(barindex-1,0,barindex,dr525) coloured(0,0,255)
drawrectangle(barindex-2,0,barindex-1,dr500) coloured(0,0,255)
drawrectangle(barindex-3,0,barindex-2,dr475) coloured(0,0,255)
drawrectangle(barindex-4,0,barindex-3,dr450) coloured(0,0,255)
drawrectangle(barindex-5,0,barindex-4,dr425) coloured(0,0,255)
drawrectangle(barindex-6,0,barindex-5,dr400) coloured(0,0,255)
drawrectangle(barindex-7,0,barindex-6,dr375) coloured(0,0,255)
drawrectangle(barindex-8,0,barindex-7,dr350) coloured(0,0,255)
drawrectangle(barindex-9,0,barindex-8,dr325) coloured(0,0,255)
drawrectangle(barindex-10,0,barindex-9,dr300) coloured(0,0,255)
drawrectangle(barindex-11,0,barindex-10,dr275) coloured(0,0,255)
drawrectangle(barindex-12,0,barindex-11,dr250) coloured(0,0,255)
drawrectangle(barindex-13,0,barindex-12,dr225) coloured(0,0,255)
drawrectangle(barindex-14,0,barindex-13,dr200) coloured(0,0,255)
drawrectangle(barindex-15,0,barindex-14,dr175) coloured(0,0,255)
drawrectangle(barindex-16,0,barindex-15,dr150) coloured(0,0,255)
drawrectangle(barindex-17,0,barindex-16,dr125) coloured(0,0,255)
drawrectangle(barindex-18,0,barindex-17,dr100) coloured(0,0,255)
drawrectangle(barindex-19,0,barindex-18,dr075) coloured(0,0,255)
drawrectangle(barindex-20,0,barindex-19,dr050) coloured(0,0,255)
drawrectangle(barindex-21,0,barindex-20,dr025) coloured(0,0,255)

drawrectangle(barindex-22,0,barindex-21,dr025n) coloured(0,0,255)
drawrectangle(barindex-23,0,barindex-22,dr050n) coloured(0,0,255)
drawrectangle(barindex-24,0,barindex-23,dr075n) coloured(0,0,255)
drawrectangle(barindex-25,0,barindex-24,dr100n) coloured(0,0,255)
drawrectangle(barindex-26,0,barindex-25,dr125n) coloured(0,0,255)
drawrectangle(barindex-27,0,barindex-26,dr150n) coloured(0,0,255)
drawrectangle(barindex-28,0,barindex-27,dr175n) coloured(0,0,255)
drawrectangle(barindex-29,0,barindex-28,dr200n) coloured(0,0,255)
drawrectangle(barindex-30,0,barindex-29,dr225n) coloured(0,0,255)
drawrectangle(barindex-31,0,barindex-30,dr250n) coloured(0,0,255)
drawrectangle(barindex-32,0,barindex-31,dr275n) coloured(0,0,255)
drawrectangle(barindex-33,0,barindex-32,dr300n) coloured(0,0,255)
drawrectangle(barindex-34,0,barindex-33,dr325n) coloured(0,0,255)
drawrectangle(barindex-35,0,barindex-34,dr350n) coloured(0,0,255)
drawrectangle(barindex-36,0,barindex-35,dr375n) coloured(0,0,255)
drawrectangle(barindex-37,0,barindex-36,dr400n) coloured(0,0,255)
drawrectangle(barindex-38,0,barindex-37,dr425n) coloured(0,0,255)
drawrectangle(barindex-39,0,barindex-38,dr450n) coloured(0,0,255)
drawrectangle(barindex-40,0,barindex-39,dr475n) coloured(0,0,255)
drawrectangle(barindex-41,0,barindex-40,dr500n) coloured(0,0,255)
drawrectangle(barindex-42,0,barindex-41,dr525n) coloured(0,0,255)

drawtext("#dr525perc#      ",barindex,upperline) coloured(255,0,0)
drawtext("#dr500perc#      ",barindex-1,upperline) coloured(255,0,0)
drawtext("#dr475perc#      ",barindex-2,upperline) coloured(255,0,0)
drawtext("#dr450perc#      ",barindex-3,upperline) coloured(255,0,0)
drawtext("#dr425perc#      ",barindex-4,upperline) coloured(255,0,0)
drawtext("#dr400perc#      ",barindex-5,upperline) coloured(255,0,0)
drawtext("#dr375perc#      ",barindex-6,upperline) coloured(255,0,0)
drawtext("#dr350perc#      ",barindex-7,upperline) coloured(255,0,0)
drawtext("#dr325perc#      ",barindex-8,upperline) coloured(255,0,0)
drawtext("#dr300perc#      ",barindex-9,upperline) coloured(255,0,0)
drawtext("#dr275perc#      ",barindex-10,upperline) coloured(255,0,0)
drawtext("#dr250perc#      ",barindex-11,upperline) coloured(255,0,0)
drawtext("#dr225perc#      ",barindex-12,upperline) coloured(255,0,0)
drawtext("#dr200perc#      ",barindex-13,upperline) coloured(255,0,0)
drawtext("#dr175perc#      ",barindex-14,upperline) coloured(255,0,0)
drawtext("#dr150perc#      ",barindex-15,upperline) coloured(255,0,0)
drawtext("#dr125perc#      ",barindex-16,upperline) coloured(255,0,0)
drawtext("#dr100perc#      ",barindex-17,upperline) coloured(255,0,0)
drawtext("#dr075perc#      ",barindex-18,upperline) coloured(255,0,0)
drawtext("#dr050perc#      ",barindex-19,upperline) coloured(255,0,0)
drawtext("#dr025perc#      ",barindex-20,upperline) coloured(255,0,0)

drawtext("#dr525nperc#      ",barindex-41,upperline) coloured(255,0,0)
drawtext("#dr500nperc#      ",barindex-40,upperline) coloured(255,0,0)
drawtext("#dr475nperc#      ",barindex-39,upperline) coloured(255,0,0)
drawtext("#dr450nperc#      ",barindex-38,upperline) coloured(255,0,0)
drawtext("#dr425nperc#      ",barindex-37,upperline) coloured(255,0,0)
drawtext("#dr400nperc#      ",barindex-36,upperline) coloured(255,0,0)
drawtext("#dr375nperc#      ",barindex-35,upperline) coloured(255,0,0)
drawtext("#dr350nperc#      ",barindex-34,upperline) coloured(255,0,0)
drawtext("#dr325nperc#      ",barindex-33,upperline) coloured(255,0,0)
drawtext("#dr300nperc#      ",barindex-32,upperline) coloured(255,0,0)
drawtext("#dr275nperc#      ",barindex-31,upperline) coloured(255,0,0)
drawtext("#dr250nperc#      ",barindex-30,upperline) coloured(255,0,0)
drawtext("#dr225nperc#      ",barindex-29,upperline) coloured(255,0,0)
drawtext("#dr200nperc#      ",barindex-28,upperline) coloured(255,0,0)
drawtext("#dr175nperc#      ",barindex-27,upperline) coloured(255,0,0)
drawtext("#dr150nperc#      ",barindex-26,upperline) coloured(255,0,0)
drawtext("#dr125nperc#      ",barindex-25,upperline) coloured(255,0,0)
drawtext("#dr100nperc#      ",barindex-24,upperline) coloured(255,0,0)
drawtext("#dr075nperc#      ",barindex-23,upperline) coloured(255,0,0)
drawtext("#dr050nperc#      ",barindex-22,upperline) coloured(255,0,0)
drawtext("#dr025nperc#      ",barindex-21,upperline) coloured(255,0,0)

drawtext("5.0%",barindex-1,lowerline) coloured(255,0,0)
drawtext("4.5%",barindex-3,lowerline) coloured(255,0,0)
drawtext("4.0%",barindex-5,lowerline) coloured(255,0,0)
drawtext("3.5%",barindex-7,lowerline) coloured(255,0,0)
drawtext("3.0%",barindex-9,lowerline) coloured(255,0,0)
drawtext("2.5%",barindex-11,lowerline) coloured(255,0,0)
drawtext("2.0%",barindex-13,lowerline) coloured(255,0,0)
drawtext("1.5%",barindex-15,lowerline) coloured(255,0,0)
drawtext("1.0%",barindex-17,lowerline) coloured(255,0,0)
drawtext("0.5%",barindex-19,lowerline) coloured(255,0,0)

drawtext("-5.0%",barindex-41,lowerline) coloured(255,0,0)
drawtext("-4.5%",barindex-39,lowerline) coloured(255,0,0)
drawtext("-4.0%",barindex-37,lowerline) coloured(255,0,0)
drawtext("-3.5%",barindex-35,lowerline) coloured(255,0,0)
drawtext("-3.0%",barindex-33,lowerline) coloured(255,0,0)
drawtext("-2.5%",barindex-31,lowerline) coloured(255,0,0)
drawtext("-2.0%",barindex-29,lowerline) coloured(255,0,0)
drawtext("-1.5%",barindex-27,lowerline) coloured(255,0,0)
drawtext("-1.0%",barindex-25,lowerline) coloured(255,0,0)
drawtext("-0.5%",barindex-23,lowerline) coloured(255,0,0)

drawtext("%",barindex-42,upperline) coloured(255,0,0)
drawsegment(barindex-21,lowerline-25,barindex-21,upperline+25)COLOURED(0,0,0)

if t = 1 then
drawarrowup(x,y) coloured(0,255,0)
endif

if t = -1 then
drawarrowdown(x,y) coloured(255,0,0)
endif

return upperline*1.05 coloured(0,0,0,0) as "-", -25 coloured(0,0,0,0) as "-"

Download
Filename: Distribution-Of-Returns-v1.1-2.itf
Downloads: 159
Vonasi Master
V-oyaging ON A S-mall I-ncome
Author’s Profile

Comments

Logo Logo
Loading...