Building an Expert Advisor to manage a manually drawn Fibonacci retracement
The Fibonacci Trader Plug-in can monitor any Fibonacci retracement on a chart. It does this by searching for a Fibonacci retracement by name.
After you manually draw your Fibonacci retracement on your price chart, record the exact name of the Fibonacci retracement. This name will be referenced in your Expert Advisor by the fnIsFiboLevelBroken.
To build an Expert Advisor that opens a BUY trade when a Fibonacci retracement has been broken, drag and drop the Fibonacci function fnIsFiboLevelBroken on to the drawing pad and connect it before the Logic element.
Set the parameters of the fnIsFiboLevelBroken function:
- name: set the value of the name parameter to the exact name of the Fibonacci retracement. For example "myfib".
- level: set the value of the level parameter to the Fibonacci retracement level to test for the break.
- type: set the value of the type parameter to the direction to test for the Fibonacci retracement break, either FROM_ABOVE or FROM_BELOW.
- price: set the value of the price parameter to one of the price constants, or Bid or Ask.
- shift: set the value of the shift parameter to the index value of the candle (or bar) to test for the break.
- Normally, the shift value is set to 0 and the price value is set to Bid or Ask. This will test the latest price against the trend line on the far right edge of the chart.
- Alternatively, any candle on the chart can be tested for a break.
After connecting and configuring the fnIsFiboLevelBroken function, configure the Logic element to test for the break.
The full drawing is shown below.