Noise area indicator

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #238467 quote
    Bogren
    Participant
    New

    Hi,

     

    Trying to create a ”Noise area indicator” like the one attached in the paper below. I don´t get the calculation for the range done properly. Read it, and look at the attached picture.

    https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4824172

    The most important metrics is as follows.

    We have to mathematically define a region where prices are expected to oscillate under conditions of balanced buying and selling pressures. We refer to this region as the Noise Area, an equilibrium zone where markets do not exhibit any exploitable intraday trend.

    Practically, the market demonstrates a lack of abnormal imbalances when the intraday

    movement from the RTH Open is less than the average movement observed on the same intraday

    time interval over the previous days. We define the Noise Area as the space between

    2 boundaries. These boundaries are time-of-day dependent and are computed using the

    average movements recorded over the previous 14 days.

     

    Thank you!

    Best regards.

    Noise-area-pic.jpg Noise-area-pic.jpg
    #238485 quote
    SnorreDK
    Participant
    Junior

    I asked chatgtp and got this

    // Parameters
    period = 14  // Look-back period (14 days)
    timeStart = 093000  // Start of RTH (Regular Trading Hours)
    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
    drawhline(upperBound, "Upper Bound", color.rgb(0,0,255))  // Blue line for Upper Bound
    drawhline(lowerBound, "Lower Bound", color.rgb(255,0,0))  // Red line for Lower Bound
    
    return 
    
    #238534 quote
    robertogozzi
    Moderator
    Master

    ChatGPT has not a thourogh knowledge of the ProRealTime (also called ProBuilder) language, so it uses some generic instructions assuming most languages have similar instructions (which generally is).

    After a few modification this is the working code:

    // Parameters
    period = 14  // Look-back period (14 days)
    timeStart = 093000  // Start of RTH (Regular Trading Hours)
    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
    drawhline(upperBound) coloured(0,0,255)  // Blue line for Upper Bound
    drawhline(lowerBound) coloured(255,0,0)  // Red line for Lower Bound
     
    return
    #238552 quote
    Bogren
    Participant
    New

    I have tried Chat GPT to. Get some strange results at the beginnning but its get´s better when you use Pro language promts.

    @robertogozzi Unfortunately, can´t see your corrected chat GPT code worked either. I only get a red line around zero on the index both on price or in a new panel.

    Here is my one, but first. I´m not shore the calculation is right. And then i do not get it right when overlay it on a pricechart…

     

    // Noise Area Indicator - Regular Trading Hours Only
    
    // Define parameters
    Length = 14
    
    // Step 1: Track the RTH open price (fixed at 9:30)
    IF (hour = 9 AND minute = 30) THEN
    openRTH = Open[0] // Set the open price at 9:30
    ENDIF
    
    // Step 2: Ensure we are in RTH (Regular Trading Hours)
    IF (hour = 9 AND minute >= 30) OR (hour > 9 AND hour < 16) THEN
    
    // Step 3: Calculate the move in points from the Open for the current bar
    moveToday = ABS(Close - openRTH) // Absolute move in points from 9:30 open
    
    // Step 4: Calculate the average absolute move over the last 14 days in points
    avgMove = 0
    FOR i = 1 TO Length DO
    movePast = ABS(Close[i] - Open[i]) // Calculate the absolute move in points for each of the last 14 days
    avgMove = avgMove + movePast // Sum the moves
    NEXT
    avgMove = avgMove / Length // Average movement in points
    
    // Step 5: Compute the Upper and Lower Boundaries based on points from the open price
    UpperBound = openRTH + avgMove // Upper boundary based on open price
    LowerBound = openRTH - avgMove // Lower boundary based on open price
    
    // Step 6: Plot the Noise Area on the chart, anchored to the open price
    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
    ENDIF
    
    // Step 7: Return values for ProBuilder to plot on the main price chart
    RETURN UpperBound AS "Upper Noise Boundary", LowerBound AS "Lower Noise Boundary"
    #238610 quote
    robertogozzi
    Moderator
    Master

    The code works, as you can see from the attached pic, there are no more errors.

    Probably it doesn’t do what he expected, but that’s another question, as I don’t understand what he wants.

    x-3.jpg x-3.jpg
    #238719 quote
    Bogren
    Participant
    New

    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!

    Noise-area-indicator.jpg Noise-area-indicator.jpg Noise-area-pic2.jpg Noise-area-pic2.jpg
    #238734 quote
    robertogozzi
    Moderator
    Master

    What is RTH?

    #238740 quote
    Bogren
    Participant
    New

    RTH is the US term for Regular Trading Hours.

    #238757 quote
    robertogozzi
    Moderator
    Master

    The first two steps are clear.

    Can you better explain “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“?

    #238770 quote
    Bogren
    Participant
    New

    Step 3 is more a clarification of step 2. Line below is from the source of the original strategy PDF:

    Typically, the average intraday movement from the Open tends to increase over time, peaking at 16:00

    Meaning for example: Take SP500. Say the average range from Open 9:30 to 9:35 is 5 points. It is highly probable thats the average range from Open 9:30 to Close at 16:00 is alot bigger because price has had much longer time to move away and the range is then bigger.

    This is possible to see in the two compared pictures i show in one of the earlier posts showing  your coded noise area that expand around 5-10 points beside the picture of the noise area from the strategy PDF that have a range around 110 points at 16:00. Sure, its hard to say exactly because

    the scale on that picture is not the same but you can see it roughly. Hope it helps.

    #238808 quote
    robertogozzi
    Moderator
    Master

    No, it’s not much clear.

    Let’s begin anew:

    1. what data do you want to be plotted in the highligheted rectangle (attached pic)
    2. hopw is those data related to the previous session?
    3. what is incorrect in the data you plotted?
    x-5.jpg x-5.jpg
    #238818 quote
    Bogren
    Participant
    New

    Okey,

    We try again.

    I want to be able to see the 14 days average move from today’s open 9:30 to any time (depending on bar size) within  regular trading hours drawn by segments on the chart. See my attached picture. Your indicator is in the backround, and i have adjusted that to show 3 day average in the code beacuse its easier when we see everything in the same picture. Thats only for this example.

    I have tried the best i can to explain in the picture. Hopefully its easier to explain there.

    SPTRD-5-minutes-Noise-area.png SPTRD-5-minutes-Noise-area.png
    #238879 quote
    robertogozzi
    Moderator
    Master

    I tried to code this one, but still I don’t know what has the average of the previous 14 periods to do with todays’a average?

    You now introduced another 3-period lookback. Is that the same periods as the 14-periods or an additional lookback period?

    Can you explain what data has to be dealt wit each session that needs to be used in the future sessions?

    What happens at the start of each session?

    What is to be calculated every bar of the new session?

    // Parameters
    ONCE Count  = 0
    period      = 14    // Look-back period (14 days)
    IF BarIndex = 0 THEN
    // initialilize array elelemts
    FOR i = 1 TO period
    $dayMove[i] = 0
    NEXT
    ENDIF
    timeStart = 153000// Start of RTH US (Regular Trading Hours) Adjusted for swedish time
    timeEnd   = 230000// End   of RTH US (Regular Trading Hours) Adjusted for swedish time
    timeNow   = time//(hour * 10000) + (minute * 100) + second
    // Calculate today's opening price
    if timeNow = timeStart then
    dayOpen    = open
    DayTally   = 0
    TodaySmove = 0
    endif
    dayClose   = close
    // Calculate today's opening price
    if timeNow = timeEnd then
    // Calculate absolute movement from the Open at each time interval for the past 14 days
    thisMove = abs(dayClose - dayOpen)
    moveSum  = 0
    Count    = Count + 1
    IF Count > period THEN
    FOR i = period downto 2
    $dayMove[i] = $dayMove[i - 1]
    moveSum     = moveSum + $dayMove[i]
    NEXT
    $dayMove[1] = thisMove
    moveSum     = moveSum + $dayMove[1]
    avgMove     = moveSum / period
    ENDIF
    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
    
    IF Count > period THEN
    if (timeNow >= timeStart) AND (timeNow <= timeEnd) then
    DayTally   = DayTally + 1
    TodaySmove = (TodaySmove + abs(dayClose - dayOpen)) / DayTally
    // Calculate Upper and Lower Boundaries
    upperBound = DayOpen + avgMove + TodaySmove//close * (1 + avgMove)
    lowerBound = DayOpen - avgMove - TodaySmove//close * (1 - avgMove)
     
    // Plot the boundaries on the chart
    DRAWSEGMENT(barindex[1], UpperBound[1], barindex, UpperBound) COLOURED(255, 0, 0) // Red for Upper Bound
    DRAWSEGMENT(barindex[1], LowerBound[1], barindex, LowerBound) COLOURED(0, 255, 0) // Green for Lower Bound
    ENDIF
    ENDIF
    Return
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

Noise area indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bogren @bogren Participant
Summary

This topic contains 12 replies,
has 3 voices, and was last updated by robertogozzi
1 year, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/03/2024
Status: Active
Attachments: 6 files
Logo Logo
Loading...