Author: Lizhniyk E, edit by Scriptong
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Fr
//+------------------------------------------------------------------+
//|                                                    RFractals.mq4 |
//|                                                       Lizhniyk E |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Lizhniyk E, edit by Scriptong"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_width2 1
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       range_fractal=5; //ðàíã ôðàêòàëà (íå÷¸òíûå ÷èñëà íå ìåíåå 3)
//---- buffers
double Ext1[];
double Ext2[];
int center=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   if(range_fractal % 2 == 0) range_fractal++;
   if(range_fractal<3) range_fractal=3;
   center=range_fractal/2 + 1 ;
   //scenter=range_fractal/2;
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,119); //SetIndexArrow(0,);119
   SetIndexBuffer(0,Ext1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,119); // SetIndexArrow(1,218);119
   SetIndexBuffer(1,Ext2);
   SetIndexEmptyValue(1,0.0);
   SetIndexLabel(0,"Fractal Up");
   SetIndexLabel(1,"Fractal Down");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
double cur=0;
bool found=false;
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   for(int i=Bars-counted_bars;i>=0;i--)
    {
    //*******create history******
    //*******fractal up**********
     found = false;
     cur = High[i+center];
     if (cur > High[i+1] && cur > High[i+range_fractal]) 
       found=true;
      else
       found=false; 
     if (found) 
       for (int j=1; j < center; j++)
          if (cur <= High[i+center-j] || cur < High[i+center+j])
            {
             found = false;
             break;
            }
     if (found) 
       Ext1[i+center] = cur;
     //*************fractal down************* 
     found = false;
     cur = Low[i+center]; 
     if (cur < Low[i+1] && cur < Low[i+range_fractal]) 
       found = true;
      else 
       found = false; 
     if (found) 
       for (int k=1;k<center;k++)
         if (cur >= Low[i+center-k] || cur > Low[i+center+k]) 
           {
            found = false;
            break;
           }
     if (found) 
       Ext2[i+center]=cur;
    }
//----
   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 ---