Afternoon all,
I am not sure if what I have in my head is possible.
Is it possible to capture Price Action over a set time to then use it as a baseline for future analysis.
So for example capture Price Action between 1200 to 1700, get the average of that information, then use this as a baseline to monitor the percentage change against it after 1700.
I have just trialed the below, which kinda works. But rather than have the mid point of high and low of a specific time, how would I average the PA over that time.
//@version=4
study("Baseline", overlay=false)
baselinetime = input("1500-1700", "Baseline", input.session) //set baseline range
blt = time(timeframe.period, baselinetime)
analysisrange = input("1700-2100", "Analysis Range", input.session) //set analysis range
ar = time(timeframe.period, analysisrange)
var highe_01 = 0.0
var lowe_01 = 10e10
if blt
if not blt[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
midpoint = (highe_01+lowe_01)/2
inc = (close - midpoint)//change(close, length)
p = (inc/close)*100
plot(ar ? p : na, title="Percentage Change", color=color.blue, linewidth=2, style=plot.style_linebr)
I hope that makes sense.
##Also what in the code above is stopping it from plotting over the weekend period?##
Update 22/01/2021 @ 20:29
Update the below lines to the below to capture weekend PA
baselinetime = input('1500-1700:1234567', title="Baseline")
analysisrange = input('1700-2100:1234567', title="analysisrange")
Any guidance on the averaging of PA for the 1500 to 1700 would be amazing.
Daniel
question from:
https://stackoverflow.com/questions/65847047/capture-pa-for-a-set-time-then-use-this-as-a-baseline-for-analysis 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…