Posts: 4
Please rate this topic Current rating: 0 Votes: 0
RSS
R87.FX
Free Member
Offline
  • From: Costa Rica
  • Registered: 02-07-18
  • Posts: 4
  • Gender: male
  • Age: 36
  • Email

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.

image__6.png 183.77 kb, 20 downloads since 2018-02-07 
R_RVI.mq4 13.16 kb, 15 downloads since 2018-02-07 

What's new on MT4talk?

NEW! Daily MT4talk Artificial Intelligence (AI) Forex signals for manual trading.

It's simple! Receive the daily MT4talk AI Forex signals from MT4talk, then execute your trades, establish the recommended Take Profit (TP) and Stop Loss (SL), and relax. Your tasks for the day are complete.

The MT4talk AI Forex Signal works perfectly. See the latest earnings from MT4talk signal users.

We believe that the results of Forex signal users are the best way to demonstrate proof of profit.

MT4Talk Signal - 2023.12.05 - 3.10 profit
My today winning with the MT4talk AI Forex Signal 05.12.2023
MT4talk Forex AI Signal - EurUsd Sell Signal. Profit: $19.68
MT4Talk Signal - 2023.12.01 - 12.44% profit
Incredible AI Signals! 2023.12.01
I've made 30%+ today. 2023.12.01
Bad day today, only a 14.36% profit overall. :)
Profit from MT4Talk Signal - 2023.11.30

View past trading results by MT4talk PRO members...

R87.FX
Free Member
Offline
  • From: Costa Rica
  • Registered: 02-07-18
  • Posts: 4
  • Gender: male
  • Age: 36
  • Email

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)
   ExtRVI_MaxBar_Buffer[x]=RviMax_Bar;  
   ExtRVI_Max_Buffer[x]=RviMax;   
   ExtRVI_Min_Buffer[x]=RviMin;
   ExtRVI_UL_Buffer[x]=RVI_UL;  
   ExtRVI_LL_Buffer[x]=RVI_LL;    
   ExtRVI_Mid_Buffer[x]=RVI_Mid;
R87.FX
Free Member
Offline
  • From: Costa Rica
  • Registered: 02-07-18
  • Posts: 4
  • Gender: male
  • Age: 36
  • Email

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.]

R_RVI.ex4 13.66 kb, 3 downloads since 2018-03-01 
R_RVI.mq4 13.98 kb, 3 downloads since 2018-03-01 
R87.FX
Free Member
Offline
  • From: Costa Rica
  • Registered: 02-07-18
  • Posts: 4
  • Gender: male
  • Age: 36
  • Email

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!

R_RVI.ex4 14.33 kb, 4 downloads since 2018-04-03 
R_RVI.mq4 14.03 kb, 3 downloads since 2018-04-03 

What's new on MT4talk?

NEW! Daily MT4talk Artificial Intelligence (AI) Forex signals for manual trading.

It's simple! Receive the daily MT4talk AI Forex signals from MT4talk, then execute your trades, establish the recommended Take Profit (TP) and Stop Loss (SL), and relax. Your tasks for the day are complete.

The MT4talk AI Forex Signal works perfectly. See the latest earnings from MT4talk signal users.

We believe that the results of Forex signal users are the best way to demonstrate proof of profit.

MT4Talk Signal - 2023.12.05 - 3.10 profit
My today winning with the MT4talk AI Forex Signal 05.12.2023
MT4talk Forex AI Signal - EurUsd Sell Signal. Profit: $19.68
MT4Talk Signal - 2023.12.01 - 12.44% profit
Incredible AI Signals! 2023.12.01
I've made 30%+ today. 2023.12.01
Bad day today, only a 14.36% profit overall. :)
Profit from MT4Talk Signal - 2023.11.30

View past trading results by MT4talk PRO members...

