RAhul RAJ Out of Range Trade Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DigitalNivesh

//@version=4
study("RAhul RAJ Out of Range Trade Indicator")
averagePeriod = input(30,"Average Period Range")

highValue  = security(syminfo.tickerid, 'D',high)
lowValue  = security(syminfo.tickerid, 'D',low)
openValue  = security(syminfo.tickerid, 'D',open)
closeValue  = security(syminfo.tickerid, 'D',close)
maxAvg = avg((highValue-lowValue),averagePeriod)
minAvg = avg(abs(closeValue-openValue),averagePeriod)
delta = maxAvg-minAvg
plot(maxAvg,color=color.red)
plot(minAvg,color=color.green)
fib = input(1.782,"FIB VALUE")
plot(maxAvg+delta*fib,color=color.blue)
plot(minAvg-delta*fib,color=color.blue)
is_newbar(res) =>
    t = time(res, "0915-1530")
    not na(t) and (na(t[1]) or t > t[1])
    
open_range  = valuewhen(is_newbar('D'), open, 0)
openVal =  security(syminfo.tickerid, '5', open_range)
plot(abs(open_range-close),color=color.yellow)
