UOSA





//+------------------------------------------------------------------+
//|                                          Ultimate Oscillator.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.ru/"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Pink

#property indicator_levelcolor LightPink
#property indicator_maximum 125
#property indicator_minimum -25
//---- input parameters
extern int fastperiod = 7;
extern int middleperiod = 14;
extern int slowperiod = 28;
extern int fastK = 3;
extern int middleK = 3;
extern int slowK = 3;
//---- buffers
double UOBuffer[];
double BPBuffer[];
double divider;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   string name;
   name="UOS(" + fastperiod + ", " + middleperiod + ", " + slowperiod + ")";
   IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, UOBuffer);
   SetIndexDrawBegin(0, slowperiod);
   SetIndexBuffer(1, BPBuffer);
   IndicatorShortName(name);
   IndicatorDigits(1);
   divider = fastK + middleK + slowK;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
//----
   int i, limit, limit2;
   double TL, RawUO;
   if(counted_bars == 0) 
     {
       limit = Bars - 2;
       limit2 = Bars - slowperiod;
     }
   if(counted_bars > 0) 
     {
       limit = Bars - counted_bars;
       limit2 = limit;
     }
   for(i = limit; i >= 0; i--)
     {
       TL = MathMin(Low[i], Close[i+1]);
       BPBuffer[i] = Close[i] - TL;
     }
   for(i = limit2; i >= 0; i--)
     {
       RawUO = fastK*iMAOnArray(BPBuffer, 0, fastperiod, 0, MODE_SMA, i) / 
               iATR(NULL, 0, fastperiod, i) +
               middleK*iMAOnArray(BPBuffer, 0, middleperiod, 0, MODE_SMA, i) /
               iATR(NULL, 0, middleperiod, i) +
               slowK*iMAOnArray(BPBuffer, 0, slowperiod, 0, MODE_SMA, i) / 
               iATR(NULL, 0, slowperiod, i);
       UOBuffer[i] = RawUO / divider*100;
     }     
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Moving average indicator
Indicator of the average true range


Custom Indicators Used:

Order Management characteristics:

Other Features: