Spread Visual

Author: Copyright 2018, SEM
0 Views
0 Downloads
0 Favorites
Spread Visual
ÿþ//+------------------------------------------------------------------+

//|                                                Spread Visual.mq5 |

//|                   Copyright 2009-2017, MetaQuotes Software Corp. |

//|                                              http://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, SEM"

#property link      "http://www.mql5.com"

#property version "1.00"



#property indicator_chart_window

//#property indicator_separate_window

#property indicator_buffers 2

#property indicator_plots   1

//---- plot ColorBars

#property indicator_label1  "spread"

#property indicator_type1  DRAW_HISTOGRAM2

#property indicator_color1    clrBlack

#property indicator_width1 5

//--- indicator buffers

double ExtOpenBuffer[];

double ExtHighBuffer[];

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int OnInit()

  {

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

   SetIndexBuffer(0,ExtOpenBuffer,INDICATOR_DATA);

   ArraySetAsSeries(ExtOpenBuffer,true);

   SetIndexBuffer(1,ExtHighBuffer,INDICATOR_DATA);

   ArraySetAsSeries(ExtHighBuffer,true);

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

   int w=rates_total-prev_calculated;

   ArraySetAsSeries(open,true);

   ArraySetAsSeries(close,true);

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

   ArraySetAsSeries(spread,true);

   for(int i=0; (i<=w && i<rates_total-6 && !IsStopped()); i++)

     {

      if(open[i]>close[i])

        {

         ExtOpenBuffer[i]=low[i];

         ExtHighBuffer[i]=low[i]-_alfa(_Digits,spread[i]);

        }

      else

        {

         ExtOpenBuffer[i]=high[i];

         ExtHighBuffer[i]=high[i]+_alfa(_Digits,spread[i]);

        };

     };



   return(rates_total);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

double _alfa(int y,double price)

  {

   double _temp=1.0;

   for(int i=0; i<y; i++)

     {

      _temp=_temp/10;

     };

   price=price*_temp;

   return(price);

  }

//+------------------------------------------------------------------+

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