Does anyone have ZigZagFibs V2.0?

 
 

inputs:

RetraceType( 1 ) , { Choose: 1 Pnts, 2 Pct, 3 = ATR }

RetracePnts( 5 ) ,

RetracePct( 5 ) ,

ATRPeriod(10), //Number of ATR Periods

ATRMulti(3), // ATR Multiplier

StrengthSensitivity(2),

ShowNegFibs(TRUE),

ShowZigZagLines( True ) ,

ShowSwingPointLines( True ) ,

ShowFibText(True),

ZigZagLineColor( Magenta ) ,

ZigZagLineWidth( 1 ),

SwingHighColor( Black ) ,

SwingLowColor (Red ) ,

SwingLineStyle( Tool_Dotted ),

HorzOffset(10), // In Minutes

VertOffset( 0.25 ),

DecimalPlaces( 2 ),

{HamFon Fib inputs}

ShowOpenLine (False), ExtRight(True),

TextColor(LightGray),

HiLoColor (Magenta), OuterFibColor (DarkGreen),

MidColor(Magenta), InnerFibColor(Red), FibPlusColor(DarkGray), OpenColor (Darkbrown);

variables:

NewSwingPrice( 0 ) ,

LastSwingPrice(0 ) ,

SwingPrice( High ) , { used as a convenient 2-element array }

SwingDate( Date ) , { used as a convenient 2-element array }

SwingTime( Time ) , { used as a convenient 2-element array }

RetraceFctrUp(0),

RetraceFctrDn(0),

TLDir( 0 ), { TLDir = -1 implies prev TL dn, +1 implies prev TL up }

SaveSwing( false ) ,

AddTL( false ) ,

UpdateTL( false ) ,

TLRef( 0 ) ,

TLSwing( 0 ),

PeakTextRef( 0 ) ,

PeakStr("") ,

{HamFon variables inputs}

TLCreated (false), Redraw (false), Loop (0), Diff(0),

ArrayMax (17),

ATRPoints(0);

vars: showDebug(FALSE), NegFibNums(6);

arrays: TrendLine[17] (0), DayValue[17] (0), FibText[17](0), FibValue[17](0);

//Create initial fib lines

if CurrentBar = 1 then begin

if (ShowNegFibs=FALSE) then ArrayMax = ArrayMax-NegFibNums;

for loop=0 to ArrayMax

begin {added Color for visual differentiation}

if loop <= ArrayMax then

begin

TrendLine[loop] = TL_New (Date[1], Time[1], Low, Date, Time, Low);

If (loop = 4) then

TL_SetColor (TrendLine[loop], MidColor)

else if (loop = 0) or (Loop = 1) then

TL_SetColor (TrendLine[loop], HiLoColor)

else if (loop = 3 ) or (loop = 5 ) then

TL_SetColor (TrendLine[loop], InnerFibColor)

else if (Loop = 2) or (loop = 6) then

TL_SetColor (Trendline[loop], OuterFibColor)

{else if (Loop > 7) then

TL_setcolor(Trendline[loop], red)}

else TL_SetColor (TrendLine[loop], FibPlusColor);

TL_SetExtLeft (TrendLine[loop], false);

TL_SetExtRight (TrendLine[loop], True);

if loop = 4 then

TL_SetStyle(TrendLine[loop],Tool_dotted);

FibText[loop] = Text_New(Date, Time, Low, " " ) ;

Text_SetColor(FibText[loop], TextColor) ;

end; // if loop

end; // for loop

FibValue[0] = 1 ; {Max Swing }

FibValue[1] = 0 ; { Min Swing }

FibValue[2] = .236 ;

FibValue[3] = .382 ;

FibValue[4] = .5 ;

FibValue[5] = .618 ;

FibValue[6] = .764 ;

FibValue[7] = .886 ;

FibValue = 1.23 ;

FibValue[9] = 1.5 ;

FibValue[10] = 1.62 ;

FibValue[11] = 2.00 ;

{Negative Numbers }

FibValue[12] = -.236 ;

