FractalBestAll

Author: Copyright � 2005, MetaQuotes Software Corp.
FractalBestAll
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
FractalBestAll
//+------------------------------------------------------------------+
//|                                                     Fractals.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters

//---- buffers
double dUpFractalsBuffer[];
double dDownFractalsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,dUpFractalsBuffer);
    SetIndexBuffer(1,dDownFractalsBuffer);   
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,241);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,242);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Fractal Up");
    SetIndexLabel(1,"Fractal Down");
//---- initialization done   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int i,nCountedBars;
    double up,dw,nul=0.0001;
    nCountedBars=IndicatorCounted();
//---- check for possible errors
    if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted    
    if(nCountedBars<=2)
       i=Bars-nCountedBars-3;
    if(nCountedBars>2)
      {
       nCountedBars--;
       i=Bars-nCountedBars-1;
      }
    while(i>=2)
     {
//----Up and Down Fractals
//----5 bars Fractal
       if(High[i+3]>High[i+4] && High[i+3]>High[i+5] && High[i+3]>High[i+2] && High[i+3]>High[i+1])
        { 
         up=Low[i]-3*Point;
         dUpFractalsBuffer[i]=up;
        }
       else {dUpFractalsBuffer[i]=nul;} 
       if(Low[i+3]<Low[i+4] && Low[i+3]<Low[i+5] && Low[i+3]<Low[i+2] && Low[i+3]<Low[i+1])
        { 
         dw=High[i]+3*Point;
         dDownFractalsBuffer[i]=dw;
           i--;
           continue;
         }
        else {dDownFractalsBuffer[i]=nul;}                                    
      i--;
     }

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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---