Download MetaTrader 5
To add comments, please log in or register
Are you a good trader? Become a signals provider and make even more money!
Agent86
915
Agent86 2014.02.05 22:49 

Hi all

I'm just playing around trying to learn custom indicator basics

Subject regarding the fractals indicator:
I noticed while the fractal indicator is on the chart the most recent arrow appears for a fractal, but the last most recent candle of the fractal is not yet closed so it's not really a confirmed fractal (why is the arrow there ?)
I'm reading the ( Indicators line identifiers enumeration ) there is no PRICE_CLOSE mode like with other indicators
Do I need a PRICE_CLOSE or is this not relevant for fractals ?

I'm just considering how I would open a trade based on a custom fractal indicator that is not really confirmed.

Does this matter for EA purposes or is this not relevant ?

Please explain this topic
Thanks.

whroeder1
13644
whroeder1 2014.02.06 02:05  
Agent86: Do I need a PRICE_CLOSE or is this not relevant for fractals ?
Do you know what the definition of a fractal is? Lowest low/Highest high plus 1 or more higher lows/lower highes on ether side. Why would you need the closing bar price?
Agent86
915
Agent86 2014.02.06 15:05  
Yes I know the fractals but I thought the standard fractal was 5 candles construction.
Lets say generally a fractal with MODE_UPPER = High[ i ] would be a series of 5 candles with 2) lower highs to the left, and 2) lower highs to the right. The High[ i ] being the middle highest candle in the center. Am I wrong ?

But if Bar[0] is not closed yet then why does the indicator form if the 5 candles are not confirmed. There are only 4 closed candles thus far. Shouldn't it be formed after the 5th candle closes ?

Unless the fractal is formed from 3 candles then that would make sense but I thought it was 5.

I'll post the code later but I'm on linux now so I can't access till I boot back to windows again.

But I thought I would need the closed bar price of the included time period candle ? Not just Bar[0] fluctuating without confirming the actual formation of the fractal ? Why would it be a fractal if at the end of the period the price high shot up and broke the center highest high ?
I mean we do not really know if it's a fractal yet which is why I'm wondering why the indicator is appearing on the chart.
It might have something to do with my for loop
I'll post the code later once I'm on windows

Thanks for the replies
whroeder1
13644
whroeder1 2014.02.06 17:46  
Agent86:But if Bar[0] is not closed yet then why does the indicator form if the 5 candles are not confirmed. There are only 4 closed candles thus far. Shouldn't it be formed after the 5th candle closes ?

Unless the fractal is formed from 3 candles then that would make sense but I thought it was 5.

I mean we do not really know if it's a fractal yet which is why I'm wondering why the indicator is appearing on the chart.

  1. there may be 4 closed candles, but there is 5 candles, so it will be a fractal unless a new local extreme forms. Just like you can get the moving average for bar zero but that value moves up and down until the bar finishes.
  2. If it was 3 the arrow wouldn't come and go. Did you bother to look at the code and find out?
  3. Why are you looking for a fractal on bars 0..2?
Agent86
915
Agent86 2014.02.12 21:48  
HI thanks

I'm not looking for fractals on bar 0-2 I'm trying to avoid that.
However, now that I revisit the code it seem creating my custom indicator uses [i] as if it were a shift (0)
So this makes sense why it's not waiting until confirmation of the actual fractal closed formation.
I want shift (3) which is more typical

Oh well, Back to the drawing board




//+------------------------------------------------------------------+
//|                           4hr factal and ema test                              
//+------------------------------------------------------------------+


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Red 

//---- buffers
double v1[];
double v2[];
double v3[];
double val1;
double val2;
double val3;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
//----
   IndicatorBuffers(3);

   SetIndexArrow(0, 241);
   SetIndexStyle(0,DRAW_ARROW,EMPTY,5,Green);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
   

   SetIndexArrow(1, 242);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,5,Red);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
  
   
   //SetIndexArrow(2, 0);
   SetIndexStyle(2,DRAW_LINE,Red);
   SetIndexBuffer(2, v3);
   SetIndexLabel(2,"My 40 EMA Line");
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {        
  
   for(int i=Bars-1; i>=0; i--)
    {
     val3=iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,i);
     if (val3 > 0)
         {
         v3[i] = val3;
         }
     
     val1=iFractals(NULL, 0, MODE_UPPER,i);
     if (val1 > 0 && val1 > val3)
        {                             
         v1[i]=High[i]; //makes arrow above candle      
                         
         //Print ("v1[", i, "]= ", v1[i], " Resistance");
         
         }              
      
     val2=iFractals(NULL, 0, MODE_LOWER,i);
     if (val2 > 0 && val2 < val3)
        {
         v2[i]=Low[i]; //makes arrow below candle
          
         //Print ("v2[", i, "]= ", v2[i], " Support");
        }
          
     }    
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
Agent86
915
Agent86 2014.02.12 21:51  
Hey !

So I could change the for statement: i>=3; ??

for(int i=Bars-1; i>=3; i--)
Yikes at least for the Fractals huh ?
/
To add comments, please log in or register