2

I want to have access to various Fibonacci levels like 23.6%, 38.2%, 50%, 61.8% and 100% in my expert advisor (EA). How can I define those in my EA so that traders can select them via the inputs?

I tried this

input double Fibo=23.6;

However, is this the common approach? Is it possible to set them as predefined?

Thank you for your help!

Matthias A. Eckhart
  • 5,136
  • 4
  • 27
  • 34
Peter Simmons
  • 23
  • 1
  • 5

1 Answers1

5

You can set predefined Fibonacci levels by using enumerations. Either you use enumerations provided by MQL5 or define your own, like this:

//+------------------------------------------------------------------+
//| Enumeration for Fibonacci levels                                 |
//+------------------------------------------------------------------+
enum ENUM_FIBO_LEVELS
  {
   fib0618 = 0618, // 61.8%
   fib1000 = 1000, // 100.0%
   fib1382 = 1382, // 138.2%
   fib1618 = 1618, // 161.8%
  };

Note: If you place a single-line comment, it will be associated with the variable name, as shown in this example.

input ENUM_FIBO_LEVELS FiboValue=fib1618; // Fibonacci level

As a result, users are able to select their preferred Fibonacci level:

Expert Advisors>Properties>Inputs

To calculate potential support and resistance levels, convert the Fibonacci ENUM level:

(double(FiboValue)/1000)

If you have any further questions, please leave a comment below.

Matthias A. Eckhart
  • 5,136
  • 4
  • 27
  • 34
  • Could you please help me with https://stackoverflow.com/questions/60933737/converting-mql4-ea-to-mql5 – BBNN Mar 30 '20 at 15:53