Discussing the article: "Developing Advanced ICT Trading Systems: Implementing Order Blocks in an Indicator" - page 2

 
Niquel Mendoza #:

Regarding the first problem, I think it could be due to the indicator not loading the data correctly. This usually happens when changing charts or opening a new one. However, if it is a chart that was already in use, it would be worth investigating further why the order blocks are not being obtained. In that case, it would be useful to include debug (Print) messages in the code to identify the problem.

Regarding the second problem, where only bullish order blocks are drawn, it could be because the EURUSD in the H4 timeframe is currently at 600-700 candlestick highs. In that context, it is possible that all the bearish order blocks have been mitigated, which is why they are not drawn on the chart.

Regarding the criteria change, I reduced some Boolean variables in the code. However, it would not be a problem to reintroduce those conditions if necessary.

Regarding the colors, the latest version I posted in the comments applies transparency to the colors of the order block rectangles. Perhaps that's why the colors don't visually match those of previous versions. Finally, regarding the animation, I didn't quite understand what you were referring to. Could you explain in more detail what you mean by animation in this context?

At Section 3.0 Conclusion you presented a video of the indicator in action for XAUUSD M1.  I was wondering if you were using the Strategy Tester Indicator function to produce the video.  When I run the Strategy Tester, generally for an EA with Visal Mode checked it does show the indicators and trades but it generally does not display the text that the EA that is running.  I was just wondering if you might know of the cause or a solution.


Also, I have found that resizing large multidemensional arrays takes an inordinate time to resize.  I have resorted to using 100 additional elements in each resize to minimize the elapsed time.  This works great for me as I use the zero based arrays for time series.

 
CapeCoddah #:

At Section 3.0 Conclusion you presented a video of the indicator in action for XAUUSD M1.  I was wondering if you were using the Strategy Tester Indicator function to produce the video.  When I run the Strategy Tester, generally for an EA with Visal Mode checked it does show the indicators and trades but it generally does not display the text that the EA that is running.  I was just wondering if you might know of the cause or a solution.


Also, I have found that resizing large multidemensional arrays takes an inordinate time to resize.  I have resorted to using 100 additional elements in each resize to minimize the elapsed time.  This works great for me as I use the zero based arrays for time series.

Hello CapeCoddah.

I used an external application to record the video, not a built-in Strategy Tester feature.

Regarding the text you mention during the execution of the Expert Advisor, I understand that it could be something external to MQL5 and not graphical objects like labels. It would be very helpful if you could share a screenshot so I can analyze it better.

Best regards.


 

HI,

Thanks for the information,  I appreciate it.

On translating your comments from Spanish to English.  As Google Translate does not translate text after a // in the line, it did not fit my needs to translate your comments.  I tried DeepL and it does translate text beyond //.  It was also difficult for me to understand.  Translating the code was not difficult but saviing the translation was impossible.  Nonetheless,  it really made a botch job of translating.  It inserted periods and "End" where it thought the sentence ended.  In addition it changed && to &&& and certainly more problems.  I gave up after correcting these errors and the compile still produced more than 100 errors.  

I ran your Part 2 through the Strategy tester and your TP & SL lines and text show.  However, it looks like you calculations for the TP & SL levels need to be adjusted.  n addition, the test shows overlapping SLs and TPs,  In a non hedging environment, the SLs and TPs would be merged into one SL or TP.  There should be only one line, not two and it should have a step to indicate the change in value.  Also it does not show on the chart where your predicted trade begins.

I have decided to concentrate on your first program as it seems to produce more signals.  I am planning to: incorporate a mechanism to terminate the signal  when its trend ends; to eliminate duplicate signals within n bars of each other;  standardize the box height centered around the bar median; identify and modify the order block parameters to enable rational use on periods H1 and above; place a Moving Average of the volumes on either the main chart of open an indicator chart; and finally to convert to zero based arrays to conform to my standard use and eventually incorporate it into my EA.  I will attempt to use functions to perform and encapsulate the logic to allow you to incorporate it if desired.  However, my programming organization style is is non traditional and does not conform to MetaQuotes automatic indentations.

I will continue to follow you as I believe you have a very good approach to trading, keep up the great efforts.

Cheers and warm regars,


CapeCoddah

 

Hello,

I was just testing my EA in the Strategy Tester, EURUSD H4 1/1/2025-2//1/2025, and observed at the end of the run, there were two problems with the Block Order indicator.

