// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("CYBER STOCH");

Arrows = ParamToggle( "Buy/Sell Arrows", "No|Yes", 1 );
alpha = Param( "Alpha", 0.07, 0.01, 0.4, 0.01, 0.01 );
Len = Param( "Length", 8, 1, 25, 1, 1 );
BullSig = BearSig = Trigger = Cycle = MaxCycle = MinCycle = Value1 = Value2 =
0;
PriceIn = ( ( H + L ) / 2 );

SmoothX = ( PriceIn + 2 * Ref( PriceIn, -1 ) + 2 * Ref( PriceIn, -2 ) + Ref(
PriceIn, -3 ) ) / 6;


for ( i = 6; i < BarCount; i++ )
{
    Cycle[i] = ( ( 1 - 0.5 * alpha ) ^ 2 ) * ( SmoothX[ i ] - 2 * SmoothX[ i - 1
] + SmoothX[ i - 2] ) + 2 * ( 1 - alpha ) * Cycle[ i - 1 ] - ( ( 1 - alpha ) ^ 2
) * Cycle[ i - 2 ];

    if ( i < 7 )
        Cycle[i] = ( PriceIn[i] - 2 * PriceIn[i-1] + PriceIn[i-2] ) / 4;
}

MaxCycle = HHV( Cycle, Len );

MinCycle = LLV( Cycle, Len );

Value1 = IIf( MaxCycle != MinCycle, ( Cycle - MinCycle ) / ( MaxCycle - MinCycle
), Value1 );

Value2 = ( 4 * Value1 + 3 * Ref( Value1, -1 ) + 2 * Ref( Value1, -2 ) + Ref(
Value1, -3 ) ) / 10;

Value2 = 2 * ( Value2 - 0.5 );

Trigger = ( 0.96 * ( Ref( Value2, -1 ) + 0.02 ) );

BullSig = IIf( Cross( Value2, Trigger ), True, False );
BearSig = IIf( Cross( Trigger, Value2 ), True, False );


Plot( Value2, "CyberCycle", colorLightBlue );
Plot( Trigger , "Trigger", colorRed );
Plot( 0 , "", colorWhite, styleDashed );

if ( Arrows )
{
    PlotShapes( shapeUpArrow*BullSig, colorBrightGreen );
    PlotShapes( shapeDownArrow*BearSig, colorRed );
}
_SECTION_END();