Triangular Moving Average - How can I modify the present code?

Hello
good morning
I have this AFL
I would like to modify them
Is it possible
I want to have moving average (Triangular MA 50)
With index (AccumulationSwingIndex) And search in case the index breaks the (Triangular MA 50)
Thank you for your cooperation

_SECTION_BEGIN("asi+ma50");
function SwingIndex( Limit ) 
{ 
    Hy = Ref( H, -1 ); 
    Cy = Ref( C, -1 ); 
    Ly = Ref( L, -1 ); 
    Oy = Ref( O, -1 ); 

    r1 = abs( H - Cy ); 
    r2 = abs( L - Cy ); 
    r3 = abs( H - L ); 
    r4 = abs( Cy - Oy ); 

    k = Max( r1, r2 ); 

    r = IIf( r1 >= Max( r2, r3 ), r1 - r2 / 2 + r4 / 4, 
             IIf( r2 >= Max( r1, r3 ), r2 - r1 / 2 + r4 / 4, 
                  r3 + r4 / 4 ) ); 

    return IIf( r == 0, 0, 50 * ( ( C - Cy + 0.5 * ( C - O ) + 0.25 * ( Cy - Oy ) ) / r ) * k / Limit ); 
} 

function AccumulationSwingIndex( Limit ) 
{ 
    return Cum( SwingIndex( Limit ) ); 
} 

index = AccumulationSwingIndex( Param( "Limit", 100, 1, 1000 ) ); 
Plot( index, _DEFAULT_NAME(), ParamColor( "Color", colorRed ) ); 
Plot( MA( index, 50 ), "MA-50", colorWhite );
_SECTION_END();

Buy = Cross( index, MA( index, 50 ) ); 
Sell = Cross( MA( index, 50 ), index );

Aren’t moving averages and trader’s favorite moving average a fun topic. Everyone seems to try to re-invent the wheel. I didn’t know what a “triangular moving average” was but a quick Google search shows it is a Simple Moving Average of a Simple Moving Average.

"The Triangular Moving Average (TMA) is a double smoothed simple moving average. This is calculated as follows TMA = SMA(SMA). "

So if that is true try this,

// Triangular Moving Average v1.0, an SMA of an SMA

periods = Param("Periods", 50, 5, 250, 1);
TriangularMA = MA(MA (Close, periods), periods) ;
 
Plot(TriangularMA, "TriangularMA", colorAqua, styleThick);

Or in your code try,

Buy = Cross( index, MA(MA( index,50 ), 50) ); 
Sell = Cross( MA(MA(index,50),50), index );