AFL is not giving signal on Realtime, the signal is delayed by almost 1 hour or so

The following AFL is not giving signal on Realtime. The signal is delayed by almost 1 hour or so. Please help me in modifying the AFL so that it can give signal on Realtime.

_SECTION_BEGIN("+VE");

Q = Param( "% Change", 2, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );

for ( i = 0; i < BarCount; i++ )
{
if ( HH[i] )
PlotText( "- -VE REVERSE", i, H[ i ] + dist[i], colorRed );

if ( LH[i] )
PlotText( "-VE REVERSE", i, H[ i ] + dist[i], colorRed );

if ( HL[i] )
PlotText( "+VE REVERSE", i, L[ i ] - dist[i], colorBrightGreen );

if ( LL[i] )
PlotText( "++ VE REVERSE", i, L[ i ] - dist[i], colorBrightGreen );

}

Filter=HH OR HL OR LH OR LL;
AddColumn(HH,"HH",1);
AddColumn(LH,"LH",1);
AddColumn(HL,"HL",1);
AddColumn (LL,"LL",1);

Buy = HL OR LL;
Sell = HH OR LH;
SellPrice=ValueWhen(Sell,H,1);
BuyPrice=ValueWhen(Buy,L,1);
//Long=Flip(Buy,Sell);
//Shrt=Flip(Sell,Buy );
Plot( Flip( Buy, Sell ), "BUY", colorDarkGreen, styleArea | styleOwnScale, 0, 20 );

Shape = (Buy * shapeSmallUpTriangle + Sell * shapeSmallDownTriangle);
PlotShapes( shape, IIf( Buy, colorYellow, colorYellow ),0, IIf( Buy, Low,High ));
_SECTION_END();

@drana, have you researched the functions in the code that you posted (without using the Code Blocks '</>')?

Please READ The Manual and see what the PEAK and TROUGH functions do, and how they work. (HINT: How they work will lead you to reading more).

That should answer your question as to why you do not have a signal in real time.

I could just tell you, but if you do the "work" to learn why, you will be much better equipped to do more work on your own, when you develop another AFL.