#-Pirson_v1

Author: Copyright � 2007, klot
#-Pirson_v1
Indicators Used
Moving average indicatorStandard Deviation indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
#-Pirson_v1
//+------------------------------------------------------------------+
//|                                                     #DT-Pirsonq4 |
//|                                           Copyright © 2007, klot |
//|                                                     klot@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, klot"
#property link      "klot@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Aqua
#property indicator_level1 0.0
extern    int N=20;
//---- indicator buffers
double Pirson[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers mapping
   SetIndexBuffer(0,Pirson);
   SetIndexEmptyValue(0,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   double X,Y,Sx,Sy;
   double sum=0.0;
//----
     for( int shift=Bars-N-1; shift>=0; shift--) 
     {
      X=iMA(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,shift);
      Y=iMA(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,shift+1);
      //----
      sum=0;
        for( int i=N-1; i>=0; i--) 
        {
         sum+=(Close[shift+i]-X)*(Close[shift+i+1]-Y);
        }
      //---
      Sx=iStdDev(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,shift);
      Sy=iStdDev(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,shift+1);
      //---
      Pirson[shift]=sum/((N-1)*Sx*Sy);
     }
//----
   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 ---