// TSV Time Segmented Volume indicator // https://futures.io/thinkorswim/10957-time-segmented-volume-worden-telecharts.html#post122215 // // 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 // // -------------------------------------------------------------------------------------- // t = sum(close>close[1]?volume*close-close[1]:close Ref(C,-1), V * ( C-Ref(C,-1) ), IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18)); // -------------------------------------------------------------------------------------- // //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"