FibValue[13] = -.382 ;

FibValue[14] = -.5 ;

FibValue[15] = -.618 ;

FibValue[16] = -.764 ;

FibValue[17] = -1.00 ;

end; //if currentbar

{ Candidate swings are just-confirmed, 3-bar (Str=1), SwingHi's and SwingLo's }

NewSwingPrice = SwingHigh( 1, High, StrengthSensitivity, StrengthSensitivity+1) ;

if ( RetraceType = 3) then ATRPoints = ATRMulti*AvgTrueRange(ATRPeriod) else ATRPoints = 0;

RetraceFctrUp = 1 + RetracePct * .01;

RetraceFctrDn = 1 - RetracePct * .01;

// print("ATRPoints = ", ATRPoints);

if NewSwingPrice -1 then

begin

if ( RetraceType = 1 and TLDir = SwingPrice + RetracePnts ) or

( RetraceType = 2 and TLDir = SwingPrice * RetraceFctrUp ) or

( RetraceType = 3 and TLDir = SwingPrice + ATRPoints )

then

{ prepare to add new up TL }

begin

SaveSwing = true ;

AddTL = true ;

TLDir = 1 ;

end

else if TLDir = 1 and NewSwingPrice >= SwingPrice then

{ prepare to update prev up TL }

begin

SaveSwing = true ;

UpdateTL = true ;

end ;

end

else

begin

{ NewSwingPrice = SwingLow( 1, Low, 1, 2 ) ; }

NewSwingPrice = SwingLow( 1, Low, StrengthSensitivity, StrengthSensitivity+1) ;

if NewSwingPrice -1 then

begin

if ( RetraceType = 1 and TLDir >= 0 and NewSwingPrice <= SwingPrice - RetracePnts ) or

( RetraceType = 2 and TLDir >= 0 and NewSwingPrice <= SwingPrice * RetraceFctrDn ) or

( RetraceType = 3 and TLDir >= 0 and NewSwingPrice <= SwingPrice - ATRPoints )

then

{ prepare to add new dn TL }

begin

SaveSwing = true ;

AddTL = true ;

TLDir = -1 ;

end

else if TLDir = -1 and NewSwingPrice <= SwingPrice then

{ prepare to update prev dn TL }

begin

SaveSwing = true;

UpdateTL = true ;

end ;

end ;

end ;

if SaveSwing then

{ save new swing and reset SaveSwing }

begin

SwingPrice = NewSwingPrice ;

SwingDate = Date[StrengthSensitivity];

SwingTime = Time[StrengthSensitivity];

// SaveSwing = false ;

end ;

if (showDebug) then

print(" AddTL === ", AddTL, " UpdateTL == ", UpdateTL, "SaveSwing == ", SaveSwing, " TL Dir = ", TLDir);

if AddTL then

{ add new TL and reset AddTL }

begin

PeakTextRef = Text_New(Date, Time, Close, " ") ;

Text_SetColor(PeakTextRef, TextColor ) ;

if ShowZigZagLines then

begin

TLRef = TL_New( SwingDate, SwingTime, SwingPrice, SwingDate[1], SwingTime[1],

SwingPrice[1] ) ;

Text_SetStyle(PeakTextRef, 2, 2 );

TL_SetExtLeft( TLRef, false ) ;

TL_SetExtRight( TLRef, false ) ;

TL_SetSize( TLRef, ZigZagLineWidth ) ;

TL_SetColor( TLRef, ZigZagLineColor ) ;

LastSwingPrice = SwingPrice[1];

end ;

if ShowSwingPointLines then

begin

TLSwing = TL_New( Date[1], Time[1], SwingPrice, Date, Time, SwingPrice ) ;

if TLDir = -1 then

TL_SetColor( TLSwing, SwingLowColor )

else

TL_SetColor( TLSwing, SwingHighColor ) ;

TL_SetStyle( TLSwing, SwingLineStyle ) ;

TL_SetExtLeft( TLSwing, False ) ;

TL_SetExtRight( TLSwing, False ) ;

end ;

