If you're diving into the world of trading with MetaTrader 4, the Doji Hunter indicator is a must-have tool in your arsenal. It’s designed to help you spot doji candles efficiently, and I’ve made some tweaks to enhance its performance.
Understanding the RangeOfBars Variable
To kick things off, I added a RangeOfBars variable. This nifty feature lets you specify how many bars back from the current candle you want to check for dojis. By setting it to 2 or 3, you can identify potential double dojis, giving you an edge in your trading strategy. For instance, you could create a method for IsDoji that focuses solely on the first candle position, and then establish another method to check both the first and second positions for double dojis. This way, your code can easily dictate when to trade or not—like saying, if IsDoji, then no trade, but if IsDoubleDoji, trade on extension!
Improved Coding for Efficiency
The previous version of the Doji Reader 2 didn't handle 5-digit conditions very well. No worries, though! I've streamlined the code to make it more efficient. While I won't claim mine is the ultimate solution, it's definitely a step in the right direction.
Keeping it Simple with ShowCandleBox
I opted to maintain the ShowCandleBox feature because it’s a great way to visualize indicators on your chart, and it performed well during testing. While extra indicators and text can be educational, I wanted to keep things straightforward to avoid overwhelming users.
Precision Matters: Switching to Doubles
A significant change I made was to switch the configuration values from integers to doubles. This shift allows us to leverage 5-digit precision, resulting in a cleaner and more accurate doji detection. Just a heads-up: when using indicators based on doubles, avoid integers unless you’re counting something specific.
Counter Reset for Accurate Tracking
I also implemented a counter reset to prevent the boxes from piling up during the counting process. Previously, the indicator kept cycling the same counter up and up. Now, with the reset feature, we can maintain an accurate count that refreshes at the start of each processing cycle.
Buffer Management for Efficient Processing
To enhance performance, I added a buffer cleaning process, allowing you to pass 0 by default and 1 when a doji is detected. By keeping the range small, we avoid unnecessary CPU usage processing outdated data that no longer interests us.
Sample Declaration for Your Code
Here’s a quick sample declaration to integrate into your code:
extern string __DOJI_HUNTER_SETTINGS = "-----"; int RangeOfBars = 3; bool ShowCandleBox = true; //false to hide the candle box extern color BoxColor = MistyRose; //choose your favorite color
Getting Doji Data: A Quick Call Example
To get started with retrieving doji data, make sure you place this call in the new candle event section of your code. Placing it in the tick event could lead to issues:
Doji1 = iCustom(NULL, 0, "Doji_Hunter", RangeOfBars, ShowCandleBox, BoxColor, FindRegularDoji, MinLengthOfUpTail, MinLengthOfLoTail, MaxLengthOfBody, FindDragonflyDoji, MaxLengthOfUpTail1, MinLengthOfLoTail1, MaxLengthOfBody1, FindGravestoneDoji, MinLengthOfUpTail2, MaxLengthOfLoTail2, MaxLengthOfBody2, 0, 0);
This code snippet will give you the first candle location value of either 0 or 1, where 1 indicates that a doji has been found.
Happy trading, and may your charts be filled with profitable doji patterns!
Related Posts
- Unlocking the Power of Master Tools for MetaTrader 4
- Mastering the Doji Reader Indicator for Better Trading Decisions
- Unlock Trading Insights with Volume Profile + Range v6.0 for MetaTrader 5
- Unlocking MetaCOT 2: Your Ultimate CFTC Indicator Toolkit for MT4
- Hourly Buffers for Data Collection in MetaTrader 5: A Simple Guide