Try to make new better Fibonacci Time, more clean screen with customize/optional fibonacci ratio to select.
still basic concept... repair needed, more participant would be better
I try to modified from below code indicator,
still basic concept... repair needed, more participant would be better
Inserted Code
//#include <ChartObjects/ChartObjectsFibo.mqh>
#include <ChartObjects/ChartObjectsLines.mqh>
CChartObjectTrend *Fibo;
CChartObjectTrend *Fibo1_618;
CChartObjectTrend *Fibo2;
int OnInit()
{
Fibo = new CChartObjectTrend();
Fibo1_618 = new CChartObjectTrend();
Fibo2 = new CChartObjectTrend();
double trange=MathAbs(Time[0]-Time[15]); //calculate bar distance,still wrong
Fibo.Create (0,"Fibo",0,Time[15],Open[15],Time[0],Open[0]);
Fibo2.Create (0,"Fibo2",0,Time[0],Open[0],Time[0]+trange,Open[0]);
Fibo1_618.Create(0,"Fibo1_618",0,Time[0],Open[0],Time[0]+(0.618*trange),Open[0]);
//# Allow user to drag object
Fibo.Color(clrRed);
Fibo.Hidden(false);
Fibo.Selectable(true);
Fibo.RayRight(false);
Fibo.Style(STYLE_DOT);
//Fibo.Attach(0,"Fibo2",0,1);
//Fibo.Attach(0,"Fibo1_618",0,1);
Fibo1_618.Color(clrBlue);
Fibo1_618.Hidden(false);
Fibo1_618.Selectable(true);
Fibo1_618.RayRight(false);
Fibo1_618.Style(STYLE_DOT);
Fibo1_618.Width(1);
//Fibo1_618.Attach(0,"Fibo",0,1);
Fibo2.Color(clrGreen);
Fibo2.Hidden(false);
Fibo2.Selectable(true);
Fibo2.RayRight(false);
Fibo2.Style(STYLE_DOT);
Fibo2.Width(1);
//Fibo2.Attach(0,"Fibo",0,1);
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
delete Fibo;
delete Fibo1_618;
delete Fibo2;
}
void OnTick()
{
string level_description;
double level_value;
string printString="Fibonacci Levels - ";
//# Get the two anchor prices
long p1 = Fibo.Time(0,OBJPROP_TIME);
long p2 = Fibo.Time(1,OBJPROP_TIME);
long trange=MathAbs(p1-p2);
//Fibo1.Delete();
//Fibo1.Create(0,"Fibo1",0,Time[0],Open[0],Time[0]+trange,Open[0]);
/*
//# Calculate range
double range=MathAbs(p1-p2);
for(int i=0;i<Fibo.LevelsCount();i++)
{
level_description=Fibo.LevelDescription(i);
//# Calculate price of level
level_value=(p2>p1)?p2-range*Fibo.Time(i):p2+range*Fibo.Time(i);
printString=StringFormat("%s %s:%.5f",printString,level_description,level_value);
}
Print(printString);
*/
} I try to modified from below code indicator,
Inserted Code
#include <ChartObjects/ChartObjectsFibo.mqh>
CChartObjectFibo *Fibo;
int OnInit()
{
Fibo = new CChartObjectFibo();
//#Create object and set some defaults
if(!Fibo.Create(0,"Fibonacci",0,Time[5],Open[5],Time[0],Open[0]))
{
return(INIT_FAILED);
}
//# Allow user to drag object
Fibo.Selectable(true);
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
delete Fibo;
}
void OnTick()
{
string level_description;
double level_value;
string printString="Fibonacci Levels - ";
//# Get the two anchor prices
double p1 = Fibo.GetDouble(OBJPROP_PRICE,0);
double p2 = Fibo.GetDouble(OBJPROP_PRICE,1);
//# Calculate range
double range=MathAbs(p1-p2);
for(int i=0;i<Fibo.LevelsCount();i++)
{
level_description=Fibo.LevelDescription(i);
//# Calculate price of level
level_value=(p2>p1)?p2-range*Fibo.LevelValue(i):p2+range*Fibo.LevelValue(i);
printString=StringFormat("%s %s:%.5f",printString,level_description,level_value);
}
Print(printString);
} Attached Image