First, it selected a block order on 2/3/2025 which is outside of the test window and secondly, it placed the block text in the Chart Shift area.


Enjoy


CapeCoddah

 

Here is an English Translated version of your first indicator.  I decided I needed to understand your many code comments in English and reconsidered Google Translate as DeepL did not impress me.  I first changed all // comments into #/# to allow Google translate the // line comments.. and then converted the text file into a MS Word document for input to Translate.  After the translation, I opened the new document and saved it as a text file, renamed it and began syntaxing the new source.   I estimate that Translate did 90% of the work but it did add spaces and characters that required manual conversion.  After a days work, it compiled with out errors.  AMAZINGLY it worked on the first try! I compared it to your original indicator for 1000 bars and they were identical.

 
CapeCoddah # :

Here is an English Translated version of your first indicator.  I decided I needed to understand your many code comments in English and reconsidered Google Translate as DeepL did not impress me.  I first changed all // comments into #/# to allow Google translate the // line comments.. and then converted the text file into a MS Word document for input to Translate.  After the translation, I opened the new document and saved it as a text file, renamed it and began syntaxing the new source.   I estimate that Translate did 90% of the work but it did add spaces and characters that required manual conversion.  After a days work, it compiled with out errors.  AMAZINGLY it worked on the first try! I compared it to your original indicator for 1000 bars and they were identical.

Hi CapeCoddah, I thought the code you created was excellent. Sorry for not responding sooner; I'm involved in several projects, which has limited my availability to help you. However, today I can dedicate some time to working on an improved version of the indicator. I'm sharing the code below.
 

Unfortunately it appears that your indicator is structurally flawed and useless for trading as it is performing its calculations on future variables that are unknownat the time of the calculation as highlighted in the code below in bold.  

          for( int i = Universal_search_range ; i > 5 ; i--) {
      //error checking
               if( i + 3 > ArraySize(highArray) || i + 3 > ArraySize(atr))
                  continue ;
               if( i < 0) continue;
      
      // Update candlestick indices
               one_candle = i ; //central candle
               candle_behind_two = i +2;
               candle_behind_one = one_candle +1;
               two_candle = one_candle - 1;
               three_candle = one_candle - 2;
               four_candle = one_candle -3;

      
      // Calculate the average volume of previous candles
               body1 = MathAbs(closeArray[one_candle] - openArray[one_candle]);
               body2 = MathAbs(closeArray[two_candle] - openArray[two_candle]);
               body3 = MathAbs(closeArray[three_candle] - openArray[three_candle]);

 
CapeCoddah #:

Unfortunately it appears that your indicator is structurally flawed and useless for trading as it is performing its calculations on future variables that are unknownat the time of the calculation as highlighted in the code below in bold.  

          for( int i = Universal_search_range ; i > 5 ; i--) {
      //error checking
               if( i + 3 > ArraySize(highArray) || i + 3 > ArraySize(atr))
                  continue ;
               if( i < 0) continue;
      
      // Update candlestick indices
               one_candle = i ; //central candle
               candle_behind_two = i +2;
               candle_behind_one = one_candle +1;
               two_candle = one_candle - 1;
               three_candle = one_candle - 2;
               four_candle = one_candle -3;

      
      // Calculate the average volume of previous candles
               body1 = MathAbs(closeArray[one_candle] - openArray[one_candle]);
               body2 = MathAbs(closeArray[two_candle] - openArray[two_candle]);
               body3 = MathAbs(closeArray[three_candle] - openArray[three_candle]);

Hello CapeCoddah, I think that is not the case, since for example the indicator does all the calculations using arrays in series (although it is not common, they are normally done without series) in the context of the first loop shown, that loop is used to detect order blocks, what is done is go from the "Universal_search_range" candle (Remember that in series candle 0 is the most recent) to candle 6 so at no time do I see future candles being used and if that were the case then two_candle or another index would result in a value less than 0 causing out of range. So the candle four_candle = one_candle - 3, would be the closest to 0 in the case that the loop ends where i = 6 then four_candle = 3, so taking into account that the current candle is 0 then, I can say that at no time am I using future candles. The name may sound confusing, I know, but I did it that way because it was easier for me to understand, given that when it came to obtaining the order blocks, one_vela was like the central candle. So if I was looking for a strong move, I would evaluate the candles that followed it (in series, this would be subtraction).