11评论

3收藏

chart overlay mtf

avatar admin | 2021 人阅读 | 11 人评论 | 2018-01-18

XAUUSDM30.png

  1. //+------------------------------------------------------------------+
  2. //|                                       MTF_OverLay Chart(yyr).mq4 Ver.1.10 |
  3. //|                                      Copyright?2006-2007 S.B.T. |
  4. //|                                     http://sufx.core.t3-ism.net/ |
  5. //+------------------- DO NOT REMOVE THIS HEADER --------------------+
  6. //|  This script is free to use/distribute/modify and re-distribute. |
  7. //|                                  (Limited to noncommercial use.)
  8. //|  Thank you for S.B.T.,yangelong redited from your OverLay Chart.mq4        
  9. //+------------------------------------------------------------------+

  10. //Indicator Properties
  11. #property copyright "Copyright?2006 S.B.T."
  12. #property link      "http://sufx.core.t3-ism.net/"
  13. #property indicator_chart_window
  14. #property indicator_buffers 4


  15. //Indicator Parameters
  16. extern string SubSymbol = "EURUSD";
  17. extern int    Timeframe=60;
  18. extern color BullBarColor = MediumSeaGreen;
  19. extern color BearBarColor = Orange;
  20. //extern color GridColor = Black;
  21. extern bool Mirroring = false;

  22. //Global Variables
  23. string Prefix; //Indicator Prefix
  24. int Grid = 10; //Grid Lines
  25. int SnapPips = 10;  //Snap Pips For Grid Lines


  26. //Indicator Buffers
  27. double ExtMapBuffer1[];
  28. double ExtMapBuffer2[];
  29. double ExtMapBuffer3[];
  30. double ExtMapBuffer4[];



  31. //+------------------------------------------------------------------+
  32. //| Custom indicator initialization function                         |
  33. //+------------------------------------------------------------------+
  34. int init() {

  35.    //Initialize Indexes
  36.    Prefix = "OverLayChart" + SubSymbol;

  37.    IndicatorShortName( "OverLay Chart( " + SubSymbol + " )" );

  38.    SetIndexBuffer( 0, ExtMapBuffer1 );
  39.    SetIndexBuffer( 1, ExtMapBuffer2 );
  40.    SetIndexBuffer( 2, ExtMapBuffer3 );
  41.    SetIndexBuffer( 3, ExtMapBuffer4 );

  42.    SetIndexStyle( 0, DRAW_HISTOGRAM, DRAW_LINE, 1, BullBarColor );
  43.    SetIndexStyle( 1, DRAW_HISTOGRAM, DRAW_LINE, 1, BearBarColor );
  44.    SetIndexStyle ( 2, DRAW_HISTOGRAM, DRAW_LINE, 2, BullBarColor );
  45.    SetIndexStyle( 3, DRAW_HISTOGRAM, DRAW_LINE, 2, BearBarColor );

  46.    SetIndexEmptyValue( 0, 0.0 );
  47.    SetIndexEmptyValue( 1, 0.0 );
  48.    SetIndexEmptyValue( 2, 0.0 );
  49.    SetIndexEmptyValue( 3, 0.0 );


  50.    return( 0 );
  51. }



  52. //+------------------------------------------------------------------+
  53. //| Custom indicator deinitialization function                       |
  54. //+------------------------------------------------------------------+
  55. int deinit() {
  56.    int _i;
  57.    
  58.    

  59.    //Delete Objects
  60.         ObjectDelete( Prefix + "Status" );
  61.         ObjectDelete( Prefix + "Copyright" );

  62.         for ( _i = 1; _i <= Grid ; _i ++ ) {
  63.            ObjectDelete( Prefix + "Grid" + _i );
  64.            ObjectDelete( Prefix + "Price" + _i );
  65.    }


  66.    return( 0 );
  67. }



  68. //+------------------------------------------------------------------+
  69. //| Custom indicator iteration function                              |
  70. //+------------------------------------------------------------------+
  71. int start() {
  72.    int _BarsCount;
  73.    double _CurRangeHigh, _CurRangeLow, _CurRangeCenter;
  74.    double _SubRangeHigh, _SubRangeLow, _SubRangeCenter;
  75.    double _SubPoint, _SubDigit;
  76.    double _SubOpen, _SubHigh, _SubLow, _SubClose;
  77.    double _PipsRatio;
  78.    double _GridPips, _GridPrice;
  79.    int _i;



  80.    //Initialize Buffers
  81.         RefreshRates();

  82.    ArrayInitialize( ExtMapBuffer1, 0.0 );
  83.    ArrayInitialize( ExtMapBuffer2, 0.0 );
  84.    ArrayInitialize( ExtMapBuffer3, 0.0 );
  85.    ArrayInitialize( ExtMapBuffer4, 0.0 );


  86.    //Calculate Visible Bars
  87.    _BarsCount = BarsPerWindow() + 1;
  88.    int _FirstBar = FirstVisibleBar();
  89.    int _LastBar = _FirstBar - _BarsCount + 1;
  90.    if ( _LastBar < 0 ) {
  91.       _LastBar = 0;
  92.       _BarsCount = _FirstBar + 1;
  93.    }


  94.    //Calculate Chart Ratio
  95.    _CurRangeHigh = High[Highest(NULL, 0, MODE_HIGH, _BarsCount, _LastBar)];
  96.    _CurRangeLow = Low[Lowest(NULL, 0, MODE_LOW, _BarsCount, _LastBar)];
  97.    _CurRangeCenter = ( _CurRangeHigh + _CurRangeLow ) / 2;

  98.    if ( Mirroring ) {
  99.       _SubRangeHigh = iLow( SubSymbol, Timeframe, Lowest( SubSymbol, Timeframe, MODE_LOW, _BarsCount, _LastBar ) );
  100.       _SubRangeLow = iHigh( SubSymbol, Timeframe, Highest( SubSymbol, Timeframe, MODE_HIGH, _BarsCount, _LastBar ) );
  101.    } else {
  102.       _SubRangeHigh = iHigh( SubSymbol, Timeframe, Highest( SubSymbol, Timeframe, MODE_HIGH, _BarsCount, _LastBar ) );
  103.       _SubRangeLow = iLow( SubSymbol, Timeframe, Lowest( SubSymbol, Timeframe, MODE_LOW, _BarsCount, _LastBar ) );
  104.    }

  105.    _SubRangeCenter = ( _SubRangeHigh + _SubRangeLow ) / 2;
  106.    _SubPoint = MarketInfo( SubSymbol, MODE_POINT );
  107.    _SubDigit = MarketInfo( SubSymbol, MODE_DIGITS );

  108.    _PipsRatio = ( _CurRangeHigh - _CurRangeLow )  / ( _SubRangeHigh - _SubRangeLow );

  109.    _GridPips = ( _SubRangeHigh - _SubRangeLow ) / Grid;
  110.    _GridPips = MathRound( ( _SubRangeHigh - _SubRangeLow ) / Grid / ( _SubPoint * SnapPips ) ) * ( _SubPoint * SnapPips );


  111.    //Draw Candlesticks
  112.         for ( _i = _LastBar; _i < _LastBar + _BarsCount; _i ++ ) {
  113.       _SubOpen = iOpen( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
  114.       _SubHigh = iHigh( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
  115.       _SubLow = iLow( SubSymbol, Timeframe, _i ) - _SubRangeCenter;
  116.       _SubClose = iClose( SubSymbol, Timeframe, _i ) - _SubRangeCenter;

  117.       if ( Mirroring ) {
  118.          if ( _SubOpen < _SubClose ) {
  119.             ExtMapBuffer2[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
  120.             ExtMapBuffer1[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
  121.          } else {
  122.             ExtMapBuffer2[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
  123.             ExtMapBuffer1[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
  124.          }

  125.          ExtMapBuffer4[_i] = _CurRangeCenter + _SubClose * _PipsRatio;
  126.          ExtMapBuffer3[_i] = _CurRangeCenter + _SubOpen * _PipsRatio;
  127.       } else {
  128.          if ( _SubOpen < _SubClose ) {
  129.             ExtMapBuffer1[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
  130.             ExtMapBuffer2[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
  131.          } else {
  132.             ExtMapBuffer1[_i] = _CurRangeCenter + _SubLow * _PipsRatio;
  133.             ExtMapBuffer2[_i] = _CurRangeCenter + _SubHigh * _PipsRatio;
  134.          }
  135.          ExtMapBuffer3[_i] = _CurRangeCenter + _SubClose * _PipsRatio;
  136.          ExtMapBuffer4[_i] = _CurRangeCenter + _SubOpen * _PipsRatio;
  137.       }
  138.    }

  139. /*
  140.    //Draw Objects
  141.    ObjectCreate( Prefix + "Copyright", OBJ_LABEL, 0, 0, 0 );
  142.         ObjectSet( Prefix + "Copyright", OBJPROP_COLOR, GridColor );
  143.    ObjectSet( Prefix + "Copyright", OBJPROP_CORNER, 3 );
  144.    ObjectSet( Prefix + "Copyright", OBJPROP_XDISTANCE, 4 );
  145.    ObjectSet( Prefix + "Copyright", OBJPROP_YDISTANCE, 4 );
  146.    ObjectSetText( Prefix + "Copyright", "OverLay Chart by S.B.T.", 8 );

  147.    ObjectCreate( Prefix + "Status", OBJ_LABEL, 0, 0, 0 );
  148.         ObjectSet( Prefix + "Status", OBJPROP_COLOR, GridColor );
  149.    ObjectSet( Prefix + "Status", OBJPROP_CORNER, 0 );
  150.    ObjectSet( Prefix + "Status", OBJPROP_XDISTANCE, 4 );
  151.    ObjectSet( Prefix + "Status", OBJPROP_YDISTANCE, 16 );
  152.    ObjectSetText( Prefix + "Status",
  153.                   SubSymbol + " O = " + DoubleToStr( iOpen( SubSymbol, 0, _LastBar ), _SubDigit ) +
  154.                   ", H = " + DoubleToStr( iHigh( SubSymbol, 0, _LastBar ), _SubDigit ) +
  155.                   ", L = " + DoubleToStr( iLow( SubSymbol, 0, _LastBar ), _SubDigit ) +
  156.                   ", C = " + DoubleToStr( iClose( SubSymbol, 0, _LastBar ), _SubDigit ),
  157.                   8 );

  158.         for ( _i = 1; _i <= Grid ; _i ++ ) {
  159.       _GridPrice = MathRound( _SubRangeCenter / ( _SubPoint * SnapPips ) ) * ( _SubPoint * SnapPips );
  160.       _GridPrice = ( ( _GridPrice + _GridPips / 2 ) + _GridPips * ( Grid / 2 - 1 ) ) - ( _GridPips * ( _i - 1 ) );

  161.                 ObjectCreate( Prefix + "Grid" + _i, OBJ_TREND, 0, 0, 0 );
  162.       ObjectSet( Prefix + "Grid" + _i, OBJPROP_TIME1, Time[_FirstBar] );
  163.       ObjectSet( Prefix + "Grid" + _i, OBJPROP_PRICE1, _CurRangeCenter + ( _GridPrice - _SubRangeCenter ) * _PipsRatio );
  164.       ObjectSet( Prefix + "Grid" + _i, OBJPROP_TIME2, Time[_LastBar] );
  165.       ObjectSet( Prefix + "Grid" + _i, OBJPROP_PRICE2, _CurRangeCenter + ( _GridPrice - _SubRangeCenter ) * _PipsRatio );
  166.                 ObjectSet( Prefix + "Grid" + _i, OBJPROP_COLOR, GridColor );
  167.                 ObjectSet( Prefix + "Grid" + _i, OBJPROP_STYLE, STYLE_DOT );
  168.                 ObjectSet( Prefix + "Grid" + _i, OBJPROP_WIDTH, 1 );
  169.                 ObjectSet( Prefix + "Grid" + _i, OBJPROP_RAY, true );

  170.                 ObjectCreate( Prefix + "Price" + _i, OBJ_TEXT, 0, 0, 0 );
  171.       ObjectSet( Prefix + "Price" + _i, OBJPROP_TIME1, Time[_FirstBar - _BarsCount / 10] );
  172.       ObjectSet( Prefix + "Price" + _i, OBJPROP_PRICE1, _CurRangeCenter + ( _GridPrice - _SubRangeCenter ) * _PipsRatio );
  173.                 ObjectSet( Prefix + "Price" + _i, OBJPROP_COLOR, GridColor );
  174.       ObjectSetText( Prefix + "Price" + _i, DoubleToStr( _GridPrice, _SubDigit ), 8 );
  175.    }

  176. */
  177.    return( 0 );
  178. }
  179. //+------------------------------------------------------------------+

复制代码


Chart-overLay MTF.mq4
""
还没有人打赏,支持一下

评论|共 11 个

晴天雨天

发表于 2018-9-25 21:23:19 | 显示全部楼层

感谢分享

LEE517

发表于 2019-6-9 22:51:05 来自手机 | 显示全部楼层

快快快快快快快快

qplpthpsh

发表于 2020-6-9 16:54:36 | 显示全部楼层

好好 学习了 确实不错

抓耗子

发表于 2020-6-26 13:42:47 | 显示全部楼层

帮帮顶顶!!

1000美金

发表于 2020-7-14 19:32:27 | 显示全部楼层

谢谢楼主分享

hhuqmxsh71

发表于 2020-7-23 19:50:34 | 显示全部楼层

谢谢楼主分享

ubuntu

发表于 2020-7-24 11:23:32 | 显示全部楼层

谢谢楼主分享

qq9876553

发表于 2020-8-28 16:37:29 | 显示全部楼层

帮你顶下哈!!

小水滴

发表于 2020-11-20 11:43:32 | 显示全部楼层

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则