You didn't post a topic yet. Let us show you how to make your first topic and upload your favorite forex robot. Guide me

Skip to forum content

Quick Login / Register with Facebook Account!

Login with Facebook

Login with Username and Password!

     Username:       Password:  Login

Register  |  Forgot Password?


The latest topics with attached files (Forex robots, Forex Indicators, etc..)

Forums in this category with details of Replies, Views, last post

best robot 2018

by jejoy


by Alemkhil

One day Profit.

by Wajid Hussain


Highest Forex Leverage 1:3000!

Try your Forex Robot with the highest leverage 1:3000! All Forex robot strategies allowed! Scalping, hedging, martingale, etc...

If you make a deposit as small as $10 in your Forex account, you can enter trades with $30,000 buying power. If you deposit $200 you can enter trades with $600,000 buying power.

Pages 1

You must login or register to post a reply


Posts: 4
Please rate this topic
Current rating: 0
Votes: 0

Embed topic to your site

Finding Max/Min Indicator Values in Given Range

Topic: Finding Max/Min Indicator Values in Given Range

Hey, I am currently customizing an RVI indicator for eventual use in an EA.  I figured it would be easier to check my work if I can actually see the results before moving on to back-testing.

The basic idea is to take the last 300 bars of the RVI (an indicator without fixed max/min's) and determine & draw lines at RviMax, RviMin, RviMid (middle), and some other calculated levels.  Essentially I want to establish a recent RVI range without changing how the indicator naturally calculates/displays. This range should update in real-time, only changing if a new max/min is established (on bar close), or if the existing max/min turns older than 300 bars.

I think I am pretty close to the desired result.  The indicator will find the MaxRVI when loaded and will display that value in the buffer correctly for all previous bars up to 300.  However after the Max/Min's the values get a little crazy.  It seems for the very recent candles (about 0-30) RviMax will be set to ANY local peak (even if clearly below the actual 300 bar max) and will continue to post lower and lower values until it reaches 0.00.  Once the RVI returns to positive territory, RviMax begins to follow RVI back up again.
I cannot see why the actual max/min values in the array are ignored in favor of less extreme values for the most recent bars. I suspect this has something to do with how I set up the array (RVIArray) or with how I used ArrayMaximum/ArrayMinimum, but I can't say for sure. Does anyone have any idea?

I have attached the mql4 file and picture outlining the issue.

Post's attachments

image__6.png 183.77 kb, 15 downloads since 2018-02-07 

R_RVI.mq4 13.16 kb, 12 downloads since 2018-02-07 


Re: Finding Max/Min Indicator Values in Given Range

After a closer look, it looks like the output in the Experts tab where I have all the data printing shows the correct value (or very close to it).  But the Data window shows incorrect data for the most recent bars. So i guess the real question is will an EA use the data-window values, or the buffer values in the log? My gut tells me the buffer values will be used, but since the variables being given for both are exactly the same I cannot say for sure. Any thoughts?

Print("MAX BAR ", RviMax_Bar);  //This Block prints all values to log
   Print("MIN BAR ", RviMin_Bar); 
   Print("RVI MAX ", RviMax);
   Print("RVI MIN ", RviMin);
   Print("RVI Range ",RviRange);
   Print("RVI ULimit ",RVI_UL);
   Print("RVI LLimit ",RVI_LL);
   Print("RVI MidLevel ",RVI_Mid);
   ExtRVI_MinBar_Buffer[x]=RviMin_Bar;  //This Block passes calculated values to buffers (not plotted)


3 (edited by R87.FX 03-01-18 17:27:09)

Re: Finding Max/Min Indicator Values in Given Range

Alright I made some good progress and figured I would share what I have.  The main thing was changing where the variables for the custom RVI levels are called.  I guess you can call a variable for a for() iteration such as “x” for counting in the middle of the code, but calling variables that will be used to pass data to buffers needs to be declared at the top.  Kind of seems obvious now, but there you go –lesson learned.  This fixed the problem with incorrect buffer values being shown for certain candles within the 300 bar range.  Now the buffer values are consistent for all bars, as they should be.

The drawing of the levels is still not how it should be,although the levels it draws when the indicator is loaded is correct.  Eventually the idea is to have the actual buffers do the drawing, or at the very least have the ObjectCreate Horizontal lines update when new highs/lows of the RVI are made or old ones expire.  Since the main goal for me is to use this in an EA, and since the buffers update correctly, this aesthetic task is not priority.  So, this will work when you call this indicator through iCustom() in an Expert Adviser.  But if you want to use the indicator visually you will need to remove and reload the indicator when lines need to be redrawn.

Also worth noting are a few quirks with this indicator that have popped up.  First, when using this indicator for back-testing with an EA, it will load 3 or more versions of the indicator at the end (even if the back-test is in visual mode with this indicator already loaded).  I’m not sure if this is just something that happens at the end, or if the EA I have is actually using three versions of the indicator during the test.  The second quirk is that the back-tests using this indicator are very slooow.  A test period of 2 years took a good 10 hours to complete where as all of my custom EA’s with more standard indicators take 10 minutes TOPS.  So if anyone has any ideas of how I can make the code more efficient, I am all ears.

Anyway, I hope this helps someone out there and if anyone has any tips they would be greatly appreciated. 

[Final Note:  I have cleaned up the code a little bit, but this is still a work in progress.  Therefore there is some unused code in therefor features that have not been implemented yet or for testing purposes.]

Post's attachments

R_RVI.ex4 13.66 kb, file has never been downloaded. 

R_RVI.mq4 13.98 kb, file has never been downloaded. 


4 (edited by R87.FX 04-03-18 21:13:06)

Re: Finding Max/Min Indicator Values in Given Range

UPDATE: I made the levels update on each new candle so now it runs as it should.  I should note,though, that I wanted to do this with either ObjectSet or ObjectMove, but for now I am just deleting and redrawing each line on each new candle.  I have also added a DeInt function to properly remove the indicator after it is removed. The issue I mentioned before about multiple versions of this same indicator being used during expert testing was a mistake in the EA and not this indicator, so no worries there. I also think the slowness of the tests is an issue with the EA and not this indicator. I have also cleaned out a lot of the unnecessary code used for testing to make it slightly easier to read. One exception to this is measuring the direction bias (“DirBias”) of a trend based on the RVI values.  This is a feature that has not been built out yet.

Anyway, I think this custom indicator is pretty much complete except for a few possible changes here and there.  I think I will stop providing updates since I will be moving on to another portion of the overall project. I hope this helps some trader out there trying to tackle a similar problem.  Please feel free to use this code as your own, as a whole or in part. And if you are a beginner and have any questions specifically related to this indicator, please feel free to contact me. 

Final Note: While this indicator has performed well overall during my testing, I will have a much more experienced MQL4 programmer look over my code before I go live and I strongly suggest you do the same.  This is the first indicator I customized and I barely put any effort into error handling. Don’t lose money because of my laziness - do your due diligence!

Post's attachments

R_RVI.ex4 14.33 kb, file has never been downloaded. 

R_RVI.mq4 14.03 kb, file has never been downloaded. 


Posts: 4

Pages 1

You must login or register to post a reply

Last Posts

  • 13/12: HMA Expert Advisor for MetaTrader 4
  • 13/12: Forexhackers-EA_V2
  • 13/12: EA Asia Scalper
  • 13/12: EA Tahan Banting v3.2
  • 13/12: best robot 2018
  • 12/12: H1 Trend EA
  • 12/12: EURUSD EA
  • 12/12: One day Profit.
  • 12/12: Bitmex robot
  • 12/12: assistance from my broker
  • 12/12: EA trading ZigZag indicator when pointing outside the Bollinger Bands.
  • 12/12: EA
  • 12/12: Moving GRID EA
  • 12/12: Ronix v4 EA
  • 11/12: Profit Master EA
  • 10/12: To accomplish
  • 10/12: Facing losses
  • 10/12: PingTouGe,a fantastic EA
  • 10/12: XtreamForex Company News
  • 10/12: Due to the changes
  • 09/12: Awesome EA, with Cent account should be just fine
  • 09/12: EA Generic A-TLP v.12.38
  • 09/12: Help with EA inputs
  • 09/12: Automated trading system
  • 09/12: 500% profit per week! Forex Robot!
  • 09/12: abundant reasons
  • 08/12: trading at the right time
  • 08/12: Indrafxscalping v8
  • 08/12: EA Adenan Scalping. daily profit 10-30% TF M1 EUR
  • 08/12: EA PricelessGrid
  • Online Users & Stats

    • Total number of registered users: 25,925
    • Newest registered user: Titus Judah
    • Total number of topics: 11,444
    • Total number of posts: 37,473

    Online users: 2,128 guests, 271 Members:

    777legrand, 845607783, adam12za, AdamVPS, admin, Adriano Lucas de Paula, adryrus, afc123, Ahmet Yasin Gülbeyen, alamgirfx20, Albertos, alesnetusil, Alexander Lamount Knowles, ameyakambleameya, Amit Singh, andilenokwayi, andydrae67, Anita Blege, aprice220466, aqufresh, aranga, Arjune Krishna, Art Dejavu, arun26180, atizaque, Avesani Maurizio, axel7969, Baburali95, ball2goal, barthos17, BENEX, bestkid321, betuboxem, biztet, bkrisbiyanto, BMWKOLA, boldoo1231, booysen.s92, Brahim Hadef, BrandonBoyd, cabakgames, cbeert, CeeJayke, chenyayuzx, Choosak Lertvichamai, Chuks Abram, Chumani Boniwe, coachklso, corrabot, Cretu Vasile, cruelzhang, csk0077, Damien Cherry, dancard84, danieldake4, danyshiandez, dare79, davbene74, deepak.networks45, Deni, Diederich Müller, dlaminqk, dmlye2004,, DoctorMa7, Don Jay, donaldoruma489, Donnie Drajat, Donovan Sissing, doolph, dow017, dvorynen, Eakapun, eaze1six, ecker8415, Eduardo Montanha, Enroute, eugenio.nabor, evert, Fadzil Yusof, farmabioq, fatboy, fbfx12, femo, flsekme, forex0801, forexnfx, forexprofit2018, Fotiou, franck0naka, fxvnpro, gamegg35, Gaspard, George Kourogiorgas, ggarza, gungink, gys, hanhtinhxanhdo, hendrikwong, Hery Setiawan, Horry Yue, Hoven AL, hussain.tradeexpress, ich61, igniz, imam.gozali329, imsamphors, Inconito75, inversionesromaguerrero, ishop888, jailson925, Jarocho, jaysonajax, jeabanuban, Jean Costa, jejoy, Jesus Flores, jfliper, jjeg1979, Jlccorp, jmvr30i, Joe0013, joekuol, Johan Kraan, joinbehar, jona41223, Joni, Jordan Pritchett, José Luis Pérez, joskerone, jp_satriane, juanvincent, judeekatherinexx, Kabelo Collen Molokwe, kamalkumar_j, kangmasrowi, kashif_raza, kazuo.yoshida.01, Ken Sato, Kenneth Cerdas, Kojo Bame, kozura, kumarpetroleum81, kvg387, Lâm Tấn Kiệt, Larrywillo, lecho80, Leonardo Junqueira, LilKeo Seony, Liviu Torac, Lucas Alonso, mabra, machemitoccafa, machs_nochmal, madebybel, mandysoy, marbre, MarianNick123, Mario Alz, mariotboy007, marron.chihuahua, Martin Kirschner, Mduduzi, meiyan, meleriste, miguel061195, mikeb4, Montipora, mountain8283, mrmaggi007, MTrader, mwatcher, Myanmar River, myd1688, n111, nakatama1, Neosul, Nico Bilio, nine007, noeltg, nofear89, nphuquy6789, Nuno Amorim, odc1977, Okan Polat, omalix, omidazizi1366, orlandog, pachu, paroucia, pellingrini45, pholza55, phuonglan19, pregem, princezahid2010, ptctodo, Querido, R3P3NT, rad1958, rafik_fex, Re Kristin, remmar, Ricardo09, rirayoza, Rivoningo Nghondzweni, rkarsu, RMC, ron2009, Roson Chea, rubenet33, said.qurbanov4, Salomo Christoffel, Sarun Numkanisorn, savychostap177, sembhi, sgeorgatos6, shafarjsr, shahbaz.star333, Shahzad Ahmad Qureshi, shaundavis111, shtefan, skycsammy15, sniper13, sotavent0, spica.razif, sprizzon, steverson, subbarao59, Szwaj Kleofas, tahucrispyku2, Taposki99, tavonboonsam, tekinyer, temaki, Thim Bérénice, thuan27, timdawg792003, Titus Judah, tjan85914, Traderfox2610, trading1735, tradingralf, truongkhanhduy, tuncay, unic, vadvid, Victoriano, vincentgdonald, vladitek, vodafone2066, Waliu Ajose, Waqas Ali, waylon, why, wisejobscommerce, xg5463, xtreamforex, Yai Megaforce, Yannick Bonyoma, yekta, yikailin, yildiz, zafarjoia, zeefx, zrodox9, Анатолий Науменко, ودمعي دوم بعيوني, สมบัติ แสนบุตร, ไพศาล เผ่าพงษ์ไพบูลย์, 悠宇丞小瀧, 振豪


    NOTE: Hacked or illegal versions of copyrighted Forex robots are highly prohibited on If you upload any illegal version of any copyrighted Forex robot, your forum account will be banned. No exceptions.


    IMPORTANT: is a public Forex forum, where forum members can upload open source Forex robots to share with other members. forum does not sell or rent Forex robots, and does not provide guarantee or support for the uploaded Forex robots! If you have any question about any Forex robot, please open a forum topic! If you have a question about your forum account, contact:


    Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. 
    All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.

    Copyright Forum Rules - Privacy Policy.