Classic trading strategy based on RSI levels. Buys when RSI is oversold and sells when RSI is overbought. This
code can be used in both MetaTrader5 and MetaTrader4.
Just change the file extension from .mq5 to .mq4 and compile the file again.
Advisor works only on the new bar. The signal to open a position BUY: rsi on bar # 1> 'RSI Level UP'. Signal to open a SELL: rsi position on
bar # 1 <'RSI Level DOWN'.
//+------------------------------------------------------------------+//| iRSI simple advisor.mq5 |//+------------------------------------------------------------------+#property version"1.005"//---#include <Trade\Trade.mqh>
CTrade m_trade; // trading object//--- input parametersinputint Inp_RSI_ma_period = 14; // RSI: averaging period inputENUM_APPLIED_PRICE Inp_RSI_applied_price = PRICE_CLOSE; // RSI: type of priceinputdouble Inp_RSI_Level_UP = 70; // RSI Level UPinputdouble Inp_RSI_Level_DOWN = 30; // RSI Level DOWN//---int handle_iRSI; // variable for storing the handle of the iRSI indicatordatetime m_prev_bars = 0; // "0" -> D'1970.01.01 00:00';//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- create handle of the indicator iRSI
handle_iRSI=iRSI(Symbol(),Period(),Inp_RSI_ma_period,Inp_RSI_applied_price);
//--- if the handle is not created if(handle_iRSI==INVALID_HANDLE)
{
//--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iRSI indicator for the symbol %s/%s, error code %d",
Symbol(),
EnumToString(Period()),
GetLastError());
//--- the indicator is stopped early return(INIT_FAILED);
}
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//--- we work only at the time of the birth of new bardatetime time_0=iTime(Symbol(),Period(),0);
if(time_0==m_prev_bars)
return;
m_prev_bars=time_0;
//---double rsi_1=iRSIGet(1);
if(rsi_1==EMPTY_VALUE)
return;
//---if(rsi_1>Inp_RSI_Level_UP)
m_trade.Sell(1.0);
elseif(rsi_1<Inp_RSI_Level_DOWN)
m_trade.Buy(1.0);
}
//+------------------------------------------------------------------+//| TradeTransaction function |//+------------------------------------------------------------------+voidOnTradeTransaction(constMqlTradeTransaction &trans,
constMqlTradeRequest &request,
constMqlTradeResult &result)
{
//---int d=0;
}
//+------------------------------------------------------------------+//| Get value of buffers for the iRSI |//+------------------------------------------------------------------+double iRSIGet(constint index)
{
double RSI[1];
//--- reset error code ResetLastError();
//--- fill a part of the iRSI array with values from the indicator buffer that has 0 index if(CopyBuffer(handle_iRSI,0,index,1,RSI)<0)
{
//--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iRSI indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculated return(EMPTY_VALUE);
}
return(RSI[0]);
}
//+------------------------------------------------------------------+
Volume Profile + Range v6.0 - indicator for MetaTrader 5 (Fixed iBarShift Issue) Volume Profile + Range v6.0 (former TPO). Distribution of deals by price levels at a given time interval. Displayed as a histogram. The width of the histogram at the level means the number...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Why posting that in a RSI thread ?
And an other time please post a smaller image, I am still able to see it.
He already got an answer in PM that those are MACDs but obviously he did not like the answer :)
RSI Levels Expert Advisor - expert for MetaTrader 5
Classic trading strategy based on RSI levels. Buys when RSI is oversold and sells when RSI is overbought.
This code can be used in both MetaTrader5 and MetaTrader4. Just change the file extension from .mq5 to .mq4 and compile the file again.
How to Trade Using RSI (more information about HowTo- read this post)
Forum on trading, automated trading systems and testing trading strategies
How to start with MQL5
Vladimir Karputov, 2020.03.12 05:36
iRSI simple advisor
Advisor works only on the new bar. The signal to open a position BUY: rsi on bar # 1> 'RSI Level UP'. Signal to open a SELL: rsi position on bar # 1 <'RSI Level DOWN'.
RSI with BB - indicator for MetaTrader 5
The indicator consists in an RSI and Bollinger bands calculated on it, it also plots arrows when RSI value was out of Bands and came again in Bands.
Non Lag Relative Strength Index for MT5 - indicator for MetaTrader 5
Non Lag Relative Strength Index for MT5
Eliminates unnecessary preliminary calculations on the built-in RSI.