I had a similar question with getting rid of the connector lines in the Fractal
Channel indicator. I figured out how to do it. Basically, you have to use the EMPTY_VALUE
constant in the array you are plotting. this will leave only the support/resistance
lines you are after. By the above image, I think you will have to use multiple
arrays, as I don't know how to plot lines over top of eachother using the same
array data. This should be enough food-for-thought to get you started though. Also,
you will not be able to get your lines to extend all the way to the next bar, as
this will require holding two values at the same time point. If you figure out
how to do it, let me know.
Now for the code. I set things up so the lines become disconnected only for backtesting ie. set MaxBars = 0 to plot the entire dataset. Hence the "if" condition, but you can eliminate this "if" condition from the code altogether if you want. I only need the disconnected s/r lines for backtesting when I'm scrolling bar-by-bar, as the regular indicator gives away the price direction. When trading for real, I set the default Maxbars to 30 bars so as to not clutter up the screen. I don't do any automated trading, as I believe all systems need the human element to make final decisions. This is an excerpt of my full indicator - what you see is the part you're after. Again if you can find a way to make the indicator look more like the above picture, post your result.
Cheers,
Enforcer2006
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Orange
extern int MaxBars = 30;
//---- buffers
double v1[];
double v2[];
double val1;
double val2;
double vHighest = EMPTY_VALUE;
double vLowest = EMPTY_VALUE;
int i;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
// SetIndexArrow(0, 119);
// SetIndexArrow(1, 119);
//----
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1, indicator_color1);
SetIndexDrawBegin(0, i-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Resistance");
//----
SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,1, indicator_color2);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Support");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if (MaxBars < 1)
MaxBars = Bars;
i = MaxBars;
while(i >= 0)
{
val1 = iFractals(NULL, 0, MODE_UPPER, i);
//----
if(val1 > 0)
{
v1[i] = High[i];
vHighest = v1[i];
if (MaxBars == Bars)
v1[i] = EMPTY_VALUE;
}
else
v1[i] = vHighest;
val2 = iFractals(NULL, 0, MODE_LOWER, i);
//----
if(val2 > 0)
{
v2[i] = Low[i];
vLowest = v2[i];
if (MaxBars == Bars)
v2[i] = EMPTY_VALUE;
}
else
v2[i] = vLowest;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Now for the code. I set things up so the lines become disconnected only for backtesting ie. set MaxBars = 0 to plot the entire dataset. Hence the "if" condition, but you can eliminate this "if" condition from the code altogether if you want. I only need the disconnected s/r lines for backtesting when I'm scrolling bar-by-bar, as the regular indicator gives away the price direction. When trading for real, I set the default Maxbars to 30 bars so as to not clutter up the screen. I don't do any automated trading, as I believe all systems need the human element to make final decisions. This is an excerpt of my full indicator - what you see is the part you're after. Again if you can find a way to make the indicator look more like the above picture, post your result.
Cheers,
Enforcer2006
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Orange
extern int MaxBars = 30;
//---- buffers
double v1[];
double v2[];
double val1;
double val2;
double vHighest = EMPTY_VALUE;
double vLowest = EMPTY_VALUE;
int i;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
// SetIndexArrow(0, 119);
// SetIndexArrow(1, 119);
//----
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1, indicator_color1);
SetIndexDrawBegin(0, i-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Resistance");
//----
SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,1, indicator_color2);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Support");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if (MaxBars < 1)
MaxBars = Bars;
i = MaxBars;
while(i >= 0)
{
val1 = iFractals(NULL, 0, MODE_UPPER, i);
//----
if(val1 > 0)
{
v1[i] = High[i];
vHighest = v1[i];
if (MaxBars == Bars)
v1[i] = EMPTY_VALUE;
}
else
v1[i] = vHighest;
val2 = iFractals(NULL, 0, MODE_LOWER, i);
//----
if(val2 > 0)
{
v2[i] = Low[i];
vLowest = v2[i];
if (MaxBars == Bars)
v2[i] = EMPTY_VALUE;
}
else
v2[i] = vLowest;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Think some more...
Enforcer2006..
Thank you so much for your time answering this question; I can see you really know you stuff :-) Sadly my programming/coding skills are non-existent, so turning your advice into a functioning indicator is still beyond me. Maybe someone could take it the final few steps if they think it might be of value to the community.
Thanks again.
Thank you so much for your time answering this question; I can see you really know you stuff :-) Sadly my programming/coding skills are non-existent, so turning your advice into a functioning indicator is still beyond me. Maybe someone could take it the final few steps if they think it might be of value to the community.
Thanks again.
phy:
Think some more...
OK Phy. You've GOT to show me how you did this! :-) This is EXACTLY what I was hoping for...
Please, please.
phy:
Think some more...
So, Phy, can you share this indicator with us, or is it not a public thing? I'd REALLY like to use if it's available... :-)
Many thanks
Just waiting for you to try yourself.
phy:
LOL. I appreciate the encouragement -- I really do -- but I have no programming
skills or coding knowledge. The best I can do is go in to Meta Editor and change
line colors and weights... and that took a lot of trial and error before I got
that right!Just waiting for you to try yourself.
Some of us just don't have the development in that area of our brains to get a grip on scripting... I wish I could. Man, I've even been trying to understand Neural Networks... but that might just as well be Cantonese....
So, go easy on me please. I have to rely on the generosity of others for the workings of these indicators -- if there's any OTHER way I can contribute, I certainly try to :-)
Respectfully.
phy:
Just waiting for you to try yourself.
I know it's been a long time, hope you're still here...?
I was never able to make this work for myself. Would you be so kind as to enlighten me?
This is the result I got from using the code from enforcer2006...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I was wondering if anyone has seen (has written/would write) an indicator that added a horizontal 'tail' to a confirmed fractal ? A tail that ended ONLY at the point that the fractal was overtaken by price. like the mock up above...
I think this would be very useful, not just for fractal-break traders like myself, but as an cumulative support/resistance indicator...
Would that be a difficult piece of code?
many thanks
.