Formula for drawing fibo channel

 
where can i find formula or mql source code for OBJ_FIBOCHANNEL?
 
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_FIBOCHANNEL
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_FIBOCHANNEL
  • www.mql5.com
OBJ_FIBOCHANNEL - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Marco vd Heijden #:
Here

I want to see the details of   ENUM_OBJECT : OBJ_FIBOCHANNEL and not  FiboChannelCreate

//+------------------------------------------------------------------+
//| Class CChartObjectFiboChannel.                                   |
//| Purpose: Class of the "Fibonacci Channel" object of chart.       |
//|          Derives from class CChartObjectTrend.                   |
//+------------------------------------------------------------------+
class CChartObjectFiboChannel : public CChartObjectTrend
  {
public:
                     CChartObjectFiboChannel(void);
                    ~CChartObjectFiboChannel(void);
   //--- method of creating the object
   bool              Create(long chart_id,const string name,const int window,
                            const datetime time1,const double price1,
                            const datetime time2,const double price2,
                            const datetime time3,const double price3);
   //--- method of identifying the object
   virtual int       Type(void) const { return(OBJ_FIBOCHANNEL); }
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CChartObjectFiboChannel::CChartObjectFiboChannel(void)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CChartObjectFiboChannel::~CChartObjectFiboChannel(void)
  {
  }
//+------------------------------------------------------------------+
//| Create object "Fibonacci Channel"                                |
//+------------------------------------------------------------------+
bool CChartObjectFiboChannel::Create(long chart_id,const string name,const int window,
                                     const datetime time1,const double price1,
                                     const datetime time2,const double price2,
                                     const datetime time3,const double price3)
  {
   if(!ObjectCreate(chart_id,name,OBJ_FIBOCHANNEL,window,time1,price1,time2,price2,time3,price3))
      return(false);
   if(!Attach(chart_id,name,window,3))
      return(false);
//--- successful
   return(true);
  }
i see this function but its not shown how levels are calculated, i want to see the calculation logic for fibo channel levels using price1 price2 price3 and time1 time2 and time3
 
Arpit T #: I want to see the details of   ENUM_OBJECT : OBJ_FIBOCHANNEL and not  FiboChannelCreate i see this function but its not shown how levels are calculated, i want to see the calculation logic for fibo channel levels using price1 price2 price3 and time1 time2 and time3

Read the documentation again, that Marco vd Heijden linked to in his post #1  ... Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_FIBOCHANNEL

Note

For Fibonacci Channel, it is possible to specify the mode of continuation of its display to the right and/or left (OBJPROP_RAY_RIGHT and OBJPROP_RAY_LEFT properties accordingly).

You can also specify the number of line-levels, their values and color.

//+------------------------------------------------------------------+
//| Set number of levels and their parameters                        |
//+------------------------------------------------------------------+
bool FiboChannelLevelsSet(int             levels,             // number of level lines
                          double          &values[],          // values of level lines
                          color           &colors[],          // color of level lines
                          ENUM_LINE_STYLE &styles[],          // style of level lines
                          int             &widths[],          // width of level lines
                          const long      chart_ID=0,         // chart's ID
                          const string    name="FiboChannel") // object name
  {
//--- check array sizes
   if(levels!=ArraySize(colors) || levels!=ArraySize(styles) ||
      levels!=ArraySize(widths) || levels!=ArraySize(widths))
     {
      Print(__FUNCTION__,": array length does not correspond to the number of levels, error!");
      return(false);
     }
//--- set the number of levels
   ObjectSetInteger(chart_ID,name,OBJPROP_LEVELS,levels);
//--- set the properties of levels in the loop
   for(int i=0;i<levels;i++)
     {
      //--- level value
      ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,values[i]);
      //--- level color
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELCOLOR,i,colors[i]);
      //--- level style
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELSTYLE,i,styles[i]);
      //--- level width
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELWIDTH,i,widths[i]);
      //--- level description
      ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,DoubleToString(100*values[i],1));
     }
//--- successful execution
   return(true);
  }
 

Level values are like 23.6,38.2,50.0

I am interested to find the Level price or alternatively i want to draw a trendline so i can get its price from ObjectGetDouble property

 
Arpit T #: Level values are like 23.6,38.2,50.0 I am interested to find the Level price or alternatively i want to draw a trendline so i can get its price from ObjectGetDouble property

We are having a language barrier problem here.

I have just shown you a screenshot of where the levels are set via the properties, as well as the code example from the documentaion showing you how to set it via the code. You can set your own levels or read the default levels in code as well using "ObjectSetDouble" to set levels and "ObjectGetDouble" to read existing levels. The equivalent for the level descriptions, colours, etc.

What exactly to do want more?

 

To calculate the price at which those levels are displayed at, use normal math. You know the start and end price, then simply apply the ratio.

 
Fernando Carreiro #:

We are having a language barrier problem here.

I have just showed you a screenshot of where the levels are set via the properties, as well as the code example from the documentaion showing you how to set it via the code. You can set your own levels or read the default levels in code as well using "ObjectSetDouble" to set levels and "ObjectGetDouble" to read existing levels. The equivalent for the level descriptions, colours, etc.

What exactly to do want more?

i have tried this, 

ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,values[i]);

is for setting Level values and not level price, 

Level values = extension e.g. 23.6, 61.8 etc

Level price = price at level values e.g. at bar zero 23.6 = 1800.2, 61.8 = 1805.2 etc

I want Level price using ObjectGetDouble not the level values. Thanks

 
Arpit T #: i have tried this,  is for setting Level values and not level price, Level values = extension e.g. 23.6, 61.8 etc Level price = price at level values e.g. at bar zero 23.6 = 1800.2, 61.8 = 1805.2 etc I want Level price using ObjectGetDouble not the level values. Thanks

You can't set level prices only level ratio values.

[Level Price] = [Start Price] + ( [End Price] - [Start Price] ) * [Level Value]

[Level Value] is the level value like 0.236 or 0.382, etc.

EDIT: Swap Start and End prices for reverse levels.

 
Fernando Carreiro #:

You can't set level prices only level ratio values.

[Level Price] = [Start Price] + ( [End Price] - [Start Price] ) * [Level Value]

[Level Value] is the level value like 0.236 or 0.382, etc.

thanks i am going to try this, You are awesome!

 
Fernando Carreiro #:

You can't set level prices only level ratio values.

[Level Price] = [Start Price] + ( [End Price] - [Start Price] ) * [Level Value]

[Level Value] is the level value like 0.236 or 0.382, etc.

EDIT: Swap Start and End prices for reverse levels.

A fibonacci channel has three points so which is Start price and End price in this case?

Reason: