Polarized_Fractal_Efficiency_v1

Author: Yuriy Tokman
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Polarized_Fractal_Efficiency_v1
//+------------------------------------------------------------------+
//|                                 Polarized_Fractal_Efficiency.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Teal

#property indicator_level1 100
#property indicator_level2 75
#property indicator_level3 50
#property indicator_level4 25
#property indicator_level5 -25
#property indicator_level6 -50
#property indicator_level7 -75
#property indicator_level8 -100

extern string __íàñòðîéêè_íèäèêàòîðà__ = "Çäåñü èçìåíÿåì";
extern int Perriod = 9;
extern int period_MA = 5;//0-3

double FractalEfficiency[];
double Line_Zero[];
double FractalEfficiencyTmp[];
 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(0,FractalEfficiency);
   
   SetIndexStyle(1,DRAW_LINE,1,1);
   SetIndexBuffer(1,Line_Zero);
   
   SetIndexStyle(2,DRAW_NONE);
   SetIndexBuffer(2,FractalEfficiencyTmp);      
   
   IndicatorShortName("Polarized_Fractal_Efficiency ("+Perriod+")");
   
   SetIndexLabel(0," ISQ#481971287  ");
   SetIndexLabel(1," yuriytokman@gmail.com  ");      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit-=1+Perriod;

   for(int i=limit; i>=0; i--)
   {
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     //Path1 = Sqrt( (Close – Close[Period])^2 + Period^2 )
     //Path2 = Sum(from i=0 to Period-1)Sqrt( (Close[i] – Close[i-1])^2 + 1 )
     //FractalEfficiencyTmp = Sign(Close – Close[Period]) * Path1 / Path2 * 100.0
     //FractalEfficiency = ExpMovAvg(FractalEfficiencyTmp, Smoothing Period),
     //where:
     //Close[Period] (or Close[i]) is Close Period (or i) bars back,
     //Sign(a) is +1 if a>0 and –1 if a<0,
     //Sqrt(a) is square root of a,
     //Sum is a summation operation,
     //ExpMovAvg is Exponential Moving Average over Smoothing Period bars.
     //Path1 is simply the hypotenuse of the big triangle formed by the current 
     //Close and Period bars ago Close. Path2 is the sum of hypotenuses of small 
     //triangles formed by each Close point.
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$  
    double Path1, Path2 = 0, a;
    Path1 = MathSqrt(MathPow(Close[i] - Close[i+Perriod],2)+MathPow(Perriod,2)); 
    for (int k=1; k<=Perriod; k++)
    Path2 += MathSqrt(MathPow(Close[i+k-1]-Close[i+k],2)+1);
     
    a = Close[i] - Close[i+Perriod];
    if (a>0) FractalEfficiencyTmp[i] = +1*Path1 / Path2 * 100.0;
    else     FractalEfficiencyTmp[i] = -1*Path1 / Path2 * 100.0;   
    }
    
    for(i=limit; i>=0; i--)
    {
     FractalEfficiency[i] = iMAOnArray(FractalEfficiencyTmp,0,period_MA,0,2,i);
     Line_Zero[i]=0;
    }
//----
   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 ---