Time Segmented Volume by Worden Brothers code

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #149577 quote
    al_craig
    Participant
    New

    Evening All,

    Amazing work on creating this site! Absolutely love it. I was wondering if anyone has the code for Time Segmented Volume that Worden Brothers produced?

    any help gratefully received 🙂

    #149591 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // TSV Time Segmented Volume indicator
    //
    // --------------------------------------------------------------------------------------
    // 13 = number of daily HALF HOURS
    //  7 = ????
    // --------------------------------------------------------------------------------------
    //      Example Settings:
    // Short Term Trading       :  TSV period between  9 and 12
    // Intermediate Term Trading:  TSV period between 18 and 25
    // Long Term Trading        :  TSV period between 35 and 45
    //
    // --------------------------------------------------------------------------------------
    //ONCE p1    = 13
    //ONCE p2    = 7
    //ONCE Mtype = 0
    p1           = max(1,min(999,p1))
    p2           = max(1,min(999,p2))
    Mtype        = max(0,min(6,Mtype))
    MyVol = 0
    IF close > close[1] THEN
       MyVol = volume * (close - close[1])
    ELSIF close < close[1] THEN
       MyVol = -volume * (close - close[1])
    ENDIF
    TSV    = summation[p1](MyVol)
    Signal = average[p2,Mtype](TSV)
    RETURN TSV AS "Tsv",Signal AS "Signal"
    x.jpg x.jpg TSV-Time-Segmented-Volume.itf
    #149595 quote
    al_craig
    Participant
    New

    Thank you very much Roberto.

    Much appreciated

    #149597 quote
    al_craig
    Participant
    New

    I am currently using balance of power which would work really well hand in hand with TSV. I can run them side by side but I would love to be build TSV onto my balance of power indicator.

    Do you think this could be done?

    thanks again for your support.

    Regards

    Alastair

    #149599 quote
    robertogozzi
    Moderator
    Master

    What code do you use as balance of power ?

    #149600 quote
    al_craig
    Participant
    New

    It is the BOP from Nicholas I believe.

    please see attached picture.

    89CB86A0-49B9-488C-9CA9-317DF0DEED5F.jpeg 89CB86A0-49B9-488C-9CA9-317DF0DEED5F.jpeg
    #149614 quote
    robertogozzi
    Moderator
    Master

    As you can see they don’t share the scale, values are so much different!

    Try to better explain what you mean by “I would love to be build TSV onto my balance of power indicator“.

    #149624 quote
    al_craig
    Participant
    New

    Good Morning,

    Sorry, I am not doing a very good job of explaining this. Perhaps it is easiest if I show you what I am hoping to reproduce.

    Please see attached picture 🙂 this combines BOP : TSV : MA

    Many thanks

    E5FB9CFE-17F8-48FD-8449-E63BED54445F.jpeg E5FB9CFE-17F8-48FD-8449-E63BED54445F.jpeg
    #149626 quote
    Vonasi
    Moderator
    Master

    al_craig – Please always use the ‘Insert PRT Code’ button when posting code rather than expect the person helping you to type it all out from a screen shot.

    Like this:

    //PRC_True Balance of Power | indicator
    //11.10.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //converted from Pinescript version
    
    //---settings
    //per=30 //periods for Emoline
    //---end of settings
    
    trhi = max(high, close[1]) //true high
    trlo = min(low, close[1]) //true low
    trop = close[1] //true open
    bop = 100*(close-trop)/(trhi-trlo) //True Balance of Power as percent
    lin= 1.5*linearregression[per](bop) //linear regression as emoline
    
    r=0
    g=255
    if bop<0 then
     r=255
     g=140
    endif
    
    return bop coloured(r,g,0) style(histogram) as "BOP", lin style(line,3) as "Emoline"

    Alternatively provide a link to where the code can be found:

    Balance of Power

    #149633 quote
    al_craig
    Participant
    New

    Good Morning Vonasi,

    Yes, not a problem. Sorry for not doing this originally. I will ensure this is done in the future.

    Many Thanks

    #149666 quote
    robertogozzi
    Moderator
    Master

    You explained yourself very well, but it’s impossible, since:

    • TSV cannot drop below 0
    • TSV has a different scale than BOP.
    #149667 quote
    Vonasi
    Moderator
    Master

    In your image TSV has been somehow normalised to only return between -100 and +100. We would need to know how this normalisation has been calculated. In this example I have normalised it by comparing the current TSV to the highest and lowest TSV values in the last P1 bars.

    //PRC_True Balance of Power | indicator
    //11.10.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //converted from Pinescript version
    
    //---settings
    per=30 //periods for Emoline
    //---end of settings
    
    trhi = max(high, close[1]) //true high
    trlo = min(low, close[1]) //true low
    trop = close[1] //true open
    bop = 100*(close-trop)/(trhi-trlo) //True Balance of Power as percent
    lin= 1.5*linearregression[per](bop) //linear regression as emoline
    
    r=0
    g=255
    if bop<0 then
    r=255
    g=140
    endif
    
    // TSV Time Segmented Volume indicator
    //
    // --------------------------------------------------------------------------------------
    // 13 = number of daily HALF HOURS
    //  7 = ????
    // --------------------------------------------------------------------------------------
    //      Example Settings:
    // Short Term Trading       :  TSV period between  9 and 12
    // Intermediate Term Trading:  TSV period between 18 and 25
    // Long Term Trading        :  TSV period between 35 and 45
    //
    // --------------------------------------------------------------------------------------
    
    ONCE p1    = 13
    ONCE p2    = 7
    ONCE Mtype = 0
    
    p1           = max(1,min(999,p1))
    p2           = max(1,min(999,p2))
    Mtype        = max(0,min(6,Mtype))
    once lookback = p1
    
    MyVol = 0
    IF close > close[1] THEN
    MyVol = volume * (close - close[1])
    ELSIF close < close[1] THEN
    MyVol = -volume * (close - close[1])
    ENDIF
    TSV    = summation[lookback](MyVol)
    
    maxtsv = highest[lookback](tsv)
    mintsv = lowest[lookback](tsv)
    tsvresult = (((tsv-mintsv)/(maxtsv - mintsv))*200)-100
    Signal = average[p2,Mtype](TSVresult)
    
    RETURN  bop coloured(r,g,0) style(histogram) as "BOP", lin style(line,3) as "Emoline", TSVresult AS "Tsv",Signal AS "Signal"
    Screenshot_2-1.png Screenshot_2-1.png
    #149678 quote
    al_craig
    Participant
    New

    Thank you both very much for your efforts. It is very much appreciated.

    I will go away and do some more homework to see what I can find out.

    Thanks again

    #150441 quote
    Barrabas15
    Participant
    Master

    I think the correct code should be like the one attached,

    I don’t know if this is correct since I don’t know much about programming but it makes much more sense.

    IF close > close[1] THEN
    MyVol = volume * (close - close[1])
    ELSIF close < close[1] THEN
    MyVol1 = volume * (close[1] - close)
    ENDIF
    
    Vol = MyVol-MyVol1
    
    TSV = summation[per](Vol)
    Signal = average[sign](TSV)
    
    if TSV >= TSV[1] then
    color =1
    else
    color =-1
    endif
    
    RETURN TSV coloured by color AS "Tsv",Signal AS "Signal"
    #150443 quote
    robertogozzi
    Moderator
    Master

    It’s the same, but since the formula I could find is TSV=(Sum( IIf( C > Ref(C,-1), V * ( C-Ref(C,-1) ), IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18)); I wrote as I did.

    Multiplying 10*-1000 is the same as multiplying -10*1000.

    There should be no difference on your chart.

Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.

Time Segmented Volume by Worden Brothers code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
al_craig @al_craig Participant
Summary

This topic contains 24 replies,
has 5 voices, and was last updated by robertogozzi
4 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/05/2020
Status: Active
Attachments: 11 files
Logo Logo
Loading...