[Fractals] Fractals and trend based EA in development

 

Good afternoon,

I am having problems interpretating fractals because the indicator does not behave as I have read it should. This is what I though a fractal was, and it should be componed with 5 bars, right?

Instead, MT4 is drawing fractals everywhere, not componed by 5 bars or any pattern that seems predictable to me. Like this:


Would you be kind enough to explain to me -or point me- to a straighforward explanation of what fractals are and when does the signal trigger? Thank you!

 
deVries:

Thank you. I quote from the page... Gractal Technical Indicator it is a series of at least five successive bars, with the highest HIGH in the middle, and two lower HIGHs on both sides. The reversing set is a series of at least five successive bars, with the lowest LOW in the middle, and two higher LOWs on both sides, which correlates to the sell fractal. The fractals are have High and Low values and are indicated with the up and down arrows.

Does that mean that a fractal is marked after TWO reversal candles have taken place from the marked candle, right?

 
flaab:
deVries:

Thank you. I quote from the page... Gractal Technical Indicator it is a series of at least five successive bars, with the highest HIGH in the middle, and two lower HIGHs on both sides. The reversing set is a series of at least five successive bars, with the lowest LOW in the middle, and two higher LOWs on both sides, which correlates to the sell fractal. The fractals are have High and Low values and are indicated with the up and down arrows.

Does that mean that a fractal is market after TWO reversal candles have take place from the market candle, right?


Not reversal if that means by high fractal it has to be followed by two bear candels.

It just means that the fractal is pointing the highest or lowest when it is the middle of 5 bars

So it can be that a high fractal is followed with also two bull candels but the high of those candels are lower then the high of the middle candel

If bar zero is not ended yet a fractal on bar 2 is still not definitive....

 
deVries:


Not reversal if that means by high fractal it has to be followed by two bear candels.

It just means that the fractal is pointing the highest or lowest when it is the middle of 5 bars

So it can be that a high fractal is followed with also two bull candels but the high of those candels are lower then the high of the middle candel

If bar zero is not ended yet a fractal on bar 2 is still not definitive....


Ok, I get it. So for a definitive fractal in shift=3, bar shift=1 must be already closed. Right?
 
flaab:

Ok, I get it. So for a definitive fractal in shift=3, bar shift=1 must be already closed. Right?

Ofcours Bar 1 is always closed .... If there is a bar 1 then bar 0 has its first tick
 

Yes. I would like to receive the last upper and lower fractal based on already closed bars. So I would need to do the following right?

double upper_fractal = iFractals (NULL, 0, MODE_UPPER, 1);
double lower_fractal = iFractals (NULL, 0, MODE_LOWER, 1);

Or should I use shift 3 (three bars ago)

double upper_fractal = iFractals (NULL, 0, MODE_UPPER, 3);
double lower_fractal = iFractals (NULL, 0, MODE_LOWER, 3);

Thank you for your attention.

 
flaab:

Yes. I would like to receive the last upper and lower fractal based on already closed bars. So I would need to do the following right?

Or should I use shift 3 (three bars ago)

Thank you for your attention.


//+------------------------------------------------------------------+
//|                                                    Comments3.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Tjipke de Vries"
#property link      ""

#property indicator_chart_window

extern int shift = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   subPrintDetails();
//----
   return(0);
  }
//+------------------------------------------------------------------+

//----------------------- PRINT COMMENT FUNCTION
void subPrintDetails()
{
   string sComment   = "";
   string sp         = "----------------------------------------\n";
   string NL         = "\n";
   
    double upper_fractal1 = iFractals (NULL, 0, MODE_UPPER, 1);
    double lower_fractal1 = iFractals (NULL, 0, MODE_LOWER, 1);
    double upper_fractal3 = iFractals (NULL, 0, MODE_UPPER, 3);
    double lower_fractal3 = iFractals (NULL, 0, MODE_LOWER, 3);
    double upper_fractalshift = iFractals (NULL, 0, MODE_UPPER, shift);
    double lower_fractalshift = iFractals (NULL, 0, MODE_LOWER, shift);      
       
   sComment = "Comments EA              Copyright © 2012, Tjipke" + NL;
   sComment = sComment + NL;

   sComment = sComment + "upper_fractal1 " + DoubleToStr(upper_fractal1,Digits) + NL;
   sComment = sComment + "upper_fractal3 " + DoubleToStr(upper_fractal3,Digits) + NL;
   sComment = sComment + "upper_fractalshift " + DoubleToStr(upper_fractalshift,Digits) + NL;
   sComment = sComment + NL;
   sComment = sComment + "lower_fractal1 " + DoubleToStr(lower_fractal1,Digits) + NL;
   sComment = sComment + "lower_fractal3 " + DoubleToStr(lower_fractal3,Digits) + NL;
   sComment = sComment + "lower_fractalshift " + DoubleToStr(lower_fractalshift,Digits) + NL;
   
   sComment = sComment + NL;


   Comment(sComment);
}
//+------------------------------------------------------------------+
use this indicator
 
