- Home
- Community
- Programming
- fib expansion
Edit Your Comment
fib expansion
Oct 26, 2010 at 04:29
Member Since Oct 12, 2010
7 posts
Hi all.
I'm programming a tool that uses the object 'Fib Expansion', to Limit Orders, Sl and TP.
But I could not do the calculations and not even get the values of prices that are in these respective levels of fibexpansion. Can someone help me?
I referred to as an attached picture of what I want to do .
Thanks:)
herer is the first inicial code:
//+------------------------------------------------------------------+
//| forexavancado_com_i-fiboexp.mq4 |
//| forexavancado.com |
//| https://www.forexavancado.com |
//+------------------------------------------------------------------+
#property copyright 'forexavancado.com'
#property link 'https://www.forexavancado.com'
extern string object_name='fibozoio';
extern double lot=0.01;
extern double level0=2.098,level1=1.618,level2=1.270,level3=1,level4=0.618,level5=0.380,level6=0.098,level7=-1.270,level8=-1.618;
extern int time_frame=60;
double level0p,level1p,level2p,level3p,level4p,level5p,level6p,level7p,level8p;
//+------------------------------------------------------------------+
int init() {
return(0);
}
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
int start()
{
if(ObjectFind(object_name) != -1){
MakeFibo(Time[0],High[0],Time[0],High[0]-100*Point);
Comment ('Obj: '+(ObjectGetFiboDescription(object_name, 0)),'/n level1p: '+level1p );
//Buy compare
if(iCustom(Symbol(),time_frame,'forexavancado_com',0,0) > iCustom(Symbol(),time_frame,'forexavancado_com',1,0)){
ObjectSet(object_name, OBJPROP_COLOR,Green); ObjectSet(object_name, OBJPROP_LEVELCOLOR,Green);ObjectSet(object_name, OBJPROP_FIBOLEVELS,9);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+0,level0);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+1,level1);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+2,level2);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+3,level3);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+4,level4);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+5,level5);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+6,level6);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+7,level7);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+8,level8);
}
//Sell compare
else {
ObjectSet(object_name, OBJPROP_COLOR,Red); ObjectSet(object_name, OBJPROP_LEVELCOLOR,Red);ObjectSet(object_name, OBJPROP_FIBOLEVELS,9);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+0,level0);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+1,level1);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+2,level2);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+3,level3);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+4,level4);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+5,level5);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+6,level6);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+7,level7);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+8,level8);
}
}
return(0);
}
//+------------------------------------------------------------------+
void MakeFibo(datetime StartTime, double HiPrice, datetime EndTime,double LoPrice)
{
double Dif = HiPrice-LoPrice;
level0p = LoPrice + (Dif*level0);
level1p = LoPrice + (Dif*level1);
level2p = LoPrice + (Dif*level2);
level3p = LoPrice + (Dif*level3);
level4p = LoPrice + (Dif*level4);
level5p = LoPrice + (Dif*level5);
level6p = LoPrice + (Dif*level6);
level7p = LoPrice + (Dif*level7);
level8p = LoPrice + (Dif*level8);
return(0);
}
I'm programming a tool that uses the object 'Fib Expansion', to Limit Orders, Sl and TP.
But I could not do the calculations and not even get the values of prices that are in these respective levels of fibexpansion. Can someone help me?
I referred to as an attached picture of what I want to do .
Thanks:)
herer is the first inicial code:
//+------------------------------------------------------------------+
//| forexavancado_com_i-fiboexp.mq4 |
//| forexavancado.com |
//| https://www.forexavancado.com |
//+------------------------------------------------------------------+
#property copyright 'forexavancado.com'
#property link 'https://www.forexavancado.com'
extern string object_name='fibozoio';
extern double lot=0.01;
extern double level0=2.098,level1=1.618,level2=1.270,level3=1,level4=0.618,level5=0.380,level6=0.098,level7=-1.270,level8=-1.618;
extern int time_frame=60;
double level0p,level1p,level2p,level3p,level4p,level5p,level6p,level7p,level8p;
//+------------------------------------------------------------------+
int init() {
return(0);
}
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
int start()
{
if(ObjectFind(object_name) != -1){
MakeFibo(Time[0],High[0],Time[0],High[0]-100*Point);
Comment ('Obj: '+(ObjectGetFiboDescription(object_name, 0)),'/n level1p: '+level1p );
//Buy compare
if(iCustom(Symbol(),time_frame,'forexavancado_com',0,0) > iCustom(Symbol(),time_frame,'forexavancado_com',1,0)){
ObjectSet(object_name, OBJPROP_COLOR,Green); ObjectSet(object_name, OBJPROP_LEVELCOLOR,Green);ObjectSet(object_name, OBJPROP_FIBOLEVELS,9);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+0,level0);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+1,level1);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+2,level2);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+3,level3);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+4,level4);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+5,level5);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+6,level6);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+7,level7);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+8,level8);
}
//Sell compare
else {
ObjectSet(object_name, OBJPROP_COLOR,Red); ObjectSet(object_name, OBJPROP_LEVELCOLOR,Red);ObjectSet(object_name, OBJPROP_FIBOLEVELS,9);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+0,level0);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+1,level1);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+2,level2);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+3,level3);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+4,level4);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+5,level5);
ObjectSet(object_name, OBJPROP_FIRSTLEVEL+6,level6);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+7,level7);ObjectSet(object_name, OBJPROP_FIRSTLEVEL+8,level8);
}
}
return(0);
}
//+------------------------------------------------------------------+
void MakeFibo(datetime StartTime, double HiPrice, datetime EndTime,double LoPrice)
{
double Dif = HiPrice-LoPrice;
level0p = LoPrice + (Dif*level0);
level1p = LoPrice + (Dif*level1);
level2p = LoPrice + (Dif*level2);
level3p = LoPrice + (Dif*level3);
level4p = LoPrice + (Dif*level4);
level5p = LoPrice + (Dif*level5);
level6p = LoPrice + (Dif*level6);
level7p = LoPrice + (Dif*level7);
level8p = LoPrice + (Dif*level8);
return(0);
}
Member Since Oct 28, 2009
1435 posts
Oct 29, 2010 at 09:03
Member Since Oct 28, 2009
1435 posts
Hi,
I've taken a quick look at this and I'm not sure I understand what you are doing.
A Fib expansion has to be placed on specific points on the chart and you are just setting the high to the high of the current bar and working out a low as that -100 pips.
Do you have any charts indicating what you are trying to do?
Regards Steve
I've taken a quick look at this and I'm not sure I understand what you are doing.
A Fib expansion has to be placed on specific points on the chart and you are just setting the high to the high of the current bar and working out a low as that -100 pips.
Do you have any charts indicating what you are trying to do?
Regards Steve
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Oct 29, 2010 at 15:31
(edited Oct 29, 2010 at 15:34)
Member Since Oct 12, 2010
7 posts
Hello Steve,
I put a print screen below the first post attached.
The idea is, when I draw a fib expansion manually with the name of object 'fibzoio', the EA place limit orders or stop order at levels described in the print screen as well as the stop and take profit.
I know the code I sent is wrong in relation to levels of fib expansion, what I need is to get the prices where are these levels described.
extern double level0=2.098, level1=1.618, level2=1.270, level3=1, level4=0.618, level5=0.380, level6=0.098, level7=-1.270, level8=-1.618;
I do not know which formula to use to get those prices at levels
I hope this clarifies
Any questions ask me ok
My english is not so good ok be patient and thank you:)
I put a print screen below the first post attached.
The idea is, when I draw a fib expansion manually with the name of object 'fibzoio', the EA place limit orders or stop order at levels described in the print screen as well as the stop and take profit.
I know the code I sent is wrong in relation to levels of fib expansion, what I need is to get the prices where are these levels described.
extern double level0=2.098, level1=1.618, level2=1.270, level3=1, level4=0.618, level5=0.380, level6=0.098, level7=-1.270, level8=-1.618;
I do not know which formula to use to get those prices at levels
I hope this clarifies
Any questions ask me ok
My english is not so good ok be patient and thank you:)
Member Since Oct 28, 2009
1435 posts
Nov 01, 2010 at 08:25
Member Since Oct 28, 2009
1435 posts
Okay, the first thing I notice is that I think you are using the Fib Expansion incorrectly.
The Fib Expansion is supposed to tell you where the next wave of an Elliot Wave is potentially going to finish. So, in your example you would be looking to place a buy order not a sell order.
Take a look here.
https://ta.mql4.com/linestudies/fibonacci_expansion
I guess it's possible to use it in other ways and you might have found another way that works. Just thought I'd point it out to you.
The Fib Expansion is supposed to tell you where the next wave of an Elliot Wave is potentially going to finish. So, in your example you would be looking to place a buy order not a sell order.
Take a look here.
https://ta.mql4.com/linestudies/fibonacci_expansion
I guess it's possible to use it in other ways and you might have found another way that works. Just thought I'd point it out to you.
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Nov 01, 2010 at 11:10
Member Since Oct 12, 2010
7 posts
steve just that, found another way to use the 'fibexpansion,' I know about the original concepts to use this tool as described in the link you sent, but found a way to use them in favor of the trend for entries trades.
Continuing with the previous post at the moment my biggest doubt is the formula that I use in MQL to find these levels described.
Hugs and thanks again
Continuing with the previous post at the moment my biggest doubt is the formula that I use in MQL to find these levels described.
Hugs and thanks again
Member Since Oct 28, 2009
1435 posts
Nov 01, 2010 at 11:17
Member Since Oct 28, 2009
1435 posts
Okay, cool. So the second question then is are you using the default fib expansion in MT4 to draw the fibs as I see you have a lot of extra lines in there. Did you add these manually to the default fib lines or are all your lines drawn in manually?
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Nov 01, 2010 at 14:24
Member Since Oct 12, 2010
7 posts
yes i draw any fib manually and automatic the EA take the only the fib with 'object_name' variable, and changes color according to comparisons made with my icustom and also adds the levesl described in 'extern variables'.
If you want, change the comparisons of buying and selling 'icustom' by an average mobile 'ima' or any other comparison to test.
After that we'd have to for orders, and then the case might situate ourselves some point he would object to changing 'modify' SL and TP orders automatically.
If you want, change the comparisons of buying and selling 'icustom' by an average mobile 'ima' or any other comparison to test.
After that we'd have to for orders, and then the case might situate ourselves some point he would object to changing 'modify' SL and TP orders automatically.
Member Since Oct 28, 2009
1435 posts
Nov 01, 2010 at 15:22
Member Since Oct 28, 2009
1435 posts
Okay, yes I can see how it works now, the fog of the weekend is beginning to clear!
11:15, restate my assumptions: 1. Mathematics is the language of nature. 2. Everything around us can be represented and understood through numbers. 3. If you graph these numbers, patterns emerge. Therefore: There are patterns everywhere in nature.
Nov 01, 2010 at 20:31
(edited Nov 01, 2010 at 20:31)
Member Since Oct 12, 2010
7 posts
a friend tell me this is the formula
void MakeFibo()
{
double priceA = ObjectGet(object_name,OBJPROP_PRICE1);
double priceB = ObjectGet(object_name,OBJPROP_PRICE2);
double priceC = ObjectGet(object_name,OBJPROP_PRICE3);
double amplitude= priceB-priceA;
level0p = priceC + (amplitude*level0);
level1p = priceC + (amplitude*level1);
level2p = priceC + (amplitude*level2);
level3p = priceC + (amplitude*level3);
level4p = priceC + (amplitude*level4);
level5p = priceC + (amplitude*level5);
level6p = priceC + (amplitude*level6);
level7p = priceC + (amplitude*level7);
level8p = priceC + (amplitude*level8);
return(0);
}
void MakeFibo()
{
double priceA = ObjectGet(object_name,OBJPROP_PRICE1);
double priceB = ObjectGet(object_name,OBJPROP_PRICE2);
double priceC = ObjectGet(object_name,OBJPROP_PRICE3);
double amplitude= priceB-priceA;
level0p = priceC + (amplitude*level0);
level1p = priceC + (amplitude*level1);
level2p = priceC + (amplitude*level2);
level3p = priceC + (amplitude*level3);
level4p = priceC + (amplitude*level4);
level5p = priceC + (amplitude*level5);
level6p = priceC + (amplitude*level6);
level7p = priceC + (amplitude*level7);
level8p = priceC + (amplitude*level8);
return(0);
}
Member Since Dec 15, 2010
11 posts
*Commercial use and spam will not be tolerated, and may result in account termination.
Tip: Posting an image/youtube url will automatically embed it in your post!
Tip: Type the @ sign to auto complete a username participating in this discussion.