# How can I get the actual price of each Fibo level ? - page 2

12

//A function that returns the price level:

//pass in the high pric to double high

//pass in the low pric to double low

//pass in one of these fibonacci levels 0,24.6,32.8,50.0,68.2,74.6,100 to double fibonacciLevel

//it returns the price level for your entered fibonacci level

//example:

//high:1.0100

//low:1.0000

//fibonacciLevel:61.8

//returns: 1.00618

***

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
• www.mql5.com
Predefined Macro Substitutions - Named Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
12

//How can I get the actual price of each Fibo level ?

//purpose: to help find the order entry position after a retracement over Elliot waves for uptrending or downtrending markets .

//remember: for uptrending market, a support level is needed to know what fibonacci level to place the order at using a buy limit order type.

//                   candle reversal patten or moving average crossover may be used for market order.

***

Moderator
124460

37650

30

NOT RELATED TO FIBO
2726

```//+------------------------------------------------------------------+
//|                                                GetFiboLevels.mq4 |
//|                         https://www.forexfactory.com/nicholishen |
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict
#property indicator_chart_window
#include <ChartObjects\ChartObjectsFibo.mqh>

class MyFibo : public CChartObjectFibo
{
public:
bool Attach(string name)
{
return Attach(ChartID(),name,0,2);
}
double LevelPrice(const int level_index)
{
double first = Price(0);
double last  = Price(1);
double range = fabs(first-last);
double fib   = range * LevelValue(level_index);
if(first<last)
return NormalizeDouble(last-fib,_Digits);
return NormalizeDouble(last+fib,_Digits);
}
};
//+------------------------------------------------------------------+
int OnInit()
{
ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{

MyFibo fibo;
if( (id==CHARTEVENT_OBJECT_CREATE || id == CHARTEVENT_OBJECT_DRAG)
&&ObjectGetInteger(0,sparam,OBJPROP_TYPE)==OBJ_FIBO
)
{
if(fibo.Attach(sparam))
{
string comm="";
int total=fibo.LevelsCount();
for(int i=0;i<total;i++)
comm+= string(fibo.LevelValue(i))+" = "+DoubleToString(fibo.LevelPrice(i),_Digits)+"\n";
Comment(comm);
fibo.Detach();
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
{
return(rates_total);
}```
10

John McGovern:

***

Hi John,

i am newbie in mq4 program. Could you tell me how to get the actual price of each fibo level base on number of Bars ie: 100 bars