No of times Price closed inside Initial balance

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #240648 quote
    oyinloyeaoyinloyea
    Participant
    Veteran

    Is it possible to create an indicator that will let me know the number of times price close inside initial balance for a particlar period of time (ie Year , Month)?

    #240651 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    What is an initial balance?

    oyinloyea thanked this post
    #240665 quote
    oyinloyeaoyinloyea
    Participant
    Veteran

    Trading time between 8am and 9am. Thanks

    #240709 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Say the price from 080000 to 090000, today, sits in the range 19000 – 19100, do you want to know how many times, in the past days,  months, years, that price range sat in that same time interval?

    oyinloyea thanked this post
    #240710 quote
    oyinloyeaoyinloyea
    Participant
    Veteran

    Yess Please. Thanks

    #240722 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hi, I don't know if this is useful for you. The indicator shows the number of candles in which the price has moved between 2 levels and at certain times.

    starttime=080000
    endtime=090000
    
    minlevel=20000
    maxlevel=21000
    
    if opentime>=starttime and opentime<=endtime then
    n=n+1
    if close>=minlevel and close<=maxlevel then
    m=m+1
    endif
    endif
    
    return m
    oyinloyea thanked this post
    #240734 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Try this one:

    DEFPARAM DrawOnLastBarOnly = true
    ONCE FromDate = 20240901   //from Sep.  1st, 2024
    ONCE ToDate   = 20241125   //to   Nov. 25th, 2024
    //
    ONCE FromTime = 080000     //from 8am  (candle opening at 8am)
    ONCE ToTime   = 090000     //to   9am  (candle opening at 9am)
    //
    ONCE Tally    = 0
    //
    IF (OpenTime >= FromTime) AND (OpenTime <= ToTime) THEN
       IF (OpenTime = FromTime) OR ((OpenTime > FromTime) AND (OpenTime[1] < FromTime)) OR ((OpenTime > FromTime) AND (IntraDayBarIndex = 0)) THEN
          HH   = High
          LL   = low
          Flag = 0
       ENDIF
       HH = max(HH,high)
       LL = min(LL,low)
    ENDIF
    IF Flag  = 0 AND (OpenTime >= ToTime) THEN
       Flag  = 1
       Tally = 0
       FOR i = (BarIndex - 1) DownTo 0
          IF (OpenDate[i] >= FromDate) AND (OpenDate[i] <= ToDate) THEN
             IF (OpenTime[i] >= FromTime) AND (OpenTime[i] <= ToTime) THEN
                IF (OpenTime[i] = FromTime) OR ((OpenTime[i] > FromTime) AND (OpenTime[i + 1] < FromTime)) OR ((OpenTime[i] > FromTime) AND (IntraDayBarIndex[i] = 0)) THEN
                   HHx   = High[i]
                   LLx   = low[i]
                   Flagx = 0
                ENDIF
                HHx = max(HHx,high[i])
                LLx = min(LLx,low[i])
             ENDIF
             IF Flagx = 0 AND (OpenTime[i] >= ToTime) THEN
                Flagx = 1
                IF (HHx <= HH) AND (LLx >= LL) THEN
                   Tally = Tally + 1
                ENDIF
             ENDIF
          ENDIF
       NEXT
    ENDIF
    DrawText("#Tally# occurrences",BarIndex+10,high+range,Dialog,Bold,10) coloured("Green")
    RETURN

    You can choose the DATE range (a few days, up to several years) and the TIME range.

    Iván González and oyinloyea thanked this post
    #240736 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I am attaching the ITF file.

    Price-Range-indicator.itf
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

No of times Price closed inside Initial balance


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
oyinloyea @oyinloyea Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
1 year, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/22/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...