MQL5 TUTORIAL - HOW TO CODE A SIMPLE BWMFI EXPERT ADVISOR IN 3 MINUTES

Опубликовано: 01 Январь 1970
на канале: MQL5 Tutorial
434
16

https://mql5tutorial.com/?s=bwmfi

Chapters:

Introduction to BWMFI Expert Advisor Creation (00:00 - 00:06)

Introduction to creating an Expert Advisor using MQL5.
Setting Up the MetaEditor (00:06 - 00:15)

Instructions on opening MetaEditor and including the trade library.
Initializing Trading Functions and Prices (00:15 - 00:35)

Creating an instance of the CTrade class.
Calculating and normalizing Ask and Bid prices.
Defining Trading Signal and BWMFI Array (00:35 - 00:52)

Declaring a string variable for the trading signal.
Setting up the Bill Williams Market Facilitation Index (BWMFI) array.
Initializing and Sorting BWMFI Values (00:52 - 01:07)

Initializing BWMFI and sorting the array for current candle values.
Populating BWMFI Array and Calculating Values (01:07 - 01:22)

Populating the BWMFI array with values.
Calculating the current and last candle's BWMFI values.
Determining Trading Signals (01:22 - 01:51)

Comparing BWMFI values to set 'buy' or 'sell' signals.
Executing Trades Based on Signals (01:51 - 02:08)

Executing buy or sell trades based on the determined signal.
Compiling and Testing the Expert Advisor (02:08 - 02:25)

Instructions for compiling the code and testing in MetaTrader.
Summary and Invitation for Premium Members (02:25 - 02:33)

In this video, we're going to create an Expert Advisor using MQL5. Let's get started.

First, open your MetaEditor by clicking its icon or pressing F4.

We begin by including the trade library using #include<Trade\Trade.mqh>. This library allows us to use trading functions in our code. Next, we create an instance of the CTrade class and name it trade.

Now, let's calculate the Ask and Bid prices. We use SymbolInfoDouble(_Symbol,SYMBOL_ASK) to get the Ask price and normalize it using NormalizeDouble. We do the same for the Bid price. These prices are stored in double variables Ask and Bid.

We then declare a string variable called signal. This variable will hold our trading signal, either 'buy' or 'sell'.

Moving on, we define an array BWMFIArray to hold the values of the Bill Williams Market Facilitation Index (BWMFI). We initialize the BWMFI using iBWMFI(_Symbol,_Period,VOLUME_TICK) and store its definition in an integer variable BWMFIDefinition.

We sort this array from the current candle downwards using ArraySetAsSeries(BWMFIArray,true).

Now, we populate this array with BWMFI values using CopyBuffer. We copy 3 values starting from the current candle. These values are stored in BWMFIArray.

Here comes the crucial part. We calculate the current BWMFI value and normalize it to 5 decimal places using NormalizeDouble(BWMFIArray[0],5). This value is stored in CurrentBWMFIValue.

Similarly, we calculate the last candle's BWMFI value using NormalizeDouble(BWMFIArray[1],5) and store it in LastBWMFIValue.

We then compare CurrentBWMFIValue and LastBWMFIValue. If the current value is greater, the signal is set to 'buy'. If it's smaller, the signal is set to 'sell'.

Based on the signal, we execute trades. For a 'buy' signal, we buy 0.10 microlots using trade.Buy(). For a 'sell' signal, we sell 0.10 microlots using trade.Sell().

After coding, press F7 to compile. If this is too fast, consider our Premium course for more guidance.

To test, go back to MetaTrader, press Control and R, and start the strategy tester. You should see your Expert Advisor on the chart.

In summary, you've learned how to create an Expert Advisor using MQL5, coded it yourself, and tested it in MetaTrader.

If you're a Premium course member with an idea for a video, send us an email.

Thanks for watching, and see you in the next video.


Смотрите видео MQL5 TUTORIAL - HOW TO CODE A SIMPLE BWMFI EXPERT ADVISOR IN 3 MINUTES онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь MQL5 Tutorial 01 Январь 1970, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 434 раз и оно понравилось 16 людям.