To start with I use the following code to obtain swingpoints
_SECTION_BEGIN( "SwingPoints" );
bi = BarIndex();
fvb = FirstVisibleValue( bi );
lvb = LastVisibleValue( bi );
rightstrength = Param( "Right Strength",2, 2, 50, 1 );
leftstrength = Param( "Left Strength", 4, 2, 50, 1 );
plotFractals = ParamToggle( "Plot Fractals", "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;
}
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, 44, O, L, -10 );
PlotShapes( shapeSmallCircle * pk, colorRed, 0, H, 10, 1 );
PlotShapes( shapeSmallCircle * tr, 44, O, L, -10, 1 );
PlotShapes( shapeSmallCircle * pk, colorRed, 0, H, 10, 2 );
PlotShapes( shapeSmallCircle * tr, 44, O, L, -10, 2 );
}
_SECTION_END();
So far this works as expected and gives this result
Now I would like to add another smallcircle for the target which would be half of the range
of those 3 swingbars in the direction of the swing. This smallcircle should be drawn just
at this calculated targetlevel for the following 4. candle, but I just can't achieve to get
this circle drawn correctly but obtain instead lots of small arrows if I try to add a similar
code like the one used for the swingpoints with those calculated targets instead 'pk'/'tr'.