Thank you DeVries, I think that confirms what I thought. I just need the last support - resistance fractals based on closed bars. I guess shift = 1 is adequate. Cheers!
 

Hello again,

I think I have it, but it does something weird. I want to read data from indicator "Fractal support and resistance" which is displayed as follows, being blue dotted lines support and red resistances.

The source code for the indicator is the following, I am reading buffer 0 for resistances and buffer 1 for supports, but support values seem to be random and inaccurate.

//+------------------------------------------------------------------+
//|                Support and Resistance                            |
//|                Copyright © 2004  Barry Stander                   |
//|                http://myweb.absa.co.za/stander/4meta/            |
//+------------------------------------------------------------------+
#property copyright "Click here: Barry Stander"
#property link      "http://myweb.absa.co.za/stander/4meta/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Tomato
#property indicator_color2 DeepSkyBlue

//---- buffers
double v1[];
double v2[];
double val1;
double val2;
int i;
  
int init()
  {

  IndicatorBuffers(2);
 
//---- drawing settings
 SetIndexArrow(0, 119);
 SetIndexArrow(1, 119);
  
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,0,Tomato);
   SetIndexDrawBegin(0,i-1);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
    

   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,0,DeepSkyBlue);
   SetIndexDrawBegin(1,i-1);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
 
   return(0);
  }

int start()
  {
  
   i=Bars;
   while(i>=0)
     {
   
val1 = iFractals(NULL, 0, MODE_UPPER,i);
 if (val1 > 0) 
   v1[i]=High[i];
    else
      v1[i] = v1[i+1];
  
val2 = iFractals(NULL, 0, MODE_LOWER,i);
 if (val2 > 0) 
   v2[i]=Low[i];
      else
      v2[i] = v2[i+1];

      i--;
     }   
   return(0);
  }
 
//+------------------------------------------------------------------+

I am calling this indicator as follows, being shift = 1 -last closed bar-.

double resistance = iCustom(Symbol(), 0, "Fractal Support and Resistance", 0, shift);
double support = iCustom(Symbol(), 0, "Fractal Support and Resistance", 1, shift);

However, support levels are not readed properly. Received values do not match those printed on the chart. The EA is suppossed to open positions on resistance breakouts or supports breaking down.

Supports are not readed properly and shorts are opened in the middle of nowhere. Could you please guide me to the proper usage of the indicator? Why am I reading supports wrongly?

However, the overall strategy proves accurate if most levels are readed properly or distances between errors and actual values is not big -example attached-. If not, if loses terribly.


This is an example opening only longs, since only resistance levels seem to be read properly. All shorts are wrong!

I'll share the strategy and the EA with you as soon as it's finished but I need to properly ready supports from the indicator!

Cheers!

 
int ticks;
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
ticks++;
if (ticks==1)
for (int shift=0;shift < 20;shift++)
   {
   double resistance = iCustom(Symbol(), 0, "FractalSR", 0, shift);
   double support    = iCustom(Symbol(), 0, "FractalSR", 1, shift);   
   
   Print(shift," ",resistance, " ", support);
   }
   return(0);
  }
//+------------------------------------------------------------------+

I copied your indicator (gave it a shorter name) and recompiled.

created this ea and ran it on the visual testor.

first 20 support and resistance values printed out matched the chart.

something else going on in your code...

might need to post a little more context

Reason: