yes that needs more recent version but you do not need all the code, just the pivots, see

```
/*
© AFL code by E.M.Pottasch, 11/2017
TB-F: Top/Bottom Finder, After Paul Levine (1993 or thereabouts), 38 page trading Ebook,
free on internet and Midas Manual 2011 (Andrew Coles, David G. Hawkins), free on internet.
Still to implement:
1)
D is actually determined by iteratively adjusting it to provide a best "fit" to the
price pullbacks subsequent to launch. To start this process, one must set D equal to
some initial guess; I usually choose fifty days worth of volume, i.e. the cumulative
volume at launch minus the cumulative volume fifty trading days earlier. In the fitting
process used to determine D, generally an "eyeball" affair, give more weight to fitting
the more recent pullbacks (from: chapter 15, page 28 -Levine, 1993- )
Chapter 4 of the Midas 2011 Manual talks about D fitting.
2)
*/
rightstrength = Param( "Right Strength", 5, 2, 50, 1 );
leftstrength = Param( "Left Strength", 5, 2, 50, 1 );
fact = Param( "Chart Time Frame Factor", 1, 1, 10, 1 );
nbars = Param( "nbars", 50, 0, 500, 0.1 );
ww = Param( "width", 5, 0, 10, 1 );
dn = DateTime();
sd = SelectedValue( dn );
start = dn == sd;
//start = DateNum() == 1081031; // Midas example start point
stidx = LastValue( ValueWhen( start, BarIndex() ) );
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
rightStrength = rightStrength * fact;
leftStrength = leftStrength * fact;
pk = H == HHV( H, leftstrength ) AND Ref( HHV( H, rightstrength ), rightstrength ) < H;
tr = L == LLV( L, leftstrength ) AND Ref( LLV( L, rightstrength ), rightstrength ) > L;
if( tr[stidx] )
{
mp = L;
}
else
if( pk[stidx] )
{
mp = H;
}
else
{
mp = ( H + L ) / 2;
}
MidasLoop = Null;
TBFLoop = Null;
MidasLoop[stidx] = mp[stidx];
TBFLoop[stidx] = mp[stidx];
cumpvol = Cum( mp * V ) - ValueWhen( Ref( start, 1 ), Cum( mp * V ) );
cumvol = Cum( V ) - ValueWhen( Ref( start, 1 ), Cum( V ) );
ma1 = MA( V, 200 );
for( i = stidx + 1; i <= lvb; i++ )
{
MidasLoop[i] = cumpvol[i] / cumvol[i]; // VWAP starting at index stidx
//dd = 61200000; // Midas example data D value
//dd = cumvol[stidx] * nbars; // temporary solution to set D
dd = ma1[stidx] * nbars; // temporary solution to set D
d1 = cumvol[i];
e1 = d1 * ( 1 - d1 / dd ); // if d1 > dd then e1 < 0, end of TB-F curve
x1 = d1 - e1;
idx = stidx;
for( j = stidx + 1; j <= i; j++ )
{
if( x1 > cumvol[j - 1] AND x1 < cumvol[j] )
{
idx = j;
//_TRACE( "i: " + i + " j: " + j );
break;
}
}
// interpolate
if( idx != 0 AND e1 >= 0 )
{
v0 = cumpvol[idx - 1];
v1 = cumpvol[idx];
t = ( x1 - cumvol[idx - 1] ) / ( cumvol[idx] - cumvol[idx - 1] );
result = ( 1 - t ) * v0 + t * v1;
TBFLoop[i] = ( cumpvol[i] - result ) / e1;
}
}
SetChartOptions( 0, chartShowDates );
SetChartBkColor( ColorRGB( 0, 0, 0 ) );
Plot( Close, "Price", colorDefault, styleCandle, Null, Null, 0, 0, 1 );
Plot( MidasLoop, "Midas", colorViolet, styleLine | styleNoRescale, Null, Null, 0, 0, ww );
Plot( TBFLoop, "TB-F", colorLightBlue, styleLine | styleNoRescale, Null, Null, 0, 0, ww );
PlotShapes( shapeSmallCircle*tr, ColorRGB( 0, 250, 0 ), 0, L, -10 );
PlotShapes( shapeSmallCircle*pk, ColorRGB( 250, 0, 0 ), 0, H, 10 );
```