Thanks for your reply.
Here is the code :
_SECTION_BEGIN( "SwingHighLow" );
SetChartOptions( 0, chartShowArrows | chartShowDates );
SetChartBkColor( colorBlack );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
rightstrength = Param( "Right Strength",4, 2, 50, 1 );
leftstrength = Param( "Left Strength", 4, 2, 50, 1 );
plotFractals = ParamToggle( "Plot Fractals", "Off|On", 0 );
plotLabels = ParamToggle( "Plot Labels", "Off|On", 1);
function GetTop()
{
Top = H == HHV( H, leftstrength ) AND Ref( HHV( H, rightstrength ), rightstrength ) < H;
Top = Top AND LastValue( bi ) - ValueWhen( Top, bi ) > rightstrength;
return Top;
}
function GetValley()
{
Valley = L == LLV( L, leftstrength ) AND Ref( LLV( L, rightstrength ), rightstrength ) > L;
Valley = Valley AND LastValue( bi ) - ValueWhen( Valley, bi ) > rightstrength;
return Valley;
}
// Build fractals array
pk = GetTop();
tr = GetValley();
pk = IIf( pk, IIf( ValueWhen( pk, bi, 2 ) < ValueWhen( tr, bi ), pk, IIf( ValueWhen( pk, H, 2 ) > H, False, pk ) ), pk );
pk = IIf( pk AND ValueWhen( pk, bi, 0 ) > bi, IIf( ValueWhen( pk, bi, 0 ) < ValueWhen( tr, bi, 0 ), IIf( ValueWhen( pk, H, 0 ) >= H, False, pk ), pk ), pk );
tr = IIf( tr, IIf( ValueWhen( tr, bi, 2 ) < ValueWhen( pk, bi ), tr, IIf( ValueWhen( tr, L, 2 ) < L, False, tr ) ), tr );
tr = IIf( tr AND ValueWhen( tr, bi, 0 ) > bi , IIf( ValueWhen( tr, bi, 0 ) < ValueWhen( pk, bi, 0 ), IIf( ValueWhen( tr, L, 0 ) <= L, False, tr ), tr ), tr );
for( i = 0; i < 3; i++ )
{
VarSet( "px" + i, ValueWhen( pk, bi, i ) );
VarSet( "tx" + i, ValueWhen( tr, bi, i ) );
VarSet( "ph" + i, ValueWhen( pk, H, i ) );
VarSet( "tl" + i, ValueWhen( tr, L, i ) );
}
ll = tr AND tl1 < tl2;
hl = tr AND tl1 > tl2;
hh = pk AND ph1 > ph2;
lh = pk AND ph1 < ph2;
dt = pk AND ph1 == ph2;
db = tr AND tl1 == tl2;
if( PlotFractals )
{
PlotShapes( shapeSmallCircle * pk, colorRed, 0, H, 10 );
PlotShapes( shapeSmallCircle * tr, colorBlue, O, L, -10 );
}
function drawPivotLabels()
{
sz = 10;
for( i = lvb; i > fvb; i-- )
{
{
if( ll[i] ) PlotTextSetFont( "SL", "Arial Black", sz, i, L[i], colorBlue, colorDefault, -25 );
if( hl[i] ) PlotTextSetFont( "SL", "Arial Black", sz, i, L[i], colorBlue, colorDefault, -25 );
if( db[i] ) PlotTextSetFont( "DB", "Arial Black", sz, i, L[i], colorLightBlue, colorDefault, -35 );
if( hh[i] ) PlotTextSetFont( "SH", "Arial Black", sz, i, H[i], colorRed, colorDefault, 20 );
if( lh[i] ) PlotTextSetFont( "SH", "Arial Black", sz, i, H[i], colorRed, colorDefault, 20 );
if( dt[i] ) PlotTextSetFont( "DT", "Arial Black", sz, i, H[i], colorOrange, colorDefault, 30 );
}
}
}
if( plotLabels ) drawPivotLabels();
_SECTION_END();
Kindly help to modify as per my requirement .
