Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
SRm
//SRm

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 MediumSeaGreen
#property indicator_color2 OrangeRed
//---- input parameters
 extern int period = 14;
 extern double k_std = 1.0;   // Êîýôôèöèåíò ìíîæèòåëü ñòàíäàðòíîãî îòêëîíåíèÿ Std
 extern double k  = 1.0;      // Êîýôôèöèåíò ìíîæèòåëü ñðåäíåãî ìèíèìàëüíîãî êîëåáàíèÿ AV
//---- buffers
double Buffer[];
double Buffer1[];    
double m[10000];
double o[10000];
datetime t;

//-----------------------------------
int init()
  {
//---- indicators
//---- 1 additional buffer used for counting.
     IndicatorBuffers( 2 );
     IndicatorDigits( Digits );
//---- indicator line
     SetIndexStyle( 0, DRAW_LINE );
     SetIndexBuffer( 0, Buffer );
     SetIndexStyle( 1, DRAW_LINE );
     SetIndexBuffer( 1, Buffer1 );         
     SetIndexLabel( 0, "GSV_UP ("+period+")" );
     SetIndexLabel( 1, "GSV_DOWN ("+period+")" );         
//----
   return(0);
  }
  
//-------------------------------

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-=2;  
//----
    if ( t == Time[0] ) return(0);

     t = Time[0];
     int i, x, p;
     double LastHigh, LastLow, w;
     p = Period( );
     for ( i = limit; i >= 0; i-- )
     { 
       if ( High[i+1] > LastHigh )
       { 
        LastHigh = High[i+1];
       }
       //----
       if ( Low[i+1] < LastLow )
       { 
        LastLow = Low[i+1];
       }   
       
         int b = TimeDayOfWeek( Time[i+1] );
         if ( TimeDay( Time[i] ) != TimeDay( Time[i+1] ) && ( ( b > 0 && b < 6 ) || p > PERIOD_D1 ) )
         { 
           x++;
           o[x] = Open[i];
           
           m[x] = LastHigh - o[x - 1];
           
              if ( LastHigh - o[x - 1] > o[x - 1] - LastLow )
              {
               m[x] = o[x - 1] - LastLow;
              }
                 LastLow = 100000; 
                 LastHigh = 0;
             
                if ( x > period )
                {
                  w = 0;
                  for ( int y = 0; y < period; y++ )
                  {  
                   w = w + m[x-y];    
                  }   
                           
                    double v = w / period;
                    w = 0;

                    for ( y = 0; y < period; y++ )
                    {  
                     w = w + ( m[x-y] - v ) * ( m[x-y] - v );    
                    }
                  
                       double e = w / period; 
                       double std = k * v + k_std * MathPow( e, 0.5 );
                       double gsv1 = o[x] + std;
                       double gsv2 = o[x] - std;          
                } 
          } 
           
          if ( x > period )
          {
           Buffer[i] = gsv1;
           Buffer1[i] = gsv2;
          }
        
       }
     
   
//----
       
       
       
   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 ---