7评论

1收藏

SweetSpotsGOLD

avatar 360 | 1842 人阅读 | 7 人评论 | 2018-03-08

EURGBPH1.png

  1. //+------------------------------------------------------------------+
  2. //|                                                   SweetSpots.mq4 |
  3. //|                                                                  |
  4. //|                                                                  |
  5. //+------------------------------------------------------------------+
  6. //| SweetSpotsGOLD_TRO_MODIFIED_VERSION                              |
  7. //| MODIFIED BY AVERY T. HORTON, JR. AKA THERUMPLEDONE@GMAIL.COM     |
  8. //| I am NOT the ORIGINAL author
  9. //  and I am not claiming authorship of this indicator.
  10. //  All I did was modify it. I hope you find my modifications useful.|
  11. //|                                                                  |
  12. //+------------------------------------------------------------------+


  13. #property copyright "Copyright Shimodax"
  14. #property link      "http://www.strategybuilderfx.com"

  15. #property indicator_chart_window

  16. /* Introduction:

  17.    This indicator shows lines at sweet spots (50 and 100
  18.    pips levels). It is recommended to turn off the grid.
  19.    
  20.    Enjoy!

  21.    Markus
  22. */

  23. extern bool   TURN_OFF    = false ;
  24. extern bool AutoAdjust  = true;
  25. extern bool Show_Labels = true ;
  26. extern int  ShiftLabel =  5 ;

  27. extern int NumLinesAboveBelow  = 100;
  28. extern int SweetSpotMainLevels = 100;

  29. extern color LineColorMain= Yellow;
  30. extern int LineStyleMain= STYLE_DOT;

  31. extern bool ShowSubLevels= true;
  32. extern int sublevels= 10;

  33. extern color LineColorSub= Yellow;
  34. extern int LineStyleSub= STYLE_DOT;


  35. string symbol, tChartPeriod,  tShortName, pricelabel ;  
  36. int    digits, period, digits2, mult = 1  ;
  37. double point ;

  38. //+------------------------------------------------------------------+
  39. int init()
  40. {
  41.    period       =  Period() ;   
  42.    symbol       =  Symbol() ;
  43.    digits       =  Digits ;   
  44.    point        =  Point ;

  45.    if(digits == 5 || digits == 3) { mult = 10; digits = digits - 1 ; point = point * 10 ; }   
  46.    
  47.    if(AutoAdjust && period > PERIOD_H1 && period < PERIOD_MN1) { mult = mult * 10; }
  48.    if(AutoAdjust && period == PERIOD_MN1) { mult = mult * 100; }
  49.    
  50. SweetSpotMainLevels = SweetSpotMainLevels * mult;

  51. sublevels           = sublevels * mult;
  52.    
  53.    deinit();
  54.    
  55.    return(0);
  56. }

  57. //+------------------------------------------------------------------+
  58. int deinit()
  59. {
  60.    int obj_total= ObjectsTotal();
  61.    
  62.    for (int i= obj_total; i>=0; i--) {
  63.       string name= ObjectName(i);
  64.    
  65.       if (StringSubstr(name,0,11)=="[SweetSpot]")
  66.          ObjectDelete(name);
  67.    }
  68.    TRO();
  69.    return(0);
  70. }
  71.    
  72. //+------------------------------------------------------------------+
  73. int start()
  74. {
  75.    if( TURN_OFF ) { return(0) ; }

  76.    static datetime timelastupdate= 0;
  77.    static datetime lasttimeframe= 0;
  78.    
  79.    
  80.    // no need to update these buggers too often   
  81.    if (CurTime()-timelastupdate < 600 && Period()==lasttimeframe)
  82.       return (0);
  83.    
  84.    deinit();  // delete all previous lines
  85.       
  86.    int i, ssp1, style, ssp, thickness; //sublevels= 50;
  87.    double ds1;
  88.    color linecolor;
  89.    
  90.    if (!ShowSubLevels)
  91.       sublevels*= 2;
  92.    
  93.    ssp1= Bid / Point;
  94.    ssp1= ssp1 - ssp1%sublevels;

  95.    for (i= -NumLinesAboveBelow; i<NumLinesAboveBelow; i++)
  96.    {
  97.    
  98.       ssp= ssp1+(i*sublevels);
  99.       
  100.       if (ssp%SweetSpotMainLevels==0)
  101.       {
  102.          style= LineStyleMain;
  103.          linecolor= LineColorMain;
  104.       }
  105.       else
  106.       {
  107.          style= LineStyleSub;
  108.          linecolor= LineColorSub;
  109.       }
  110.       
  111.       thickness= 1;
  112.       
  113.       if (ssp%(SweetSpotMainLevels*10)==0)
  114.       {
  115.          thickness= 2;      
  116.       }

  117.       if (ssp%(SweetSpotMainLevels*100)==0)
  118.       {
  119.          thickness= 3;      
  120.       }
  121.       
  122.       ds1= ssp*Point;
  123.       SetLevel(DoubleToStr(ds1,Digits), ds1,  linecolor, style, thickness, Time[10]);
  124.    }

  125.    return(0);
  126. }


  127. //+------------------------------------------------------------------+
  128. //| Helper                                                           |
  129. //+------------------------------------------------------------------+
  130. void SetLevel(string text, double level, color col1, int linestyle, int thickness, datetime startofday)
  131. {

  132.    string linename= "[SweetSpot] " + text + " Line" + pricelabel;

  133.    // create or move the horizontal line   
  134.    if (ObjectFind(linename) != 0) {
  135.       ObjectCreate(linename, OBJ_TREND, 0, Time[0], level, Time[1], level, 0, 0);

  136. //      ObjectCreate(linename, OBJ_HLINE, 0, 0, level);
  137.       
  138.       ObjectSet(linename, OBJPROP_STYLE, linestyle);
  139.       ObjectSet(linename, OBJPROP_COLOR, col1);
  140.       ObjectSet(linename, OBJPROP_WIDTH, thickness);

  141.       ObjectSet(linename, OBJPROP_RAY, true);      
  142.       ObjectSet(linename, OBJPROP_BACK, True);
  143.    }
  144.    else {
  145.       ObjectMove(linename, 0, Time[0], level);
  146.    }
  147.    

  148.    if(Show_Labels)
  149.    {         
  150.    
  151.    
  152.       string Obj0002 = linename+"linelbl" ;
  153.       
  154.       ObjectDelete(Obj0002);
  155.       
  156.       if(ObjectFind(Obj0002) != 0)
  157.       {
  158.           ObjectCreate(Obj0002,OBJ_ARROW,0,Time[0],level);
  159.           ObjectSet(Obj0002,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
  160.           ObjectSet(Obj0002,OBJPROP_COLOR,col1);  
  161.       }
  162.       else
  163.       {
  164.          ObjectMove(Obj0002,0,Time[0],level);
  165.       }

  166.                  
  167.    } // if     
  168.    
  169. }     


  170. //+------------------------------------------------------------------+  
  171. void TRO()
  172. {   
  173.    
  174.    string tObjName03    = "TROTAG"  ;  
  175.    ObjectCreate(tObjName03, OBJ_LABEL, 0, 0, 0);//HiLow LABEL
  176.    ObjectSetText(tObjName03, CharToStr(78) , 12 ,  "Wingdings",  DimGray );
  177.    ObjectSet(tObjName03, OBJPROP_CORNER, 3);
  178.    ObjectSet(tObjName03, OBJPROP_XDISTANCE, 5 );
  179.    ObjectSet(tObjName03, OBJPROP_YDISTANCE, 5 );  
  180. }
  181. //+------------------------------------------------------------------+
  182.   
复制代码


SweetSpotsGOLD_TRO_MODIFIED_VERSION.mq4
""
还没有人打赏,支持一下

评论|共 7 个

游游

发表于 2020-4-20 19:22:19 | 显示全部楼层

支持一下:lol

enob冯存抒

发表于 2020-6-27 22:51:32 | 显示全部楼层

我是个凑数的。。。

feiziteng

发表于 2020-7-1 15:09:21 | 显示全部楼层

LZ真是人才

andy076318

发表于 2020-9-1 16:41:47 | 显示全部楼层

谢谢楼主分享

不知道叫什么

发表于 2021-7-11 13:04:59 | 显示全部楼层

顶下

元本奎广

发表于 2021-7-27 23:28:29 | 显示全部楼层

konase

发表于 2021-8-1 23:08:45 | 显示全部楼层

顶下

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

EA之家评论守则