Time Segmented Volume for ThinkorSwim

SolidChiken

New member
2019 Donor
Last edited:

BenTen

Administrative
Staff
VIP
This was pulled from the TSL archive.

11:07 UpTheCreek: TSV is proprietary to Worden. I dont believe the algo has ever been disclosed.
11:13 Wally: TSV_Replica https://tos.mx/P2Hgh1

Code:
# Time Segmented Value (TSV)
Declare lower;
input length = 18;

#TSV=(Sum( IIf( C > Ref(C,-1), V * ( C-Ref(C,-1) ),
# IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18));

plot TSV = sum( if close > close[1] then volume * (close - close[1]) else if close < close[1] then -1* volume *(close - close[1]) else 0, length);

Plot TSVAvg = Average( TSV,5);
 

SolidChiken

New member
2019 Donor
Thank you @BenTen . Really appreciate it. Noticed it doesn't look the same as the one on the article. Do you know how to adjust the code to make it have a zero line ?

AgmrCM9.png
 
Last edited:

BenTen

Administrative
Staff
VIP
@SolidChiken Here is the code for the Zero Line. Add it to the bottom of that script. Keep in mind that what I posted above is a replica of the indicator you wanted. May or may not work the same.

Code:
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GREEN);
 

horserider

Well-known member
VIP
@SolidChiken You do know you can give any name you want to an indicator. So what he calls TSV may very well be similar to an already existing one. Write it up nice and voila a proprietary indicator to sell your service. Since no calculations are shown we can only guess.
My best guess is OnBalanceVolume.

The one BenTen showed you has a scale starting at 0. No need for a zero line.
 

horserider

Well-known member
VIP
@SolidChiken I see now they also have that write up on OBV. So TSV must be different. Bad guess by me.

OBV is not BMP . ToS has a BalanceofMarketPower indicator.

I am going to play with this tomorrow when I have some spare time. I like the mystery of what TSV is. I am wondering about that web site. How they claim the indicators show dark pool activity is beyond me. Maybe someone more an expert on dark pools can help out.

What had me scratching my head was this "The Bollinger Band indicator employs two simple moving averages with two standard deviations. By applying the standard deviations to the moving averages, " . Makes me wonder about anything they say.
 

SolidChiken

New member
2019 Donor
@horserider... I've tried the BoMP. However the indicator doesn't correspond to what I want to see in the chart.
The TSV code that we having here looks like not the same as the page. The zero line is staying at the bottom.
Anyone here can help to tweak it ? 🙏
 

markos

Well-known member
VIP
Hi @gjervis Once you get in touch with support via the button on top of the screen and after you ask about thinkscript lounge, ask them to set up your free tour of the system with emphasis on currency pairs. You are entitled to a free personal tour. Have 10 questions ready so they stay on track with currency information. I don't recall any currency pair info on this site.

If you would rather speak on the phone, go back to Tutorials. There is a "Secret" phone number that I call for the Advanced Team.
 

TheAvenged

New member
Hey, I am trying to convert this script into ThinkorSwim. I tried, but am not very proficient with thinkscript. I would really appreciate any help.

Code:
//  Formula Name  : OGTS Time Segmented Money Flow
//  Author        : KH Tang 
//  Company       : Wealth Resonance 
//  Last Update   : 15 Jan 2014
//  Date Updated  : 22 Nov 2013 // Update with opening price as direction*
//  Origin date      : 5 Jun 2007 
//  Origin        : KH Tang 
//  Version       : 1.01
//  Level         : Volume Spread Analysis
//  Description   : Key Usages:
//                : 1.Tape Reading for Direction of Breakout in Trading Range
//                : 2.Tape Reading for Divergence in Trending
//           : Note: Enhancement to include Opening price as direction.
//More notes on blog:
//http://blessedfool.blogspot.sg/2014/02/stock-market-tools-12-better-obv-and.html
//------------------------------------------------------------------------------

procedure BackgroundSetting()
{

SetChartBkGradientFill( ParamColor("BackgroundTop", colorSkyblue),
        ParamColor("BackgroudBottom", colorWhite),ParamColor("TitleBlock",colorWhite));
}


SetBarsRequired( -2, -2 );
_SECTION_BEGIN("Display Setting");
GraphXSpace = 10;
Backgroundsetting();
_SECTION_END();//Display Setting

//William C. Garrett's Approximation: 
//GPaths   = IIf(C>Ref(C,-1),((H-Ref(C,-1))+(H-L)+(C-L)),IIf(C<Ref(C,-1),(Ref(C,-1)-L)+(H-L)+(H-C),1));
//GUpShare = IIf(C>Ref(C,-1),((H-Ref(C,-1))+(C-L)),IIf(C<Ref(C,-1),(H-L),0));
//GDnShare = IIf(C>Ref(C,-1),(H-L),IIf(C<Ref(C,-1),(Ref(C,-1)-L)+(H-C),0));


//Expansion for clarity:
PathA1= Ref(C,-1)-L;
PathB1= H-L;
PathC1= H-C;
Path1 = PathA1+PathB1+PathC1;
UpShare1 = PathB1;
DnShare1 = PathA1+PathC1;

PathA2= H-Ref(C,-1);
PathB2= H-L;
PathC2= C-L;
Path2 = PathA2+PathB2+PathC2;
UpShare2 = PathA2+PathC2;
DnShare2 = PathB2;

Paths  = IIf(C<Ref(C,-1),Path1,      IIf(C>Ref(C,-1),Path2,   1));
UpShare= IIf(C<Ref(C,-1),UpShare1,IIf(C>Ref(C,-1),UpShare2,0));
DnShare= IIf(C<Ref(C,-1),DnShare1,IIf(C>Ref(C,-1),DnShare2,0));

FlowFactor = Avg;

FlowIn  = UpShare/Paths*Volume*FlowFactor;
FlowOut = DnShare/Paths*Volume*FlowFactor;
NetFlow = FlowIn - FlowOut;
TotalFlow = Cum(NetFlow );


PlotType = ParamList("Type of Chart Plotting:","Cumulative|Time Segmented",1);
LBP = Param("LBP for Time Segmented Plot",26,10,50,1);
FastSmoothMF     = EMA(TotalFlow,int(LBP/2)); 
SlowSmoothMF   = EMA(TotalFlow,LBP);

DailyNetFlow= IIf(NetFlow==0,MA(Netflow,30),NetFlow);

if(PlotType=="Cumulative")
{
    Plot(TotalFlow ,"Garrett Money Flow",colorRed,styleThick);
}
else if (PlotType=="Time Segmented")
{
    TSMF=FastSmoothMF - SlowSmoothMF;
    Plot(TSMF,"Time Segmented Money Flow",colorRed,styleThick);
    Plot(0,"",colorBlack);
    TSMFsig = EMA(TSMF,9);
    Plot(TSMFsig,"Sig",colorBlue);
    
    Histogram = TSMF-TSMFSig;

    Plot(Histogram,"Histogram",colorBlack,styleHistogram);

}

@horserider I've read a bunch of your posts in the last few days and you seem like a wizard. is this something you could potentially change over to tos?
 

Similar threads

Top