Spread Analyzer

Author: Copyright � 2009, Obaidah & GodfreyH
Spread Analyzer
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Spread Analyzer
//+------------------------------------------------------------------+
//|                        Spread Analyzer.mq4                       |
//|               Copyright © 2009, Obaidah & GodfreyH               |
//|                         clefts@hotmail.com                       |
//|                         godfreyh@gmail.com                       |
//|                                                                  |
//|   This Indicator works as assistant to Volume Spread Analyzer    |
//|Volume and Spread in order to identify weakness and strength spots|
//|                                                                  |
//|                             WARNING!                             |
//| Signs provided by this technical indicator cannot be considered  |
//| As entry signals unless there's at least 1 more indicator shows  |
//|   The same signal, This indicator is well-designed to help you   |
//|         Deciding your entery points and you exit points.         |
//|  Please notice that this indicator uses the average for the last |
//|             13 bars, so, ANY signal in the first 13 bars         |
//|                  Of any season open is NOT liable.               |
//|                                                                  |
//| This indicator is to remain open source for further developments |
//|   The programmers are NOT responsible about any losing trades    |
//| Taken based on this indicator, Do learn about volume and spread  |
//|         Analysis before you use this indicator seriuosly         |
//|                                                                  |
//| In order to know how does this indicator provides signal and how |
//|      Strong such a signal is please read Master The Markets      |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2009, Obaidah & GodfreyH"
#property link      "clefts@hotmail.com"
#property link      "godfreyh@gmail.com"

extern int Lb=8;

double Spread[],Spread1[],SpreadAverage[], Change[],ChangeAve[],ClosePart[],BarType[], PrevVol[];

#property indicator_chart_window
#property  indicator_buffers 7

// Custom indicator initialization function

int init()
{

   IndicatorBuffers(7);
   
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexStyle(4,DRAW_NONE);
   SetIndexStyle(5,DRAW_NONE);
   SetIndexStyle(6,DRAW_NONE);
   
   SetIndexDrawBegin(0,Lb);
   SetIndexDrawBegin(1,Lb);
   SetIndexDrawBegin(2,Lb);
   SetIndexDrawBegin(3,Lb);
   SetIndexDrawBegin(4,Lb);
   SetIndexDrawBegin(5,Lb);
   SetIndexDrawBegin(6,Lb);
   
   SetIndexBuffer(0,Spread);
   SetIndexBuffer(1,Spread1);
   SetIndexBuffer(2,SpreadAverage);
   SetIndexBuffer(3,ChangeAve);
   SetIndexBuffer(4,PrevVol);
   SetIndexBuffer(5,BarType);
   SetIndexBuffer(6,ClosePart);
   
   IndicatorDigits(0);
   
   IndicatorShortName("Volume And Spread Analyzer");
   
   return(0);
}

// Custom indicator deinitialization function

int deinit()
{
   return(0);
}

// Custom indicator iteration function

int start()
{
   int countedBars = IndicatorCounted();
   int limit;
   if(countedBars > 0)
       countedBars--;
   limit=Bars-countedBars;
   int i,j;
   for(i=0; i<limit; i++) {
      Spread[i]=High[i] - Low[i];
      SpreadAverage[i]=0;
      for(j=i+Lb;j>i;j--)
         SpreadAverage[i]+=iHigh(Symbol(),0,j) - iLow(Symbol(),0,j);
         
      SpreadAverage[i]/=Lb;
      Spread1[i]=0;
      PrevVol[i]=Volume[i+2];
      if(Spread[i] > 3*SpreadAverage[i])
         Spread1[i]=4;
      else {
      if(Spread[i] > 1.9*SpreadAverage[i])
         Spread1[i]=3;
      else {
         if(Spread[i] > 1.6*SpreadAverage[i])
            Spread1[i]=2;
         else {
            if(Spread[i] > 1.3*SpreadAverage[i])
               Spread1[i]=1;
            else {
               if(Spread[i] < 0.60*SpreadAverage[i])
                  Spread1[i]=-1;
            }
         }
      }
      }
      ChangeAve[i]=0;
      for(j=i+Lb;j>i;j--) {
         if(iOpen(Symbol(),0,i) < iClose(Symbol(),0,i)) // Check if its a bullish bar.
            ChangeAve[i]+=iClose(Symbol(),0,j) - iOpen(Symbol(),0,j);
         else
            ChangeAve[i]+=iOpen(Symbol(),0,j) - iClose(Symbol(),0,j);
      }
      ChangeAve[i]/=Lb;
      if(iOpen(Symbol(),0,i) < iClose(Symbol(),0,i)) {
         Change[i]=iClose(Symbol(),0,i) - iOpen(Symbol(),0,i);
         BarType[i]=1.0; // One if its an up-bar
      }
      else {
         if(iOpen(Symbol(),0,i) > iClose(Symbol(),0,i)) {
            Change[i]=iOpen(Symbol(),0,i) - iClose(Symbol(),0,i);
            BarType[i]=2.0; // 2 If its a down-bar
         }
      }
      ClosePart[i]=0;
      if(BarType[i] == 1) {
      // 2 means highs, 1 means middle, 0 means lows (in case of up-bars)
         if(Close[i] >= High[i]-Spread[i]*0.30)
            ClosePart[i]=2;
         else
            if(Close[i] > High[i]-Spread[i]*0.60)
               ClosePart[i]=1;
      }
      else {
         if(BarType[i] == 2) {
         //2 means lows, 1 means middle, 0 means highs (in case of down-bars)
            if(Close[i] < High[i]-Spread[i]*0.60)
               ClosePart[i]=2;
            else
               if(Close[i] < High[i]-Spread[i]*0.30)
                  ClosePart[i]=1;
         }
      }
   }
   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 ---