Last Forum Posts
  • 11/12: AI Signals 8.12.2023 6,13% Profit
  • 10/12: The new MT4talk.com Trend Detector & Pip Hunter Forex Robot!
  • 10/12: How do you manage risk and avoid emotianal trading?
  • 10/12: Small Account, Which Timeframes Best for Forex?
  • 10/12: How to add screenshots see the screenshots to the forum posts?
  • 10/12: Learning Forex Trading Without Spending a Penny?
  • 09/12: Ilan 1.4: Visual Backtest with $200, 0.1 Lots
  • 09/12: Eye-Opening Insights on Forex Trading - Plus More!
  • 08/12: Small Drawdown, Big Gains: Charles-1.3.3 EA in Action
  • 08/12: Boost Your Trading: Ilan1.4 EA Optimization Tips Inside!
  • 08/12: Tailoring Orders: A Comprehensive Look at e-PSI@ManagerTrailing_v.2.5
  • 08/12: ForexFactory EA: Optimize for Best Pairs! Grider.ex4
  • 08/12: Enhanced Daily Open Strategy: Download Now!
  • 08/12: Unleashing OCTA SUPER EA: Swing, Scalp, News!
  • 08/12: Optimal Arbitrage EA Suggestions
  • 08/12: Navigating Forex: The Holy Grail EA for Real Gains
  • 08/12: how to pay tax for forex trading and how much?
  • 08/12: Profit Hunter EA - It's a super scalper EA!
  • 08/12: Moving Average Convergence Divergence (MACD): A Beginner`s Guide
  • 08/12: Basic Concepts VI: Types of Orders
  • 08/12: Basic Concepts III: History and Recent Trend of Online FX Market
  • 08/12: Top Scalping EAs: Share Your Picks!
  • 08/12: Scalper v5 + Wicks EA Inquiry - Any Recommendations?
  • 08/12: Effortless Profits: EA Blessing Configuration
  • 08/12: Enhance Your Strategy with Multi-StrategyiFSF EA: Expert Tips Inside!
  • 08/12: FX Safe Profit: Steady Income with Unique Trading Tech!
  • 08/12: Feedback Wanted: FXAlarms_14.12 EA Trial
  • 08/12: TFOT 3.0-EDU: Boosting Performance with Open Price
  • 08/12: USDJPY Sell, 8th December +33.96 USD
  • 07/12: XMT-Scalper v.2.46: Error-Free Operation – Seeking Guidance
  • 07/12: Basic Concepts II: Nature of the Foreign Exchange Market
  • 07/12: Basic Concepts I: Introduction
  • 07/12: Pips or points?
  • 07/12: Profitable Hedge EA: Optimal for Trending Currencies & Indices
  • 07/12: Proteção de EA: Bloqueio com Número de Conta
  • 07/12: Seeking Robust EA: Minimize Drawdown, Optimize Risk
  • 07/12: Seeking 24/7 Holy Grail EA: Low DD, $2K Start
  • 07/12: What's the most challenging part of Forex trading?
  • 07/12: Super pumped to be here!
  • 06/12: AI Signals 06.12.23 -1,68% profit despite difficult market conditions
  • 06/12: MT4Talk Signal - 2023.12.06 - 4.90$ profit
  • 06/12: Seeking Profitable VSA-Based EA
  • 06/12: VSA by the master the market e-book indicator
  • 06/12: Adaptive scalper - Inquiry
  • 06/12: Top Scalper: Consistent Profits for All Traders
  • 06/12: Daily Scalping: 100 Pips, Any Timeframe, Green Pips Guaranteed!
  • 06/12: Tick Scalper v3.4: Optimal for Fixed Accounts, 5min/15min TF
  • 06/12: ole$ya-PRO EA V.1
  • 06/12: In Search of Modified Martingale EA: Download Recommendations?
  • 06/12: safe martingale EA
  • 06/12: AIS2 Trading Robot: Auto Trading & Risk Control
  • 06/12: ibfx - Quick Buy: Powerful Forex EA for LQDFX and FXOpen
  • 06/12: zigzag1.mq4 Forex indicator download
  • 05/12: MT4Talk Signal - 2023.12.05 - 3.10 profit
  • 05/12: My today winning with the MT4talk AI Forex Signal 05.12.2023
  • 05/12: MT4talk Forex AI Signal - EurUsd Sell Signal. Profit: $19.68
  • 05/12: EU sell, 05.12. Profit: 27.40
  • 05/12: ilan1.4 (timefilter).mq4 - Proven Forex Robot for LQDFX and FXOpen
  • 05/12: EA Profit V11 Backtest - Unveiling Trading Efficiency
  • 05/12: Unlock Trading Success: Forex Indicator Predictor v2.0 Revealed
  • 05/12: Trend Signal Arrows: Master Your Buying and Selling
  • 05/12: Forex Millionaire Expert Advisor - Ideal for Any Market Condition
  • 05/12: Profitable EA: Download Super Robot Martin Now!
  • 05/12: Optimizing Robots for Live Profits: Stop and Target Tips?
  • 05/12: Pulp Fiction EA - Profit Unleashed: Pulp Fiction.ex4 Magic!
  • 05/12: Seeking Binary Option Indicator: Need Recommendations!
  • 05/12: EA Success: RONGGOLAWE - $2K Start, Pepperstone Razor, 5 Trades Max
  • 05/12: Maximize Gains, Minimize Risks with EA Fozzy
  • 05/12: Best EA for Arbitrage Trading?
  • 05/12: Trade-Arbitrage.mq4 - Powerful Forex EA for Consistent Profits
  • 04/12: Dragon Expert FF: 97% Gain, Default Settings
  • 04/12: Is Forex Trading on MT4 Right for Beginners? Tips and Strategies.
  • 04/12: How Can You Maximize Profits with Advanced Strategies in MT4 Trading?
  • 04/12: Exness Trading: Safe Deposits, Smooth Trading, No Instant Withdrawals?
  • 04/12: PZ Goldfinch EA: Tested for Success, Ending in Profits!
  • Backtested Forex Robots & Setting Files
  • 04/04: LIN FOREX EA v2 - (Tested with over $330,000 profit)
  • 03/11: EU Profit - (tested with over $8,500 (1,700%) profit)
  • 27/12: Money bag - forex robot - (Tested with over $22,000,000 profit)
  • 19/07: e.2.17 5min Scalper.mq4 EA - (Tested with over $150,000 profit)
  • 26/03: bogie-macd_matrend-v1-stealth - (Tested with over $1,100,000 profit)
  • 20/01: Farhad3a.mq4 Forex EA free - (Tested with over $1,100,000 profit)
  • 09/09: Genie - (Tested with over $1,700,000 profit)
  • 29/04: Forex Trading EA - (tested with over $5,200 (1000%) profit)
  • 27/09: FSS longtradeScalper EA - (tested with over $1,800,000 profit)
  • 05/04: samurayv5.2.mq4 free Forex EA - (Tested with over $400,000 profit)
  • 22/08: Alexav SpeedUp M1 ea download - (tested with over $1.7M profit)
  • 19/05: Bago_EAv2.mq4 free Forex EA - (Tested with over $1,700,000 profit)
  • 03/11: PROphet EA - (Tested with over $1,500,000 profit)
  • 24/05: break 1mn[1].mq4 free Forex EA - (Tested with over $3,200,000 profit)
  • 29/01: DT-RSI-EXP1.mq4 Forex EA - (tested with over $1,100,000 profit)
  • 26/07: Scalping EA - (Tested with over $3,100,000 profit)
  • 18/08: 2019 Crisis Scalper - Automated Forex robot - Tested with $3M+ profit
  • 17/10: ma2cci.mq4 Forex EA - (tested with over $1,100,000 profit)
  • 31/01: gbp_4barbreakout_m30-2 Forex EA - (tested with over $1,900,000 profit)
  • 13/07: ilan 1.6 dynamic - (Tested with over $1,400,000 profit)
  • 26/03: happy doji lucky hammer free EA - (Tested with over $1,800,000 profit)
  • 17/12: EA for New bar event - (tested with over $1,400,000 profit)
  • 25/01: DayTrading02.mq4 Forex EA - (Tested with over $2,900,000 profit)
  • 29/10: Limit.mq4 Forex EA - (tested with over $1,600,000 profit)
  • 06/03: MT4 EA Daily Breakdown - (Tested with over $1,200,000 profit)

  • NOTE: You can only share open-source Forex robots on this platform. Sharing hacked or unauthorized versions of copyrighted Forex robots is strictly prohibited and can result in a ban on your account.

    By using the MT4talk website, you automatically agree to the Forum Rules & Terms of Use, as well as the terms below.

    Everything you see on the MT4talk website is created by its users, mainly the members of the MT4talk forum. The website doesn't sell Forex robots and doesn't provide support for the ones you download. MT4talk only offers a PRO membership, allowing you to download unlimited files from forum posts. Updates for the Forex robots may be limited or nonexistent, depending on the creator. If you choose to download any Forex robot or setting file from the forum, you acknowledge that you are using it at your own risk. MT4talk PRO membership is a digital product. Therefore, after you complete the PRO membership purchase, there is no refund available!


    We are conducting real-life tests on Forex robots to assess their performance. For certain robots, we may use a demo account to conduct tests, and for other Forex robots, we may use a real Forex account. It's essential to recognize that we are not financial advisors and cannot provide investment guidance. Our objective is to discover effective market analysis solutions through testing various strategies, which could be beneficial to our community.


    CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.

    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 or the MT4talk EA Tester Team 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.


    Affiliates Disclaimer - The website may have links to partner websites, and if you sign up and trade through these links, we will receive a commission. Our affiliate partners are FXOpen, FBS, LQDFX, and MyForexVPS.


    Site map forums - Sitemap posts - Sitemap public search - Sitemap topics - Sitemap user posts - Sitemap user topics - Sitemap users

    Copyright MT4talk.com Forum Rules - Privacy Policy.