Fibonacci Channel

 

Hi dear masters.

Visually, when the Fibonacci Channel tool is drawn on a high or low in MetaTrader by mouse, the third point is automatically set by default itself. How can we program the calculations for this default configuration that is handled within MetaTrader’s internal buffer?

It doesn’t matter whether the solution is for MQL4 or MQL5.

Thank you. 

 
V0R73X:

Hi dear masters.

Visually, when the Fibonacci Channel tool is drawn on a high or low in MetaTrader by mouse, the third point is automatically set by default itself. How can we program the calculations for this default configuration that is handled within MetaTrader’s internal buffer?

It doesn’t matter whether the solution is for MQL4 or MQL5.

Thank you. 

MT5...

  1. Attach the tool.
  2. Right click on chart.
  3. Click on Object List.
  4. Edit the tool.
Fibo_Channel
 
Ryan L Johnson #:

MT5...

  1. Attach the tool.
  2. Right click on chart.
  3. Click on Object List.
  4. Edit the tool.
You did not understand the question.
 
V0R73X:

Hi dear masters.

Visually, when the Fibonacci Channel tool is drawn on a high or low in MetaTrader by mouse, the third point is automatically set by default itself. How can we program the calculations for this default configuration that is handled within MetaTrader’s internal buffer?

It doesn’t matter whether the solution is for MQL4 or MQL5.

Thank you. 

if you are manually drawing by mouse, you have to write code so if drawn object is detected it can set as per your logic

Use

1. ObjectFind

2. ObjectName where type = OBJ_FIBOCHANNEL

3. Update the manually drawn object as you wish using time3,price3

 
Rajesh Kumar Nait #:

if you are manually drawing by mouse, you have to write code so if drawn object is detected it can set as per your logic

Use

1. ObjectFind

2. ObjectName where type = OBJ_FIBOCHANNEL

3. Update the manually drawn object as you wish using time3,price3

Yes, but the question is how to implement it without using the mouse and get time3,price3 values from MT’s buffer. 

Thanks anyway.
 
V0R73X #:
Yes, but the question is how to implement it without using the mouse and get time3,price3 values from MT’s buffer. 

Thanks anyway.
Are you comfortable to do a single click or mouse? If yes, then use ChartEvent to detect mouse click and plot fibo channel on price which you can pick from chart as per your logic else map keyboard events on key press. you can store price value of Fibo Channel using ObjectGetDouble and save it in MT's buffer and use this data to plot when keyboard event or mouse click is detected.
 
V0R73X:

Hi dear masters.

Use iHighest/iLowest to find the index of the Highest/Smallest value in a range. Use iHigh/iLow to retrieve the actual High/Low price of that bar.

Once you have the high and low prices, calculating the Fibonacci retracement levels is straightforward:

fib50 = (highest_price+lowest_price)/2;
fib38point2 = 38.2*highest_price+lowest_price*61.8;
fib61point8 = 61.8*highest_price+lowest_price*38.2;
//Other fiblevels is similar

 
Rajesh Kumar Nait #:
Are you comfortable to do a single click or mouse? If yes, then use ChartEvent to detect mouse click and plot fibo channel on price which you can pick from chart as per your logic else map keyboard events on key press. you can store price value of Fibo Channel using ObjectGetDouble and save it in MT's buffer and use this data to plot when keyboard event or mouse click is detected.

I want to code it without mouse clicks. I would like to know how MetaTrader determines the third price and time with just a single click on a High/Low, the issue is that MetaTrader behaves differently each time due to changes in the scale of chart!

 
V0R73X #:

I want to code it …

// Calculate the mid-step value for the Fibonacci Channel by finding the difference
// between the maximum and minimum price on the chart, and then dividing it by 5.
const double fibchnlMidStep = (ChartGetDouble(chart_id, CHART_PRICE_MAX) - ChartGetDouble(chart_id, CHART_PRICE_MIN)) / 5;

// Add the mid-step value to the start point to determine the third parameter of the Fibonacci Channel.

 
MAHA #:
// Calculate the mid-step value for the Fibonacci Channel by finding the difference
// between the maximum and minimum price on the chart, and then dividing it by 5.
const double fibchnlMidStep = (ChartGetDouble(chart_id, CHART_PRICE_MAX) - ChartGetDouble(chart_id, CHART_PRICE_MIN)) / 5;

// Add the mid-step value to the start point to determine the third parameter of the Fibonacci Channel.

Thank you so much.
 
instead of drawing the fibo channel object, you can also draw individual horizontal lines at fibonacci retracements from a price level