Count Minutes from Day Open?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #84531 quote
    margincallcatmargincallcat
    Participant
    Average

    Hello!

    I am trying to figure out how to return the amount of minutes passed from open – but i just cant get a hold of it.

     

    The aim of this code is to retrieve the average minutes passed of each candle when using Tick Charts (just to get q quick hum about timeframe).

     

    Does anyone have a suggestion? This is what ive come up with so far and it gives an OK estimate of average minutes, but would be more precise if i could get the (exact) amount of minutes passed since open.

    defparam drawonlastbaronly=true
    newday=intradaybarindex<intradaybarindex[1]
    
    if newday then
    drawvline(barindex)coloured(200,200,200,50)
    
    opentid=openhour
    
    else
    drawtext("#opentid#",barindex,0.8)coloured(0,200,0)
    closetid=openhour+1
    drawtext("#closetid#",barindex,0.6)coloured(200,0,0)
    
    tid=closetid-opentid
    drawtext("#tid#",barindex,0.4)coloured(0,0,0)
    
    drawtext("-",barindex,0)
    
    tidminuter=tid*60
    drawtext("#tidminuter#",barindex,-0.2)coloured(0,0,0)
    
    idbx=intradaybarindex
    drawtext("#idbx#",barindex,-0.4)
    
    minpertick=(tidminuter/idbx)
    drawtext("#minpertick#",barindex,-0.6)coloured(0,0,0)
    endif
    return

    The “minpertick” is the number im aiming for.

     

    Please note that the y-values have no purpose whatsoever – its just for me to see the “equation”.

     

    THANKS!

    #84534 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Replace empty line 6 with:

    Count = 0

    Then insert before line 25:

    IF OpenMinute <> OpenMinute[1] THEN
       Count = Count + 1
    ENDIF

    Now COUNT will hold the number of minutes fron the start of the new day.

    margincallcat thanked this post
    #84535 quote
    margincallcatmargincallcat
    Participant
    Average

    Wow thanks for a superquick answer a saturday morning! Ill give it a try!

    #84541 quote
    margincallcatmargincallcat
    Participant
    Average

    Unfortunately that did not really work when switching between timeframes – but i managed to get it exactly as how i wanted it now.

     

    Perhaps someone else can benefit from it…

     

    defparam drawonlastbaronly=true
    //---
    Starthour=8
    newcountday=openhour=StartHour and openhour<>openhour[1]
    if newcountday then
    opentid=openhour
    prehours=intradaybarindex
    timeopen=time[1]
    else
    timecurrent=time
    elapsed=(timecurrent-timeopen)
    hourspassed=(openhour-opentid)*10000
    hoursonly=hourspassed/10000
    minelapsed=round((elapsed-hourspassed)/100)
    totmin=(hoursonly*60)+minelapsed
    idbx=intradaybarindex-prehours+1
    minperbar=round(((totmin/idbx)*10))/10
    drawtext("#minperbar#min/bar",barindex,close,dialog,bold,12)coloured(0,0,0)
    //---
    endif
    return

    Regards!

    Viktor

    robertogozzi and Nicolas thanked this post
Viewing 4 posts - 1 through 4 (of 4 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

Count Minutes from Day Open?


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by margincallcatmargincallcat
7 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/10/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...