How to create a Willams Percent Range EA with MQL5

video
play-sharp-fill

 

  • Introduction and Objective:
    • The tutorial focuses on the Williams Percent Range indicator, a momentum oscillator that identifies overbought and oversold levels. The objective is to design an expert advisor that can detect and trade based on this indicator.
  • Initial Setup in MetaEditor:
    • Users are instructed to open the MetaEditor and create a new file named “simple Williams Percent Range”.
  • Array Creation and Initialization:
    • Arrays “mypricearray0” and “mypricearray1” are established to store price data for the last three candles.
    • The copyrates function fills these arrays with the necessary data.
  • Williams Percent Range Logic:
    • The tutorial provides logic to determine the value of the Williams Percent Range using the iwpr function. This function calculates the indicator value for the current symbol on the chart and the selected period.
  • Signal Generation:
    • The expert advisor evaluates the Williams Percent Range values. When the value is below a certain threshold, it indicates an oversold condition, suggesting a potential price increase. Conversely, a value above a certain threshold indicates an overbought condition, suggesting a potential price decrease.
  • Testing and Visualization:
    • Users are guided on how to test the functionality in MetaTrader using the strategy tester. The visual mode displays the expert advisor in action, showing trading signals based on the Williams Percent Range.
  • Conclusion and Further Learning:
    • The tutorial demonstrates the creation of an expert advisor that trades based on the Williams Percent Range indicator. This approach allows traders to capitalize on potential market reversals based on overbought and oversold conditions.

By following this tutorial, users can effectively set up an expert advisor that trades based on the Williams Percent Range, offering insights into potential market reversals.


  • 0:00 – Introduction to the Williams Percent Range Indicator and its use in MetaTrader 5.
  • 0:30 – Explanation of how the Williams Percent Range Indicator works, its scale, and its significance.
  • 1:00 – Demonstration of how to insert the Williams Percent Range Indicator in MetaTrader.
  • 1:30 – Discussion on the peaks outside the range and their significance in trading.
  • 2:00 – Steps to create an expert advisor for the Williams Percent Range Indicator using MetaEditor.
  • 2:30 – Setting up the expert advisor, naming it, and initializing the code.
  • 3:00 – Explanation of the code, defining the array for prices, and using the iWPR function.
  • 3:30 – Further code details, sorting the price array, and using the copy buffer function.
  • 4:00 – Calculating the value using the normalized double function and matching it with the built-in MetaTrader indicator.
  • 4:30 – Outputting the calculated value on the chart using the comment function.
  • 5:00 – Compiling the source code, ensuring there are no errors or warnings.
  • 5:30 – Demonstrating the expert advisor in MetaTrader, using the strategy tester, and observing the results.

  1. What is the Williams Percent Range Indicator?
    • The Williams Percent Range Indicator, often referred to as %R, is an oscillator developed by Larry Williams. It indicates whether a market is overbought or oversold and has a negative scale. A value of -100 indicates the lowest price of the last N days, while a value of 0 indicates the highest price of the last N days.
  2. How do you add the Williams Percent Range Indicator in MetaTrader?
    • You can add the indicator by clicking on “Insert”, “Indicators”, “Oscillators”, and then “Williams Percent Range”.
  3. How do you interpret the Williams Percent Range Indicator?
    • The idea is to find peaks that are outside the usual range. If the indicator is above the dotted line, it might indicate an impending price drop. If it’s below the line, it might indicate a price rise.
  4. How do you create an Expert Advisor for the Williams Percent Range Indicator?
    • In the MetaEditor, you select “File”, “New”, “Expert Advisor from Template”, and give it a name, e.g., “SimpleWilliamsPercentRange”. After a few more steps and adding MQL5 code, the Expert Advisor can be created.
  5. How do you test the created Expert Advisor?
    • In MetaTrader, you click on “View”, “Strategy Tester”, select the created Expert Advisor, and start the test. During the test, you can observe how the Expert Advisor operates and how it reacts to the Williams Percent Range Indicator.
  6. What does the Expert Advisor display during the test?
    • The Expert Advisor calculates the value of the Williams Percent Range Indicator and indicates whether the market is overbought or oversold. It also provides trading signals based on these calculations.
  7. What happens if the indicator gives false signals?
    • It was noted in the video that the indicator sometimes gives false signals. To improve this, one can change the value for which the indicator is calculated from 14 candles to 100 candles.
  8. How did the change affect the signals of the indicator?
    • After changing to 100 candles, the indicator gave significantly fewer false signals. The peaks in the indicator occurred slightly before the actual price movements, potentially giving traders an advantage.
  9. What is the main goal of the Expert Advisor created in the video?
    • The primary goal is to create an Expert Advisor that uses the Williams Percent Range Indicator to generate trading signals and help traders better understand the market and identify potential trading opportunities.
  10. What did the viewer learn at the end of the video?
  • By the end of the video, the viewer learned how to create an Expert Advisor for the Williams Percent Range Indicator in MQL5 and how to test and apply this Expert Advisor.