Fibonacci Levels:

kriss.ro  

hello, maybe my question is too basic for a lot of you guys, and for that i apologize. but this is the first time that i want to work with fibonacci lines.

i have created the code to import Fibonacci retrecment lines into my EA and it works.

but how can i return the value of the fibo levels?

for example the line 23.6 is in this moment is .......... price. how can i return the value (price) of this line?

i have read the documentation and a lot of pages of Forum and i did not fined my answer.

Fernando Carreiro  
kriss.ro: hello, maybe my question is too basic for a lot of you guys, and for that i apologize. but this is the first time that i want to work with fibonacci lines. i have created the code to import Fibonacci retrecment lines into my EA and it works. but how can i return the value of the fibo levels? for example the line 23.6 is in this moment is .......... price. how can i return the value (price) of this line? i have read the documentation and a lot of pages of Forum and i did not fined my answer.

If you are using a OBJ_FIBO graphical object and setting the various levels via the OBJPROP_LEVELVALUE property via ObjectSetDouble, then the prices on which those levels fall are not retrievable programmatically.

You will have to calculate that yourself in the code, given that you know the start and end anchor points of the graphical object itself. It is simple maths.

OBJ_FIBO - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
OBJ_FIBO - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
OBJ_FIBO - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
Lorentzos Roussos  
kriss.ro:

hello, maybe my question is too basic for a lot of you guys, and for that i apologize. but this is the first time that i want to work with fibonacci lines.

i have created the code to import Fibonacci retrecment lines into my EA and it works.

but how can i return the value of the fibo levels?

for example the line 23.6 is in this moment is .......... price. how can i return the value (price) of this line?

i have read the documentation and a lot of pages of Forum and i did not fined my answer.

Here is a test case , attach , create fibo with mouse 

int OnInit()
  {
//--- create timer
  // EventSetTimer(60);
  ChartSetInteger(ChartID(),CHART_EVENT_OBJECT_CREATE,true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
  // EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
  if(id==CHARTEVENT_OBJECT_CREATE){
  if(ObjectGetInteger(ChartID(),sparam,OBJPROP_TYPE)==OBJ_FIBO){
  int total_levels=(int)ObjectGetInteger(ChartID(),sparam,OBJPROP_LEVELS);
  Print("Fibo spotted , "+IntegerToString(total_levels)+" levels");
  double onePrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,0);//get   0% price
  double zeroPrice=ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,1);//get 100% price
  double range=onePrice-zeroPrice;
  for(int i=0;i<total_levels;i++)
     {
     double value=ObjectGetDouble(ChartID(),sparam,OBJPROP_LEVELVALUE,i);
     double price=zeroPrice+range*value;
     Print("Level["+IntegerToString(i)+"] :: "+DoubleToString(value,2)+" :: "+DoubleToString(price,_Digits));
     }
  }}
  }
//+------------------------------------------------------------------+
kriss.ro  

well, i want my EA to be fully Automated. so i cant do anything manually.

thanks anyway. its not that hard to calculate the lines.

Lorentzos Roussos  
kriss.ro #:

well, i want my EA to be fully Automated. so i cant do anything manually.

thanks anyway. its not that hard to calculate the lines.

Ow you meant how to calculate , i thought it picked them up from the chart , sorry :D