Yes, you are right @<span class=”bbp-author-name”>robertogozzi </span>it´s working! I was in the wrong timeframe at the beginning. Therefore i saw nothing. Then i changed your code to plot drawsegments instead of drawhline. Now we have done some progress here.
// Parameters
period = 14 // Look-back period (14 days)
timeStart = 153000 // Start of RTH US (Regular Trading Hours) Adjusted for swedish time.
timeNow = (hour * 10000) + (minute * 100) + second
// Calculate today's opening price
if timeNow = timeStart then
dayOpen = open
endif
// Calculate absolute movement from the Open at each time interval for the past 14 days
moveSum = 0
for i = 1 to period do
if timeNow > timeStart then
prevMove = abs(close[i] / open[i] - 1) // Absolute movement from open
moveSum = moveSum + prevMove
endif
next
// Average movement over the past 14 days
avgMove = moveSum / period
// Calculate Upper and Lower Boundaries
upperBound = dayOpen * (1 + avgMove)
lowerBound = dayOpen * (1 - avgMove)
// Plot the boundaries on the chart
DRAWSEGMENT(barindex - 1, UpperBound, barindex, UpperBound) COLOURED(255, 0, 0) // Red for Upper Bound
DRAWSEGMENT(barindex - 1, LowerBound, barindex, LowerBound) COLOURED(0, 255, 0) // Green for Lower Bound
Return
But, as you see in attached pictures something in the calculation is not correct. In the pics both show the same day, 31 of jan. 2022. from RTH Open 9:30 to close 16:00.
I will try to explain more in detail how i think it should be.
Definition: The Noise Area represents a price zone where the market is considered in balance—no significant demand or supply imbalance is occurring. Outside this area, deviations in price are considered exploitable trends, while within the zone, movements are attributed to market noise, and no trades are made.
Step 1: For each day and time, the absolute move from the RTH OPEN that day is calculated for the last 14 days.
Step 2: The average move over the last 14 days for each time of day is then calculated.
Step 3: The Upper and Lower boundaries of the Noise Area are calculated using the Open price of the current day, adjusted by the average move until that time. Typically, the average intraday movement from
the Open tends to increase over time, peaking at 16:00.
Step4: (Maybe hard to achieve?)To make the evidence of potential imbalances more robust, include the closing from yesterdays RTH close price in
our calculation. This adjustment accounts for overnight gaps, which in themselves often
signal imbalances. For instance, following a gap-down event, the Upper Boundary of the
Noise Area is adjusted upward by a quantity equal to the gap size, and conversely for a
gap-up event, the Lower Boundary is adjusted downward.
With these considerations, the revised mathematical equations for the Upper and Lower Boundaries, including adjustments for overnight gaps, are as follows:
UpperBoundt,HH:MM = max(Opent,9:30, Closet−1,16:00) × (1 + σt,9:30−HH:MM )
LowerBoundt,HH:MM = min(Opent,9:30, Closet−1,16:00) × (1 − σt,9:30−HH:MM )
Hope this helps and make it more clear.
Thanks in advance!