pivot detector osillator

Author: copyleft mladen
pivot detector osillator
Indicators Used
Relative strength indexMoving average indicator
0 Views
0 Downloads
0 Favorites
pivot detector osillator
//+------------------------------------------------------------------+
//|                                        pivot detector oscillator |
//|                                                                  |
//| developed by Giorgos Siligardos,                                 |
//| published in TASC, September, 2009                               |
//+------------------------------------------------------------------+
#property copyright "copyleft mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers    1
#property indicator_color1     DeepSkyBlue
#property indicator_width1     2
#property indicator_level1     0
#property indicator_level2     100
#property indicator_levelcolor DimGray


//
//
//
//
//

extern int pdoPrice          = PRICE_CLOSE;
extern int pdoRsiLength      = 14;
extern int pdoAverageLength  = 200;
extern int pdoUpTrendEntry   = 35;
extern int pdoUpTrendExit    = 85;
extern int pdoDownTrendEntry = 20;
extern int pdoDownTrendExit  = 70;

double pdo[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,pdo);
   IndicatorShortName("pdo ("+pdoRsiLength+","+pdoAverageLength+","+pdoUpTrendEntry+","+pdoUpTrendExit+","+pdoDownTrendEntry+","+pdoDownTrendExit+")");
   return(0);
}
int deinit() { return(0); }
int start()
{
   int i,limit;
   int counted_bars=IndicatorCounted();
   if (counted_bars>0) counted_bars--;
            limit=MathMin(Bars-counted_bars,Bars-1);
 
   //
   //
   //
   //
   //
 
   for(i=limit; i>=0; i--)
   {
      double rsi   = iRSI(NULL,0,pdoRsiLength,pdoPrice,i);
      double avg   = iMA(NULL,0,pdoAverageLength,0,MODE_SMA,pdoPrice,i);
      double price = iMA(NULL,0,1               ,0,MODE_SMA,pdoPrice,i);
      
      if (price>avg)
            pdo[i] = 100*(rsi-pdoUpTrendEntry)/(pdoUpTrendExit-pdoUpTrendEntry);
      else  pdo[i] = 100*(rsi-pdoDownTrendEntry)/(pdoDownTrendExit-pdoDownTrendEntry);
   }                  
   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 ---