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


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

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

Quick Register / Login with Facebook!

Login with Facebook

Register or Login!

Username:  Password:  Login  |  Register

Registered Forum members can download over 10,000 Forex Robots!


Pages 1

You must login or register to post a reply


Posts: 3
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, 12 downloads since 2018-02-07 

R_RVI.mq4 13.16 kb, 9 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)



FREE Forex Money on Real Forex Account!

>> Get $3500 FREE No Deposit Forex Bonus!  Don't need to deposit! 

With $3500 bonus you will be able to test a quality of your Forex Robot on Real Forex Account!

No risk and no personal investments. 

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. 


Posts: 3

Pages 1

You must login or register to post a reply

Google Ads


Top 5 Forex Robots!


  1 minute time-frame!


  Instant Daily Profit!


  500% profit per week!


  Few Pips A Day!


  Automated Forex Robot!

Last Posts

  • 22/03: Forex for better future
  • 22/03: robominer 2, makes 130k in 2 month from 10k in demo
  • 22/03: RSI_50_50A - MQ4 file (expert advisor)
  • 22/03: Simpicity1 - MQ4 file (expert advisor)
  • 22/03: RSI_50_50A - MQ4 file (expert advisor)
  • 22/03: Divergence in reality from the expectation: forex is not that easy
  • 21/03: Assar Ultra©™ High Frequency Forex Scalping in 2018
  • 21/03: Forex trading for better life
  • 21/03: What makes trading easier for you?
  • 21/03: Identifying our mistakes.
  • 21/03: Best Non repaint Forex Arrow inidcator
  • 21/03: OMEN 2.9
  • 21/03: Dhrausciaxtrismus - MQ4 file (expert advisor)
  • 20/03: BettertomorrowEA - MQ4 file (expert advisor)
  • 20/03: Best Price action indicator
  • 20/03: ZigMA EA Free EA until Dec 2018
  • 20/03: Opportunity to earn more.
  • 19/03: BettertomorrowEA
  • 19/03: scalper v7
  • 19/03: Did you become rich?
  • 19/03: profitrider - MQ4 file (expert advisor)
  • 19/03: blockbuster - MQ4 file (expert advisor)
  • 18/03: bollinger bands - MQ4 file (expert advisor)
  • 17/03: The common matter.
  • 17/03: MM4X Forex Price Action Strategy with Quarters Theory Indicator
  • 17/03: All Pair History Download Script
  • 16/03: test please ASSARV11.ex4
  • 16/03: new hedge ea
  • 16/03: Determination in Forex.
  • 15/03: Foreign currency exchange market_ a potential investment field
  • 15/03: Need info EA Hedging
  • 15/03: Earning money online without investing no money
  • 15/03: Honest Broker.
  • 15/03: High Frequency Trading(HFT)
  • Hot Topics

  • ASSAR v8 (1042)
  • Scalper_v5 (free) (720)
  • A highly profitable Ea (465)
  • FX Magic Robot - Verified Live Working 3/13/17 (458)
  • 2000 pips daily (451)
  • ASSAR V9 (Trend Breakout Edition) 2017 Expert Advisor (417)
  • spartan bolt V6 (414)
  • Assar_03_EA (391)
  • Forex Earth Robot (249)
  • Trade-Arbitrage EA (248)
  • xmt scalper (227)
  • Forex Math EA free for Mt4 (180)
  • Super Signal Scalping Profit Statement (178)
  • Rabbit3 £100 start Zero to Hero Updated EA (167)
  • EA SmartAssTrade. (158)
  • Fracture 7.4.0 (156)
  • high profit EA (151)
  • SCALPER PALING JOSS EA is a Holy Grail (150)
  • New to forex? (148)
  • Ilan Expert Advisor for Metatrader 4 (136)
  • Monster Profit Forex Robot (123)
  • WayGrow EA 1.7 (111)
  • scalperstarkpro downoad free (price 90 dollars) (94)
  • FX Magic Robot (91)
  • IceFX TraderAgent Pro EA v2.5.1 (86)
  • Profitable GBPJPY EA (true results) (85)
  • Unbelievable EA (83)
  • Hedge Expert Advisor (63)
  • 100 pips profits trading (63)
  • Good EA 2017. Free !!! (63)
  • Best Indicator That No Repaint!!! (62)
  • Magic Fx Formula indicator-V2 (61)
  • hello (60)


    FREE Forex Money on Real Forex Account!

    >> Get $3500 FREE No Deposit Forex Bonus!  Don't need to deposit! 

    With $3500 bonus you will be able to test a quality of your Forex Robot on Real Forex Account!

    No risk and no personal investments. 


    NOTE: Cracks or other 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.

    Copyright Forum Rules - Privacy Policy.