Hello.
I am interested in your indicator. But I need the lines "TL_Support" and "TL_Resistance" to be built not by the last two fractals, but by the last one and the next higher/lower one.
I have made changes to the code. It works fine online, but in the tester it refuses to work. It makes the first construction and freezes. Could you please tell me how to make the indicator with changes work in MT5 tester?
I will quote the code below, the changes made will be highlighted in yellow.
//+------------------------------------------------------------------+ //| Search for fractal values| //+------------------------------------------------------------------+ // --- Search for the first upper fractal for(n=0; n<Bars(Symbol(),base_tf); n++) { // --- if a non-empty value, terminate the loop if(FractalUp_base[n]!=EMPTY_VALUE) break; } UpFractal_1_base=FractalUp_base[n];// --- write the price value of the first fractal in the variable UpperFractal_1_base=n;// --- write the index of the first fractal in the variable // --- // --- Search for the second upper fractal for(n=UpperFractal_1_base+1; n<Bars(Symbol(),base_tf); n++) { // --- if a non-empty value, terminate the loop if( FractalUp_base[n]!=EMPTY_VALUE && FractalUp_base[n]>UpFractal_1_base ) break; } UpFractal_2_base=FractalUp_base[n]; // --- write the price value of the second fractal in the variable UpperFractal_2_base=n;// --- write the index of the second fractal in the variable // --- // --- Search for the first lower fractal for(n=0; n<Bars(Symbol(),base_tf); n++) { // --- if a non-empty value, terminate the loop if(FractalDown_base[n]!=EMPTY_VALUE) break; } LowFractal_1_base=FractalDown_base[n];// --- write the price value of the first fractal in the variable LowerFractal_1_base=n;// --- write the index of the first fractal in the variable // --- // --- Search for the second lower fractal for(n=LowerFractal_1_base+1; n<Bars(Symbol(),base_tf); n++) { // --- if a non-empty value, terminate the loop if( FractalDown_base[n]!=EMPTY_VALUE && FractalDown_base[n]<LowFractal_1_base ) break; } LowFractal_2_base=FractalDown_base[n];// --- write the price value of the second fractal in the variable LowerFractal_2_base=n;// --- write the index of the second fractal in the variable //---
I haven't checked it myself, but try to add a better condition for drawing the lines themselves, where objects are created. For example, for a support line:
//--- Create support line if (LowFractal_1_base<LowFractal_2_base)//if the price of the first found fractal is lower than the price of the second found fractal, then draw a line { ObjectCreate(0,"TL_Support",OBJ_TREND,0,LowFractalTime_2_base[0],LowFractal_2_base,LowFractalTime_1_base[0],LowFractal_1_base); ObjectSetInteger(0,"TL_Support",OBJPROP_RAY_RIGHT,true); ObjectSetInteger(0,"TL_Support",OBJPROP_COLOR,Support_Color); ObjectSetInteger(0,"TL_Support",OBJPROP_STYLE,Support_Style); ObjectSetInteger(0,"TL_Support",OBJPROP_WIDTH,Support_Width); }
I haven't checked it myself, but try to add a better condition for drawing the lines themselves, where objects are created. For example, for a support line:
Good afternoon, thanks for your comment. The idea is good, but for support lines the condition should be (according to the logic I am trying to implement) the opposite, the low of the second fractal found should be lower than the first one, all candidates for the second fractal whose low is higher than the first one should be ignored
And also, if you go this way, you will have to redesign the drawing block, actually, and everything else after that too. The beautiful code will lose its elegance, IMHO.
There is one more factor why I wrote a comment to this post - the programme works perfectly well, everything is drawn perfectly on real quotes, on time, without bugs, but in the tester it doesn't want to. And when something is unclear, it alarms and stresses me, so I want to figure it out.
The file of the edited code is attached, I will be extremely grateful if more competent comrades will point out the reason for such behaviour of the tester.
Good afternoon, thank you for your comment. The idea is good, but for support lines the condition should be (according to the logic I am trying to implement) the opposite, the low of the second fractal found should be lower than the first one, all candidates for the second fractal, whose low is higher than the first one, should be ignored
And also, if you go this way, you will have to redesign the drawing block, actually, and everything else after that too. Beautiful, IMHO, code will lose its elegance.
There is one more factor why I wrote a comment to this post - the programme works perfectly well, everything is drawn perfectly on real quotes, on time, without bugs, but in the tester it doesn't want to. And when something is unclear, it alarms and stresses me, so I want to figure it out.
The file of the edited code is attached, I will be extremely grateful if more competent comrades will point out the reason for such behaviour of the tester.
Apparently, there is a conflict with the FractalDown_base[] array. It is strange that it does not occur for the upper fractals. Anyway, I have modified your comparison a bit:
for(n=LowerFractal_1_base+1; n<Bars(Symbol(),base_tf); n++) { // --- if a non-empty value, terminate the loop if(FractalDown_base[n]!=EMPTY_VALUE && FractalDown_base[n]<Low_base_tf[LowerFractal_1_base] ) break; }
That is, I added the definition of High and Low and compare already with them. This way everything works fine in the tester. The modified file is attached.
Apparently, there is a conflict with the FractalDown_base[] array. Strangely, it does not occur for the top fractals. Anyway, I changed your comparison a bit:
That is, I added the definition of High and Low and compare already with them. This way everything works fine in the tester. The modified file is attached.
Good afternoon, thank you for your time and attention. I have uploaded the attached file. Unfortunately, the tester still works incorrectly, the indicator makes the first construction and no longer rebuilds the resistance and support lines, does not display fractals. To test it, I have output High_base_tf[UpperFractal_1_base] and Low_base_tf[LowerFractal_1_base] in the comment. It counts correctly, everything is fine with the logic. Apparently, the failure lurks somewhere in the drawing.
The screen scan, which shows that new fractals are formed, but the lines are not rebuilt, is attached at the link.
***
There you can also see the lines Low_base_tf[LowerFractal_1_base] and their values, which can be compared with the values of LowFractal_1_base (for low values, for high values similarly). Everything counts correctly, but there are NO new constructions.
The screen scan, which shows that new fractals have been formed, but the lines have not been rearranged - attached at the link.
***
Unfortunately, the link has been removed.
Unfortunately the link has been removed.
Links to third-party sites are prohibited.
Links to third party sites are not allowed.
How can I post a scan of the tester screen? I can only get it out in PDF, and I understand this format is not accepted on the forum.
How can I post a screen scan of the tester? I can only get it out in PDF, and I understand that this format is not accepted on the forum.
A screenshot is a picture. What does pdf have to do with it? Save the screenshot as a png image and paste the image into your post.
Links to third-party sites are prohibited.
Vladimir, good evening. You are an experienced programmer judging by your publications and works. Could you please advise me on the essence of this thread - the programme does not work in the tester, but it works correctly on online charts. The author does not respond, apparently busy.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Fractal_TL:
An indicator for automatic drawing of trendlines based on fractals of a given timeframe.
Author: Almat Kaldybay