In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.
//Coded by CapnOscar on 16.04.2015 - Say Thanks? study(title="MyTrend", shorttitle="MyTrend", overlay=true) picktf = input(title="Pick TimeFrame", type=resolution, defval="30") previous_close = security(tickerid, picktf,close) previous_open = security(tickerid, picktf,open) cur_open = security(tickerid, picktf,open) previous_high = security(tickerid, picktf,high) previous_low = security(tickerid, picktf,low) cur_high = security(tickerid, picktf,high) cur_low = security(tickerid, picktf,low) D = (cur_high - cur_low) Q = (previous_high - previous_low) P = (previous_high + previous_low + previous_close) / 3 R1 = (2*P)-previous_low S1 = (2*P)-previous_high R2 = P+(previous_high - previous_low) S2 = P-(previous_high - previous_low) rsic = close > P ? green : close < P ? red : orange pv = plot(P, color=rsic, linewidth=3) plr1 = plot(R1, color=silver) plr2 = plot(R2, color=gray) pls1 = plot(S1, color=silver) pls2 = plot(S2, color=gray)