Download MetaTrader 5

Examples: Drawing Horizontal Break-Through Levels Using Fractals

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
182378
MetaQuotes Software Corp. 2008.09.05 14:06 

New article Drawing Horizontal Break-Through Levels Using Fractals has been published:

The article describes creation of an indicator that would display the support/resistance levels using up/down fractals.

In the first instance, the fractal levels can be useful while moving the StopLoss level under the red line at a rising market. You should keep the StopLoss above the blue line at a receding market. In such a manner the safe intelligent distance between the StopLoss and the market will be ensured.

For example, we entered the market (see the chart, mark 1) with the stop above the blue line (mark 2), if the red line is broken through (mark 3) we move the StopLoss (mark 4), if a new breakthrough occurred (mark 5), we move the StopLoss analogously (mark 6). If the blue line is broken through (mark 7), we liquidate the position.

Author: Victor Chebotariov

MQL4 Comments
16319
MQL4 Comments 2008.09.06 08:41  
Is that same with Bollinger Band? Thank You.
MQL4 Comments
16319
MQL4 Comments 2008.09.06 11:35  

Handy article and nice coding.


Thanks,

Javier.

MQL4 Comments
16319
MQL4 Comments 2008.09.06 14:50  

Hi

I like this a lot but can someone please tell me how to attach it to chart. I have tried the usual but I cannot get the lines drawn on a chart.

Thanks

Ross

Andrea Bronzini
106
Andrea Bronzini 2008.09.08 07:14  
cornie84:
Is that same with Bollinger Band? Thank You.

No, it seems much better than BB.

This one gives you a much sharper information and narrow range.


I think a piece of code is missing anyway... I couldnt visualize the bars then I noticed that you dont define the ...

I added this 2 lines:


IndicatorBuffers(2);
IndicatorDigits(Digits);


just before SetIndexStyle lines... now it works perfectly.


Thanx for sharing!



Zyp

MQL4 Comments
16319
MQL4 Comments 2008.09.08 11:27  

To be expected to do?

I have put in several of my graphics and so far nothing has happened.


Explain please.

MQL4 Comments
16319
MQL4 Comments 2009.02.05 19:49  

The variable used for short-position stoploss appears to be incorrectly specified as FLL:

original code

if(Close[0]<FLL) //Trailing-stop for the short positions
  {
   if(OrderStopLoss()>FLL+(Ask-Bid+3)*Point || OrderStopLoss()==0)
     {
      OrderModify(OrderTicket(),OrderOpenPrice(),FLL+(Ask-Bid+3)*Point,OrderTakeProfit(),0,Red);
      return(0);
     }
  }

Correct code(?) using FLU as the price level to base the new short-position's stoploss:

edit: also the use of (Ask-Bid+3)*Point is incorrect...should be simply Ask-Bid+3*Point without the parentheses.

if(Close[0]<FLL) //Trailing-stop for the short positions
  {
   if(OrderStopLoss()>FLU+Ask-Bid+3*Point || OrderStopLoss()==0)
     {
      OrderModify(OrderTicket(),OrderOpenPrice(),FLU+Ask-Bid+3*Point,OrderTakeProfit(),0,Red);
      return(0);
     }
  }
koko
9
koko 2010.06.11 01:10  

The code is wrong. So should be the test results. Fractals form after the close of at least 2 bars after high/low. This indicator plots lines right after the fractal bar which will not exist in real time -so, it does not work correctly real time.

This shall fix how it gets the values of the upper and lower fractals:

double upfrac_val = iFractals(NULL, 0, MODE_UPPER, i + 3);
double lofrac_val = iFractals(NULL, 0, MODE_LOWER, i + 3);
To add comments, please log in or register