Home Technical Indicator Post

Enhance Your Trading with Custom Bollinger Bands for MetaTrader 5

Attachments
49464.zip (2.27 KB, Download 0 times)

Hey fellow traders! If you've been looking for a way to spice up your trading strategy, I’ve got something special for you. I've developed a custom Bollinger Bands indicator specifically for MetaTrader 5 that goes beyond the standard moving average methods. While the default options only allow for the 'simple' moving average, my version brings additional flexibility to the table.

With this custom indicator, you can choose from various moving average methods like Exponential, Smoothed, and Linear Weighted. So, if you want to tailor your Bollinger Bands to fit your trading style, this is the tool for you!

To get started with this indicator, you’ll need to install it in your MetaTrader 5 directory. Here’s how:

C:\Users\YourUsername\AppData\Roaming\MetaQuotes\Terminal\Indicators\Examples

Here are some of the added features you can expect:

Bollinger Bands Custom Indicator

By default, the settings are configured to zero:

Default Settings

Here’s a sneak peek of the indicator in action, using the Linear Weighted average:

Example 1  Example 2

Now, let's dive into the code for those who want to explore the technical side:

//+------------------------------------------------------------------+
//| Custom Bollinger Bands Indicator                                   |
//| Developed by Lucas Vidal                                          |
//+------------------------------------------------------------------+
#property copyright "Lucas Vidal"
#property link "https://www.mql5.com/en/users/lucasmoura00"
#property description "Custom Bollinger Bands Indicator"
#include <MovingAverages.mqh>
//--- indicator properties
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_color1 LightSeaGreen
#property indicator_type2 DRAW_LINE
#property indicator_color2 LightSeaGreen
#property indicator_type3 DRAW_LINE
#property indicator_color3 LightSeaGreen
#property indicator_label1 "Middle Bands"
#property indicator_label2 "Upper Bands"
#property indicator_label3 "Lower Bands"
//--- input parameters
enum MovingAverageMethod {
    Simple, // 0
    Exponential, // 1
    Smoothed, // 2
    LinearWeighted // 3
};
input MovingAverageMethod InpMaMethod = Simple; // Moving Average Method
input int InpBandsPeriod=20; // Band Period
input int InpBandsShift=0; // Band Shift
input double InpBandsDeviations=2.0; // Deviation
//--- global variables
int ExtBandsPeriod, ExtBandsShift;
double ExtBandsDeviations;
int ExtPlotBegin=0;
//--- indicator buffers
double ExtMLBuffer[];
double ExtTLBuffer[];
double ExtBLBuffer[];
double ExtStdDevBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                            |
//+------------------------------------------------------------------+
void OnInit() {
   // Initialization code here
}
//+------------------------------------------------------------------+

Feel free to dive into the code and tweak it to your liking! If you have any questions or need assistance, don’t hesitate to reach out. Happy trading!

Related Posts

Comments (0)