MQL5 Tutorial – Simple RVI Trading Robot

ARE YOU STILL BROKER FOOD?
EASY AUTOMATED TRADING! 
PRECODED MODULES AND STRATEGIES!
FASTER, BETTER, AUTOMATED RESULTS YOU WILL GET NOWHERE ELSE
CLICK HERE  TO START  NOW

This time we are using the RVI indicator to spot trends and corrections.
Well, you know in every up or down trend you will always have the main trend and you will have corrections.
This line here stands for the average price, right now we are in a down trend and if the two lines cross, we have a little up correction.
And if the green line crosses the dotted line here the downturn might change and become an up-trend.
The RVI indicator is integrated into your MetaTrader and if you click on Insert, Indicator, Oscillator, and you select the relative Vigor index you will get the RVI for ten candles.
And this is how it looks like and it is also what we use here and you can use it to find out when the direction changes.
So right now we are in a little up-trend and when the green line crosses the dotted line, that might be the end of the trend.
Now how can we create an Expert Advisor that is going to use the RVI index?
To do that, please click on the little button here or press the F4 key, that will bring up the Meta Editor.
And here you want to click on File, New, Expert Advisor from Template.
Please click on Continue, I will call it simple RVI, now click on Continue, Continue and Finish, and delete everything above the Ontick function.
Let’s remove the two comment lines here and this time we are going to start with an empty chart output.
And we need to create the price array for several prices, I will call this one myPriceArray0 and I create another one that will be called myPriceArray1.
I do this because our indicator has two buffers, and now I will create an RVI definition using the function iRVI that is built in with MQL 5 for the current symbol and the selected period on the chart, for ten candles.
Because if you right click on the properties of the relative Vigor index you will see that it also uses ten candles here.
And now I use Array SetAsSeries for myPriceArray0 and myPriceArray1, to sort the price from the current candle downwards.
And now we want to use Copy Buffer with the RVI Definition we have created.
For the first line that is buffer zero and the other line that is buffer one to fill the arrays with prices from the current candle zero for three candles.
And now we want to get the value for the current candle, that’s candle zero in our PriceArray0 or in our PriceArray1 and store the results in two different variables here to calculate the green line and the red line.
And now we want to create a chart output, the first pair is for the main trend and if the RVI value zero is below the RVI value one and the RVI value one is also below zero that would mean we have a downtrend.
In the other case the RVI value zero is greater than the RVI value one and the RVI value zero is greater than zero, that would be an up-trend.
Now let’s insert the values for the correction part, if the RVI value zero is greater than the RVI value one.
And if the RVI value one is still below the dotted zero line, we have an up correction in the down trend.
And if the RVI value is below the RVI value one but the RVI value zero is above the dotted zero line, that would indicate a down correction in the bullish trend.
Now let’s click on the compile button or press the F7 key on your keyboard and with F4 or a click on this little symbol here, you can go back to your MetaTrader.
Back in Meta Trader please click on View, Strategy Tester and in the Strategy Test panel please select the simpleRVI.ex5 file, mark the visualisation option here, click on Start.
And this is how it looks like, we just have crossed the dotted line here so that would be a sign for a down-trend.
Now we have an upwards correction in the down-trend because both lines here are still below the dotted line and now the upwards correction became an upwards trend and that may go on for a while.
Okay, now you know how you can use the RVI indicator to create an MQL 5 Expert Advisor that will tell you if you are in an upwards or in a downwards trend, and you have done it with a few lines of MQL5 code in your Meta Editor.

Download “MQL5 - Simple RVI Robot from MQL5 Tutorial” SimpleRVI.txt – Downloaded 20 times – 1 KB

Learn how to create your own MQL5 trading robot for $1
Sign Up Now