Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

aaa

Automatic Fibonacci Retracement

Recommended Posts

ThanX ZDO for your information

 

I am not good enough to make an indicator

 

I can understand most of an algo and adapt some minor point, no more...

 

Here is one I've found on the net

 

//+------------------------------------------------------------------+

//| #SpudFibo.mq4 - downloaded from ultimaforex.com

//+------------------------------------------------------------------+

#property indicator_chart_window

 

extern string note1 = "Fibonacci colors";

extern color UpperFiboColor = Navy;

extern color MainFiboColor = RoyalBlue;

extern color LowerFiboColor = DodgerBlue;

extern string note2 = "Draw main Fibonacci lines?";

extern bool InnerFibs = true;

 

double HiPrice, LoPrice, Range;

datetime StartTime;

 

int init()

{

return(0);

}

 

int deinit()

{

ObjectDelete("FiboUp");

ObjectDelete("FiboDn");

ObjectDelete("FiboIn");

return(0);

}

 

 

//+------------------------------------------------------------------+

//| Draw Fibo

//+------------------------------------------------------------------+

 

int DrawFibo()

{

if(ObjectFind("FiboUp") == -1)

ObjectCreate("FiboUp",OBJ_FIBO,0,StartTime,HiPrice+Range,StartTime,HiPrice);

else

{

ObjectSet("FiboUp",OBJPROP_TIME2, StartTime);

ObjectSet("FiboUp",OBJPROP_TIME1, StartTime);

ObjectSet("FiboUp",OBJPROP_PRICE1,HiPrice+Range);

ObjectSet("FiboUp",OBJPROP_PRICE2,HiPrice);

}

ObjectSet("FiboUp",OBJPROP_LEVELCOLOR,UpperFiboColor);

ObjectSet("FiboUp",OBJPROP_FIBOLEVELS,13);

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboUp",0,"(100.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboUp",1,"(123.6%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboUp",2,"(138.2%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboUp",3,"(150.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboUp",4,"(161.8%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboUp",5,"(176.4%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboUp",6,"(200.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription("FiboUp",7,"(223.6%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+8,1.500); ObjectSetFiboDescription("FiboUp",8,"(250.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+9,1.618); ObjectSetFiboDescription("FiboUp",9,"(261.8%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+10,2.000); ObjectSetFiboDescription("FiboUp",10,"(300.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+11,2.500); ObjectSetFiboDescription("FiboUp",11,"(350.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+12,3.000); ObjectSetFiboDescription("FiboUp",12,"(400.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+13,3.500); ObjectSetFiboDescription("FiboUp",13,"(450.0%) - %$");

ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+14,4.000); ObjectSetFiboDescription("FiboUp",14,"(500.0%) - %$");

ObjectSet("FiboUp",OBJPROP_RAY,true);

ObjectSet("FiboUp",OBJPROP_BACK,true);

 

if(ObjectFind("FiboDn") == -1)

ObjectCreate("FiboDn",OBJ_FIBO,0,StartTime,LoPrice-Range,StartTime,LoPrice);

else

{

ObjectSet("FiboDn",OBJPROP_TIME2, StartTime);

ObjectSet("FiboDn",OBJPROP_TIME1, StartTime);

ObjectSet("FiboDn",OBJPROP_PRICE1,LoPrice-Range);

ObjectSet("FiboDn",OBJPROP_PRICE2,LoPrice);

}

ObjectSet("FiboDn",OBJPROP_LEVELCOLOR,LowerFiboColor);

ObjectSet("FiboDn",OBJPROP_FIBOLEVELS,19);

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboDn",0,"(0.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboDn",1,"(-23.6%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboDn",2,"(-38.2%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboDn",3,"(-50.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboDn",4,"(-61.8%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboDn",5,"(-76.4%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboDn",6,"(-100.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription("FiboDn",7,"(-123.6%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+8,1.382); ObjectSetFiboDescription("FiboDn",8,"(-138.2%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+9,1.500); ObjectSetFiboDescription("FiboDn",9,"(-150.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+10,1.618); ObjectSetFiboDescription("FiboDn",10,"(-161.8%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+11,1.764); ObjectSetFiboDescription("FiboDn",11,"(-176.4%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+12,2.000); ObjectSetFiboDescription("FiboDn",12,"(-200.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+13,2.500); ObjectSetFiboDescription("FiboDn",13,"(-250.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+14,3.000); ObjectSetFiboDescription("FiboDn",14,"(-300.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+15,3.500); ObjectSetFiboDescription("FiboDn",15,"(-350.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+16,4.000); ObjectSetFiboDescription("FiboDn",16,"(-400.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+17,4.500); ObjectSetFiboDescription("FiboDn",17,"(-450.0%) - %$");

ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+18,5.000); ObjectSetFiboDescription("FiboDn",18,"(-500.0%) - %$");

ObjectSet("FiboDn",OBJPROP_RAY,true);

ObjectSet("FiboDn",OBJPROP_BACK,true);

 

if(InnerFibs)

{

if(ObjectFind("FiboIn") == -1)

ObjectCreate("FiboIn",OBJ_FIBO,0,StartTime,HiPrice,StartTime+PERIOD_D1*60,LoPrice);

else

{

ObjectSet("FiboIn",OBJPROP_TIME2, StartTime);

ObjectSet("FiboIn",OBJPROP_TIME1, StartTime+PERIOD_D1*60);

ObjectSet("FiboIn",OBJPROP_PRICE1,HiPrice);

ObjectSet("FiboIn",OBJPROP_PRICE2,LoPrice);

}

ObjectSet("FiboIn",OBJPROP_LEVELCOLOR,MainFiboColor);

ObjectSet("FiboIn",OBJPROP_FIBOLEVELS,7);

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboIn",0,"Daily LOW (0.0) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboIn",1,"(23.6) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboIn",2,"(38.2) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboIn",3,"(50.0) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboIn",4,"(61.8) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboIn",5,"(76.4) - %$");

ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboIn",6,"Daily HIGH (100.0) - %$");

ObjectSet("FiboIn",OBJPROP_RAY,true);

ObjectSet("FiboIn",OBJPROP_BACK,true);

}

else

ObjectDelete("FiboIn");

}

 

//+------------------------------------------------------------------+

//| Indicator start function

//+------------------------------------------------------------------+

 

int start()

{

int shift = iBarShift(NULL,PERIOD_D1,Time[0]) + 1; // yesterday

HiPrice = iHigh(NULL,PERIOD_D1,shift);

LoPrice = iLow (NULL,PERIOD_D1,shift);

StartTime = iTime(NULL,PERIOD_D1,shift);

 

if(TimeDayOfWeek(StartTime)==0/*Sunday*/)

{//Add fridays high and low

HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_D1,shift+1));

LoPrice = MathMin(LoPrice,iLow(NULL,PERIOD_D1,shift+1));

}

 

Range = HiPrice-LoPrice;

 

DrawFibo();

 

return(0);

}

//+------------------------------------------------------------------+

Share this post


Link to post
Share on other sites

An other one

 

//+------------------------------------------------------------------+

//| Fibos.mq4 |

//| Developed by Coders' Guru |

//| http://www.xpworx.com |

//+------------------------------------------------------------------+

 

#property copyright "Coders' Guru"

#property link "http://www.xpworx.com"

string ver = "Last Modified: 2008.02.22 19:20";

 

#property indicator_chart_window

#property indicator_buffers 7

 

extern bool Higher_To_Lower = true; //else Lower_To_Higher

extern bool DrawVerticalLines = true;

extern int StartBar = 0;

extern int BarsBack = 20;

 

double f_1[];

double f_2[];

double f_3[];

double f_4[];

double f_5[];

double f_6[];

double f_7[];

 

void DeleteAllObjects()

{

int objs = ObjectsTotal();

string name;

for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)

{

name=ObjectName(cnt);

if (StringFind(name,"V_",0)>-1) ObjectDelete(name);

if (StringFind(name,"H_",0)>-1) ObjectDelete(name);

if (StringFind(name,"f_",0)>-1) ObjectDelete(name);

if (StringFind(name,"fib",0)>-1) ObjectDelete(name);

if (StringFind(name,"trend",0)>-1) ObjectDelete(name);

WindowRedraw();

}

}

 

 

void CalcFibo()

{

 

DeleteAllObjects();

 

int lowest_bar = iLowest(NULL,0,MODE_LOW,BarsBack,StartBar);

int highest_bar = iHighest(NULL,0,MODE_HIGH,BarsBack,StartBar);

 

double higher_point = 0;

double lower_point = 0;

higher_point=High[highest_bar];

lower_point=Low[lowest_bar];

 

if(DrawVerticalLines) DrawVerticalLine("V_UPPER",highest_bar,Blue);

if(DrawVerticalLines) DrawVerticalLine("V_LOWER",lowest_bar,Blue);

 

int i = 0;

 

if(Higher_To_Lower)

{

for(i = 0; i < 500; i++)

{

f_1 = higher_point;

f_2 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.236,Digits);

f_3 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.382,Digits);

f_4 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.5,Digits);

f_5 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.618,Digits);

f_6 = NormalizeDouble(lower_point+(higher_point-lower_point)*1.618,Digits);

f_7 = lower_point;

}

ObjectCreate("fib",OBJ_FIBO,0,0,higher_point,0,lower_point);

ObjectCreate("trend",OBJ_TREND,0,Time[highest_bar],higher_point,Time[lowest_bar],lower_point);

ObjectSet("trend",OBJPROP_STYLE,STYLE_DOT);

ObjectSet("trend",OBJPROP_RAY,false);

}

else

{

for(i = 0; i < 500; i++)

{

f_7 = higher_point;

f_6 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.236,Digits);

f_5 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.382,Digits);

f_4 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.5,Digits);

f_3 = NormalizeDouble(lower_point+(higher_point-lower_point)*0.618,Digits);

f_2 = NormalizeDouble(lower_point+(higher_point-lower_point)*1.618,Digits);

f_1 = lower_point;

}

DeleteAllObjects();

ObjectCreate("fib",OBJ_FIBO,0,0,lower_point,0,higher_point);

ObjectCreate("trend",OBJ_TREND,0,Time[lowest_bar],lower_point,Time[highest_bar],higher_point);

ObjectSet("trend",OBJPROP_STYLE,STYLE_DOT);

ObjectSet("trend",OBJPROP_RAY,false);

}

 

 

}

 

void DrawVerticalLine(string name , int bar , color clr)

{

if(ObjectFind(name)==false)

{

ObjectCreate(name,OBJ_VLINE,0,Time[bar],0);

ObjectSet(name,OBJPROP_COLOR,clr);

ObjectSet(name,OBJPROP_WIDTH,2);

WindowRedraw();

}

else

{

ObjectDelete(name);

ObjectCreate(name,OBJ_VLINE,0,Time[bar],0);

ObjectSet(name,OBJPROP_COLOR,clr);

ObjectSet(name,OBJPROP_WIDTH,2);

WindowRedraw();

}

 

}

 

 

 

int deinit()

{

DeleteAllObjects();

return (0);

}

 

int init()

{

DeleteAllObjects();

SetIndexBuffer(0,f_1);

SetIndexBuffer(1,f_2);

SetIndexBuffer(2,f_3);

SetIndexBuffer(3,f_4);

SetIndexBuffer(4,f_5);

SetIndexBuffer(5,f_6);

SetIndexBuffer(6,f_7);

return(0);

}

 

 

int start()

{

CalcFibo();

return(0);

}

Share this post


Link to post
Share on other sites

Fibo

EasyLanguage code for Fibonacci Retracement

 

not exactly what you are looking for... but it is something you can work on.

 

if someone knows the author, please post his credit here.

 

9754d1237020355-automatic-fibonacci-retracement-fibo.gif

.

Fibo_.txt

FIBO.gif.8b23265d3fed1c6de2fda77b0129a17f.gif

Edited by Tams

Share this post


Link to post
Share on other sites

Thank you Tams

 

not exactly but This is a really interesting coding indicator.

 

It works like the price channel, one of my preferate indicator.

 

I'm looking for something like this

rtrace.jpg.16698a989c49f69fcdff40f86a5bc3e0.jpg

Share this post


Link to post
Share on other sites
Thank you Tams

not exactly but This is a really interesting coding indicator.

It works like the price channel, one of my preferate indicator.

I'm looking for something like this

 

with some tweaking, you can modify the code to do what you want.

 

I am busy in the next 2 weeks, if I have some time in April, I will take a look at it for you.

Edited by Tams

Share this post


Link to post
Share on other sites

You are kind...

 

It looks great with the extension of the lignes without the old one

 

I was looking at your indicators

 

Your zigzag, price action etc are a good job

 

ThanX a lot

Share this post


Link to post
Share on other sites

I have problems with the numbers

 

Most of the time there are invisible

 

In 5 mn they appears sometimes

 

Is there an other way to code the numbers like in the pivots ?

 

variables:

 

right.time(0),

id.text.Dynamic_R(-1);

 

right.time = DateTime2ELTime( getappinfo(airightdispdatetime));

 

if currentbar = 1 then

begin

id.text.Dynamic_R = text_new( d, right.time, Dynamic_R, text(Dynamic_R));

end;

 

text_setstring(id.tl.Dynamic_R, text(Dynamic_R));

text_setlocation(id.tl.Dynamic_R, d, right.time, Dynamic_R);

Share this post


Link to post
Share on other sites

Also

 

I'd like to have the lignes in the empty right side of the chart

 

So if Right margin = 8

 

Dash.length( 8 ),

 

Well sometimes I have no lignes and when I put a nber like 66 I have them and after a while they desappear

 

The code looks great anyway

Share this post


Link to post
Share on other sites

the code should work in minute charts.

 

the lines and texts will behave erratically in non-minute charts.

(ie. tick, second, or daily charts)

Share this post


Link to post
Share on other sites

Thanx Tams for your answer

 

I use it in minute chart=

 

1

5

15

60

240

 

and it is erratic...

 

If I enter 8 (Right margin = 8)

 

it is only a dot or 3 bars long ligne

 

Then I change in ex 44

 

I have a long line

 

Then I change back to 8 and I have a 8 bars ligne

 

I can manage it but the main problem is that I have no number at all

Share this post


Link to post
Share on other sites

Here is the code I use

 

//----------------------------------------------------------------

// show number

//----------------------------------------------------------------

 

//----------------------------------------------------------------

variables:

//----------------------------------------------------------------

 

id.text.Dynamic_R(-1),

id.text.xFib0.764(-1),

id.text.xFib0.618(-1),

id.text.xFib0.500(-1),

id.text.xFib0.382(-1),

id.text.xFib0.236(-1),

id.text.Dynamic_S(-1);

 

if Show.number <> 0 then

begin

 

if currentbar = 1 then

begin

 

id.text.Dynamic_R = text_new( d, right.time, Dynamic_R, text(Dynamic_R));

id.text.xFib0.764 = text_new( d, right.time, xFib0.764, text(xFib0.764));

id.text.xFib0.618 = text_new( d, right.time, xFib0.618, text(xFib0.618));

id.text.xFib0.500 = text_new( d, right.time, xFib0.500, text(xFib0.500));

id.text.xFib0.382 = text_new( d, right.time, xFib0.382, text(xFib0.382));

id.text.xFib0.236 = text_new( d, right.time, xFib0.236, text(xFib0.236));

id.text.Dynamic_S = text_new( d, right.time, Dynamic_S, text(Dynamic_S));

 

 

text_setSize(id.text.Dynamic_R, NbreSize);

text_setSize(id.text.xFib0.764, NbreSize);

text_setSize(id.text.xFib0.618, NbreSize);

text_setSize(id.text.xFib0.500, NbreSize);

text_setSize(id.text.xFib0.382, NbreSize);

text_setSize(id.text.xFib0.236, NbreSize);

text_setSize(id.text.Dynamic_S, NbreSize);

 

text_setcolor(id.text.Dynamic_R, NbreColor );

text_setcolor(id.text.xFib0.764, NbreColor );

text_setcolor(id.text.xFib0.618, NbreColor );

text_setcolor(id.text.xFib0.500, NbreColor );

text_setcolor(id.text.xFib0.382, NbreColor );

text_setcolor(id.text.xFib0.236, NbreColor );

text_setcolor(id.text.Dynamic_S, NbreColor );

 

text_setstyle(id.text.Dynamic_R, 1,1 );

text_setstyle(id.text.xFib0.764, 1,1 );

text_setstyle(id.text.xFib0.618, 1,1 );

text_setstyle(id.text.xFib0.500, 1,1 );

text_setstyle(id.text.xFib0.382, 1,1 );

text_setstyle(id.text.xFib0.236, 1,1 );

text_setstyle(id.text.Dynamic_S, 1,1 );

 

end;

 

text_setstring(id.tl.Dynamic_R, text(Dynamic_R));

text_setstring(id.tl.xFib0.764, text(xFib0.764));

text_setstring(id.tl.xFib0.618, text(xFib0.618));

text_setstring(id.tl.xFib0.500, text(xFib0.500));

text_setstring(id.tl.xFib0.382, text(xFib0.382));

text_setstring(id.tl.xFib0.236, text(xFib0.236));

text_setstring(id.tl.Dynamic_S, text(Dynamic_S));

 

text_setlocation(id.tl.Dynamic_R, d, right.time, Dynamic_R);

text_setlocation(id.tl.xFib0.764, d, right.time, xFib0.764);

text_setlocation(id.tl.xFib0.618, d, right.time, xFib0.618);

text_setlocation(id.tl.xFib0.500, d, right.time, xFib0.500);

text_setlocation(id.tl.xFib0.382, d, right.time, xFib0.382);

text_setlocation(id.tl.xFib0.236, d, right.time, xFib0.236);

text_setlocation(id.tl.Dynamic_S, d, right.time, Dynamic_S);

 

end;

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.