0% found this document useful (0 votes)
75 views2 pages

RSI Bollinger EMA System v2

The document is a MetaTrader 4 (MT4) script for a custom trading indicator called RSI_Bollinger_EMA_System_v2, created by ForexBee in 2023. It combines the Relative Strength Index (RSI), Bollinger Bands, and Exponential Moving Average (EMA) to generate buy and sell signals based on specific conditions. The script includes initialization and calculation functions to set up the indicator and compute the necessary values for trading signals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views2 pages

RSI Bollinger EMA System v2

The document is a MetaTrader 4 (MT4) script for a custom trading indicator called RSI_Bollinger_EMA_System_v2, created by ForexBee in 2023. It combines the Relative Strength Index (RSI), Bollinger Bands, and Exponential Moving Average (EMA) to generate buy and sell signals based on specific conditions. The script includes initialization and calculation functions to set up the indicator and compute the necessary values for trading signals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//+------------------------------------------------------------------+

//| RSI_Bollinger_EMA_System_v2.mq4 |
//| Copyright 2023, ForexBee |
//| https://www.forexbee.ir |
//+------------------------------------------------------------------+
#property strict
#property indicator_chart_window
#property indicator_buffers 5 // ‫ بافر‬5 :‫تصحیح شده‬
#property indicator_color1 clrGreen // Buy Signal
#property indicator_color2 clrRed // Sell Signal
#property indicator_color3 clrBlue // EMA
#property indicator_color4 clrLime // Upper BB
#property indicator_color5 clrTomato // Lower BB

// Inputs
input int RSI_Period = 7;
input int BB_Period = 20;
input double BB_Deviation = 2.0;
input int EMA_Period = 9;

// Buffers
double BuySignal[];
double SellSignal[];
double EMA[];
double UpperBB[];
double LowerBB[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0, BuySignal);
SetIndexStyle(0, DRAW_ARROW, EMPTY, 2, clrGreen);
SetIndexArrow(0, 233); // Up Arrow
SetIndexLabel(0, "BUY");

SetIndexBuffer(1, SellSignal);
SetIndexStyle(1, DRAW_ARROW, EMPTY, 2, clrRed);
SetIndexArrow(1, 234); // Down Arrow
SetIndexLabel(1, "SELL");

SetIndexBuffer(2, EMA);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1, clrBlue);
SetIndexLabel(2, "EMA " + string(EMA_Period));

SetIndexBuffer(3, UpperBB);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1, clrLime);
SetIndexLabel(3, "Upper BB");

SetIndexBuffer(4, LowerBB);
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1, clrTomato);
SetIndexLabel(4, "Lower BB");

return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
for(int i = MathMax(prev_calculated, 1); i < rates_total; i++)
{
EMA[i] = iMA(NULL, 0, EMA_Period, 0, MODE_EMA, PRICE_CLOSE, i);
UpperBB[i] = iBands(NULL, 0, BB_Period, BB_Deviation, 0, PRICE_CLOSE,
MODE_UPPER, i);
LowerBB[i] = iBands(NULL, 0, BB_Period, BB_Deviation, 0, PRICE_CLOSE,
MODE_LOWER, i);

double rsi = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);

// Buy Signal
if(rsi < 30 && low[i] <= LowerBB[i] && close[i] > EMA[i])
BuySignal[i] = low[i] - 10 * _Point;

// Sell Signal
if(rsi > 70 && high[i] >= UpperBB[i] && close[i] < EMA[i])
SellSignal[i] = high[i] + 10 * _Point;
}

return(rates_total);
}
//+------------------------------------------------------------------+

You might also like