Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Like Tree1Likes

Reply
Old 01-25-2009, 01:27 PM   #1
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Automatic Fibonacci Retracement

Hello

I am a beginner in EL...

Is there a free code to draw lignes of the retracements on the right side of the charts when PivotHighVSBar found a new pivot like in the link below?

https://www.tradestation.com/Discuss...?Topic_ID=8864
aaa is offline  
Reply With Quote
Old 01-26-2009, 01:56 PM   #2
zdo

Join Date: Nov 2007
Location: boonies
Posts: 1,349
Ignore this user

Thanks: 317
Thanked 355 Times in 256 Posts
Blog Entries: 104

Re: Automatic Fibonacci Retracement

Look at ZigZag2.5
You might have to modify or comment a bunch out but the framework for what you want to do is in there...
zdo is offline  
Reply With Quote
Old 02-01-2009, 04:33 AM   #3
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: Automatic Fibonacci Retracement

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",OBJPRO P_TIME2, StartTime);
ObjectSet("FiboUp",OBJPRO P_TIME1, StartTime);
ObjectSet("FiboUp",OBJPRO P_PRICE1,HiPrice+Range);
ObjectSet("FiboUp",OBJPRO P_PRICE2,HiPrice);
}
ObjectSet("FiboUp",OBJPRO P_LEVELCOLOR,UpperFiboCol or);
ObjectSet("FiboUp",OBJPRO P_FIBOLEVELS,13);
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription( "FiboUp",0,"(100.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription( "FiboUp",1,"(123.6%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription( "FiboUp",2,"(138.2%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription( "FiboUp",3,"(150.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription( "FiboUp",4,"(161.8%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription( "FiboUp",5,"(176.4%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription( "FiboUp",6,"(200.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription( "FiboUp",7,"(223.6%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+8,1.500); ObjectSetFiboDescription( "FiboUp",8,"(250.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+9,1.618); ObjectSetFiboDescription( "FiboUp",9,"(261.8%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+10,2.000); ObjectSetFiboDescription( "FiboUp",10,"(300.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+11,2.500); ObjectSetFiboDescription( "FiboUp",11,"(350.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+12,3.000); ObjectSetFiboDescription( "FiboUp",12,"(400.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+13,3.500); ObjectSetFiboDescription( "FiboUp",13,"(450.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_FIRSTLEVEL+14,4.000); ObjectSetFiboDescription( "FiboUp",14,"(500.0%) - %$");
ObjectSet("FiboUp",OBJPRO P_RAY,true);
ObjectSet("FiboUp",OBJPRO P_BACK,true);

if(ObjectFind("FiboDn") == -1)
ObjectCreate("FiboDn",OBJ _FIBO,0,StartTime,LoPrice-Range,StartTime,LoPrice);
else
{
ObjectSet("FiboDn",OBJPRO P_TIME2, StartTime);
ObjectSet("FiboDn",OBJPRO P_TIME1, StartTime);
ObjectSet("FiboDn",OBJPRO P_PRICE1,LoPrice-Range);
ObjectSet("FiboDn",OBJPRO P_PRICE2,LoPrice);
}
ObjectSet("FiboDn",OBJPRO P_LEVELCOLOR,LowerFiboCol or);
ObjectSet("FiboDn",OBJPRO P_FIBOLEVELS,19);
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription( "FiboDn",0,"(0.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription( "FiboDn",1,"(-23.6%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription( "FiboDn",2,"(-38.2%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription( "FiboDn",3,"(-50.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription( "FiboDn",4,"(-61.8%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription( "FiboDn",5,"(-76.4%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription( "FiboDn",6,"(-100.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription( "FiboDn",7,"(-123.6%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+8,1.382); ObjectSetFiboDescription( "FiboDn",8,"(-138.2%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+9,1.500); ObjectSetFiboDescription( "FiboDn",9,"(-150.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+10,1.618); ObjectSetFiboDescription( "FiboDn",10,"(-161.8%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+11,1.764); ObjectSetFiboDescription( "FiboDn",11,"(-176.4%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+12,2.000); ObjectSetFiboDescription( "FiboDn",12,"(-200.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+13,2.500); ObjectSetFiboDescription( "FiboDn",13,"(-250.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+14,3.000); ObjectSetFiboDescription( "FiboDn",14,"(-300.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+15,3.500); ObjectSetFiboDescription( "FiboDn",15,"(-350.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+16,4.000); ObjectSetFiboDescription( "FiboDn",16,"(-400.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+17,4.500); ObjectSetFiboDescription( "FiboDn",17,"(-450.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_FIRSTLEVEL+18,5.000); ObjectSetFiboDescription( "FiboDn",18,"(-500.0%) - %$");
ObjectSet("FiboDn",OBJPRO P_RAY,true);
ObjectSet("FiboDn",OBJPRO P_BACK,true);

if(InnerFibs)
{
if(ObjectFind("FiboIn") == -1)
ObjectCreate("FiboIn",OBJ _FIBO,0,StartTime,HiPrice ,StartTime+PERIOD_D1*60,L oPrice);
else
{
ObjectSet("FiboIn",OBJPRO P_TIME2, StartTime);
ObjectSet("FiboIn",OBJPRO P_TIME1, StartTime+PERIOD_D1*60);
ObjectSet("FiboIn",OBJPRO P_PRICE1,HiPrice);
ObjectSet("FiboIn",OBJPRO P_PRICE2,LoPrice);
}
ObjectSet("FiboIn",OBJPRO P_LEVELCOLOR,MainFiboColo r);
ObjectSet("FiboIn",OBJPRO P_FIBOLEVELS,7);
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription( "FiboIn",0,"Daily LOW (0.0) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription( "FiboIn",1,"(23.6) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription( "FiboIn",2,"(38.2) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription( "FiboIn",3,"(50.0) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription( "FiboIn",4,"(61.8) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription( "FiboIn",5,"(76.4) - %$");
ObjectSet("FiboIn",OBJPRO P_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription( "FiboIn",6,"Daily HIGH (100.0) - %$");
ObjectSet("FiboIn",OBJPRO P_RAY,true);
ObjectSet("FiboIn",OBJPRO P_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,shif t);
LoPrice = iLow (NULL,PERIOD_D1,shift);
StartTime = iTime(NULL,PERIOD_D1,shif t);

if(TimeDayOfWeek(StartTim e)==0/*Sunday*/)
{//Add fridays high and low
HiPrice = MathMax(HiPrice,iHigh(NUL L,PERIOD_D1,shift+1));
LoPrice = MathMin(LoPrice,iLow(NULL ,PERIOD_D1,shift+1));
}

Range = HiPrice-LoPrice;

DrawFibo();

return(0);
}
//+------------------------------------------------------------------+
aaa is offline  
Reply With Quote
Old 02-01-2009, 04:34 AM   #4
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: Automatic Fibonacci Retracement

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,B arsBack,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[i] = higher_point;
f_2[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.236,Digits );
f_3[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.382,Digits );
f_4[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.5,Digits);
f_5[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.618,Digits );
f_6[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*1.618,Digits );
f_7[i] = lower_point;
}
ObjectCreate("fib",OBJ_FI BO,0,0,higher_point,0,low er_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[i] = higher_point;
f_6[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.236,Digits );
f_5[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.382,Digits );
f_4[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.5,Digits);
f_3[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*0.618,Digits );
f_2[i] = NormalizeDouble(lower_poi nt+(higher_point-lower_point)*1.618,Digits );
f_1[i] = lower_point;
}
DeleteAllObjects();
ObjectCreate("fib",OBJ_FI BO,0,0,lower_point,0,high er_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)==fals e)
{
ObjectCreate(name,OBJ_VLI NE,0,Time[bar],0);
ObjectSet(name,OBJPROP_CO LOR,clr);
ObjectSet(name,OBJPROP_WI DTH,2);
WindowRedraw();
}
else
{
ObjectDelete(name);
ObjectCreate(name,OBJ_VLI NE,0,Time[bar],0);
ObjectSet(name,OBJPROP_CO LOR,clr);
ObjectSet(name,OBJPROP_WI DTH,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);
}
aaa is offline  
Reply With Quote
Old 02-08-2009, 08:05 AM   #5

Join Date: Jul 2008
Location: Valdosta, GA
Posts: 48
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Automatic Fibonacci Retracement

Are there any comparable automatic Fib retracement codes for tradestation?
Thanks.


Curtis
clbradley is offline  
Reply With Quote
Old 02-09-2009, 03:47 AM   #6
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: Automatic Fibonacci Retracement

That's what I'm looking for....
aaa is offline  
Reply With Quote
Old 02-09-2009, 08:35 AM   #7
gus

Join Date: Apr 2007
Location: Logan
Posts: 3
Ignore this user

Thanks: 0
Thanked 1 Time in 1 Post

Re: Automatic Fibonacci Retracement

If you look on the tradestation forum there are a number of discussions.

https://www.tradestation.com/Discuss...Topic_ID=33842
gus is offline  
Reply With Quote
The Following User Says Thank You to gus For This Useful Post:
aaa (03-14-2009)
Old 03-14-2009, 04:35 AM   #8
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: Automatic Fibonacci Retracement

Thank you Gus for your information

If you find something could you post some code here ?
aaa is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retracement Vs. Reversal cowseathay The Wyckoff Forum 25 02-04-2009 04:31 PM
GBP/USD Perfect 50% Retracement Off NFP DannyBly Forex Trading Laboratory 12 06-09-2008 03:47 AM
It's Fibonacci Fridays! cooter General Discussion 2 07-14-2007 12:10 AM
Fibonacci trading Sniper Technical Analysis 9 01-27-2007 04:28 AM
Retracement Methodologies Soultrader Technical Analysis 1 12-05-2006 12:45 PM

All times are GMT -4. The time now is 12:23 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.