if TLDir = -1 then

PeakStr = "" + NumToStr(SwingPrice,DecimalPlaces) + " / " + NumToStr(LastSwingPrice - SwingPrice, DecimalPlaces )

else

PeakStr = "" + NumToStr(SwingPrice,DecimalPlaces) + " / " + NumToStr(SwingPrice - LastSwingPrice, DecimalPlaces ) ;

Text_SetString(PeakTextRef, PeakStr );

if TLDir = -1 then

Text_SetLocation(PeakTextRef, SwingDate, SwingTime, SwingPrice - VertOffset )

else

Text_SetLocation(PeakTextRef, SwingDate, SwingTime, SwingPrice + VertOffset );

AddTL = false ;

end

else if UpdateTL then

{ update prev TL and reset UpdateTL }

begin

if ShowZigZagLines then

TL_SetEnd( TLRef, SwingDate, SwingTime, SwingPrice ) ;

if ShowSwingPointLines then

begin

TL_SetEnd( TLSwing, SwingDate, SwingTime, SwingPrice ) ;

TL_SetBegin( TLSwing, SwingDate, SwingTime, SwingPrice ) ;

end ;

if TLDir = -1 then

PeakStr = "" + NumToStr(SwingPrice,DecimalPlaces) + " / " + NumToStr(LastSwingPrice - SwingPrice, DecimalPlaces )

else PeakStr = "" + NumToStr(SwingPrice,DecimalPlaces) + " / " + NumToStr(SwingPrice - LastSwingPrice, DecimalPlaces ) ;

Text_SetString( PeakTextRef, PeakStr );

if TLDir = -1 then

Text_SetLocation(PeakTextRef, SwingDate, SwingTime, SwingPrice - VertOffset)

else

Text_SetLocation(PeakTextRef, SwingDate, SwingTime, SwingPrice + VertOffset);

UpdateTL = false ;

end ;

{************* HamFons' FIB POINTS Code:

goal is to call the LAST SWING HI AND LAST SWING LO from ABOVE CODE

and draw Fib points between them *****************}

if (showDebug) then

print("SaveSwing == ", SaveSwing, " TL Dir = ", TLDir);

//Update Fib lines

if SaveSwing then begin

if TLDir = -1 then

begin

DayValue[0] = Swingprice;

DayValue[1] = LastSwingprice;

end

else

begin

DayValue[1] = Swingprice;

DayValue[0] = LastSwingprice;

end ;

Diff = DayValue[0] - DayValue[1];

if (showDebug) then

print("Day0 = ", DayValue[0], " DayMax= ", DayValue[1], " Diff =", Diff, " TLDir = ", TLDir);

for loop=2 to ArrayMax

begin

DayValue[loop] = DayValue[1] + Diff * FibValue[loop];

end;

for loop=0 to ArrayMax begin

{ SetEnd before SetBegin }

if TrendLine[loop] > 0 then begin

TL_SetEnd (TrendLine[loop], Date, Time, DayValue[loop]);

TL_SetBegin (TrendLine[loop], Date, Time, DayValue[loop]);

end; // if TrendLine

end; // for loop

SaveSwing = False ;

end ; // if SaveSwing

if (ShowFibText) then

begin

for loop=0 to ArrayMax

begin

if FibText[loop] > 0 then

begin

// Text_SetLocation(FibText[loop],Date,Time +30, Dayvalue[loop]);

Text_SetLocation(FibText[loop],Date,Time +HorzOffset, Dayvalue[loop]);

Text_SetString(FibText[loop],NumToStr(DayValue[loo p],DecimalPlaces) + " / " + NumToStr(FibValue[loop],2)) ;

end;

end;

end;

Files:
zigpic.gif  21 kb
 

I do not know about exact name ZigZagFibs V2.0 but take a look at this thread https://www.mql5.com/en/forum and this indicator ICWR. Ar least two indicators looks the same with your image.

 

Thanks newdigital but I think it is quite a bit different to those, I have the beta version as attached, but it does not draw the fib lines correctly

Files:
Reason: