Author: Fedor Igumnov
Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Asymmetry
//+------------------------------------------------------------------+
//|                                                     Asymmetry.mq4 |
//|                                                    Fedor Igumnov |
//|                                           igumnovfedor@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Fedor Igumnov"
#property link      "igumnovfedor@yandex.ru"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
extern int AsPeriod=30;
//--- buffers
double Asymmetry[];




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  string short_name;
  
//---- indicators
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Asymmetry);
   short_name="Asym("+AsPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,AsPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int   counted_bars=IndicatorCounted();
   int i,k;
   double M,D,MD,stdDev=0;
   double r1;
//---
   if (Bars<AsPeriod)
   return (0);  
   counted_bars=IndicatorCounted();
   M=0;
   D=0;
   MD=0;
   r1=0;
   stdDev=0;
   k=Bars-AsPeriod-1;
   if(counted_bars>=AsPeriod) 
   k=Bars-counted_bars-1;
   while(k>=0)
   {
   
   for (i=AsPeriod;i>=0;i--)
   {
  M+=iRSI(Symbol(),0,AsPeriod,PRICE_CLOSE,k+i);  
  
   }
   M=M/(AsPeriod+2);  
   for (i=AsPeriod;i>=0;i--)
   {
   D+=(iRSI(Symbol(),0,AsPeriod,PRICE_CLOSE,k+i)-M)*(iRSI(Symbol(),0,AsPeriod,PRICE_CLOSE,k+i)-M); 
 
   }
   D=D/(AsPeriod+2);
   stdDev=MathSqrt(D);
   for (i=AsPeriod;i>=0;i--)
   {
   MD+=(iRSI(Symbol(),0,AsPeriod,PRICE_CLOSE,k+i)-D)*(iRSI(Symbol(),0,AsPeriod,PRICE_CLOSE,k+i)-D);  
      
   } 
   MD=MD/(AsPeriod+2);   
   Asymmetry[k]=MathAbs(MD/(D*stdDev*10000));
   k--;
     }
 
//----
   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 ---