- //+------------------------------------------------------------------+
- //| MTF_OverLay Chart(yyr).mq4 Ver.1.10 |
- //| Copyright?2006-2007 S.B.T. |
- //| http://sufx.core.t3-ism.net/ |
- //+------------------- DO NOT REMOVE THIS HEADER --------------------+
- //| This script is free to use/distribute/modify and re-distribute. |
- //| (Limited to noncommercial use.)
- //| Thank you for S.B.T.,yangelong redited from your OverLay Chart.mq4
- //+------------------------------------------------------------------+
- //Indicator Properties
- #property copyright "Copyright?2006 S.B.T."
- #property link "http://sufx.core.t3-ism.net/"
- #property indicator_chart_window
- #property indicator_buffers 4
- //Indicator Parameters
- extern string SubSymbol = "EURUSD";
- extern int Timeframe=60;
- extern color BullBarColor = MediumSeaGreen;
- extern color BearBarColor = Orange;
- //extern color GridColor = Black;
- extern bool Mirroring = false;
- //Global Variables
- string Prefix; //Indicator Prefix
- int Grid = 10; //Grid Lines
- int SnapPips = 10; //Snap Pips For Grid Lines
- //Indicator Buffers
- double ExtMapBuffer1[];
- double ExtMapBuffer2[];
- double ExtMapBuffer3[];
- double ExtMapBuffer4[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init() {
- //Initialize Indexes
- Prefix = "OverLayChart" + SubSymbol;
- IndicatorShortName( "OverLay Chart( " + SubSymbol + " )" );
- SetIndexBuffer( 0, ExtMapBuffer1 );
- SetIndexBuffer( 1, ExtMapBuffer2 );
- SetIndexBuffer( 2, ExtMapBuffer3 );
- SetIndexBuffer( 3, ExtMapBuffer4 );
- SetIndexStyle( 0, DRAW_HISTOGRAM, DRAW_LINE, 1, BullBarColor );
- SetIndexStyle( 1, DRAW_HISTOGRAM, DRAW_LINE, 1, BearBarColor );
- SetIndexStyle ( 2, DRAW_HISTOGRAM, DRAW_LINE, 2, BullBarColor );
- SetIndexStyle( 3, DRAW_HISTOGRAM, DRAW_LINE, 2, BearBarColor );
- SetIndexEmptyValue( 0, 0.0 );
- SetIndexEmptyValue( 1, 0.0 );
- SetIndexEmptyValue( 2, 0.0 );
- SetIndexEmptyValue( 3, 0.0 );
- return( 0 );
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit() {
- int _i;
-
-
- //Delete Objects
- ObjectDelete( Prefix + "Status" );
- ObjectDelete( Prefix + "Copyright" );
- for ( _i = 1; _i <= Grid ; _i ++ ) {
- ObjectDelete( Prefix + "Grid" + _i );
- ObjectDelete( Prefix + "Price" + _i );
- }
- return( 0 );
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start() {
- int _BarsCount;
- double _CurRangeHigh, _CurRangeLow, _CurRangeCenter;
- double _SubRangeHigh, _SubRangeLow, _SubRangeCenter;
- double _SubPoint, _SubDigit;
- double _SubOpen, _SubHigh, _SubLow, _SubClose;
- double _PipsRatio;
- double _GridPips, _GridPrice;
- int _i;
- //Initialize Buffers
- RefreshRates();
- ArrayInitialize( ExtMapBuffer1, 0.0 );
- ArrayInitialize( ExtMapBuffer2, 0.0 );
- ArrayInitialize( ExtMapBuffer3, 0.0 );
- ArrayInitialize( ExtMapBuffer4, 0.0 );
- //Calculate Visible Bars
- _BarsCount = BarsPerWindow() + 1;
- int _FirstBar = FirstVisibleBar();
- int _LastBar = _FirstBar - _BarsCount + 1;
- if ( _LastBar < 0 ) {
- _LastBar = 0;
- _BarsCount = _FirstBar + 1;
- }
- //Calculate Chart Ratio
- _CurRangeHigh = High[Highest(NULL, 0, MODE_HIGH, _BarsCount, _LastBar)];
- _CurRangeLow = Low[Lowest(NULL, 0, MODE_LOW, _BarsCount, _LastBar)];
- _CurRangeCenter = ( _CurRangeHigh + _CurRangeLow ) / 2;
- if ( Mirroring ) {
- _SubRangeHigh = iLow( SubSymbol, Timeframe, Lowest( SubSymbol, Timeframe, MODE_LOW, _BarsCount, _LastBar ) );
- _SubRangeLow = iHigh( SubSymbol, Timeframe, Highest( SubSymbol, Timeframe, MODE_HIGH, _BarsCount, _LastBar ) );
- } else {
- _SubRangeHigh = iHigh( SubSymbol, Timeframe, Highest( SubSymbol, Timeframe, MODE_HIGH, _BarsCount, _LastBar ) );
- _SubRangeLow = iLow( SubSymbol, Timeframe, Lowest( SubSymbol, Timeframe, MODE_LOW, _BarsCount, _LastBar ) );
- }
- _SubRangeCenter = ( _SubRangeHigh + _SubRangeLow ) / 2;
- _SubPoint = MarketInfo( SubSymbol, MODE_POINT );
- _SubDigit = MarketInfo( SubSymbol, MODE_DIGITS );
- _PipsRatio = ( _CurRangeHigh - _CurRangeLow ) / ( _SubRangeHigh - _SubRangeLow );
- _GridPips = ( _SubRangeHigh - _SubRangeLow ) / Grid;
- _GridPips = MathRound( ( _SubRangeHigh - _SubRangeLow ) / Grid / ( _SubPoint * SnapPips ) ) * ( _SubPoint * SnapPips );
- //Draw Candlesticks
- for ( _i = _LastBar; _i < _LastBar + _BarsCount; _i ++ ) {
- _SubOpen = iOpen( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
- _SubHigh = iHigh( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
- _SubLow = iLow( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
- _SubClose = iClose( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
- if ( Mirroring ) {
- if ( _SubOpen < _SubClose ) {
- ExtMapBuffer2[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
- ExtMapBuffer1[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
- } else {
- ExtMapBuffer2[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
- ExtMapBuffer1[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
- }
- ExtMapBuffer4[_i] = _CurRangeCenter + _SubClose * _PipsRatio;
- ExtMapBuffer3[_i] = _CurRangeCenter + _SubOpen * _PipsRatio;
- } else {
- if ( _SubOpen < _SubClose ) {
- ExtMapBuffer1[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
- ExtMapBuffer2[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
- } else {
- ExtMapBuffer1[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
- ExtMapBuffer2[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
- }
- ExtMapBuffer3[_i] = _CurRangeCenter + _SubClose * _PipsRatio;
- ExtMapBuffer4[_i] = _CurRangeCenter + _SubOpen * _PipsRatio;
- }
- }
- return( 0 );
- }
- //+------------------------------------------------------------------+
|