Author: Copyright � 2010, Murad Ismayilov
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
WiOver
// Èíäèêàòîð: WiOver
// Âåðñèÿ: 0.2
// Äàòà ïîñëåäíåé ìîäèôèêàöèè: 15.11.2010
// Àâòîð: Ìóðàä Èñìàéëîâ
// Ïî÷òà: wmlab@hotmail.com
//
// 0.2 (15.11.2010) - äîáàâëåíû ëèíèè âõîäà ëèìèòíûìè îðäåðàìè


#property copyright "Copyright © 2010, Murad Ismayilov"
#property link      "http://www.wmlab.org/"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

extern int WiOverPeriod=14;

double WiBBuffer[];
double WiSBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {
   string shortname;

   IndicatorBuffers(2);
   SetIndexBuffer(0,WiBBuffer);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,WiSBuffer);
   SetIndexStyle(1,DRAW_LINE);

   if(WiOverPeriod<=0)
     {
      WiOverPeriod=14;
     }

   shortname="WiOver("+WiOverPeriod+")";
   IndicatorShortName(shortname);
   SetIndexLabel(0,shortname+" SellLimit");
   SetIndexLabel(1,shortname+" BuyLimit");

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,k,counted_bars=IndicatorCounted();
   double sum,mul,abs;
   int count;
//   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+WiOverPeriod;

   i=limit;
   while(i>=0)
     {
      sum=0.0;
      count=0;
      k=i+WiOverPeriod-1;
      while(k>=i)
        {
         mul=0.0;

         if((High[k+1]>Low[k]) && (Low[k]>Low[k+1]))
           {
            mul=((High[k+1]-Low[k])/(High[k+1]-Low[k+1]));
           }

         if((High[k+1]>High[k]) && (High[k]>Low[k+1]))
           {
            mul=((High[k+1]-High[k])/(High[k+1]-Low[k+1]));
           }

         sum+=mul;
         count++;
         k--;
        }

      // Print ("sum = ", sum, " count = ", count); 
      abs=(sum *(High[i]-Low[i]))/count;
      //Print (i, " ", WiOverBuffer[i]);
      WiBBuffer[i] = High[i] - abs;
      WiSBuffer[i] = Low[i] + abs;
      i--;
     }

   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 ---