交易危机

 找回密码
 快捷注册(禁q号)

QQ登录

只需一步,快速开始

搜索
广告位
查看: 17000|回复: 30
打印 上一主题 下一主题

[其他] 生命哥-BOB系统

[复制链接]

29

主题

1223

积分

1

精华

初级操盘手

金钱
1223 美元
权重
14
跳转到指定楼层
楼主
发表于 2014-3-10 16:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
生命哥-BOB系统
图示:
日走势代码:

  1. //+------------------------------------------------------------------+
  2. //|                                                     Daily  Pivot |
  3. //|                                    Copyright ?2006, Profitrader |
  4. //|                                    Coded/Verified by Profitrader |
  5. //|                                  Modified by Nanningbob May 2012 |
  6. //+------------------------------------------------------------------+
  7. //
  8. // Modified for 10.2 by nanningbob April 2012
  9. // Modified by candletiger@forexfactory April 2012
  10. // Version ct4
  11. //+------------------------------------------------------------------+
  12. //| Supported features/additions/modifications:                      |
  13. //| * paints pivot lines for *every* week or month in history        |
  14. //| * paints 3 S/L levels                                            |
  15. //| * with a second instance, mid lines can be added                 |
  16. //| * for the current week/month, an extension line is drawn         |
  17. //| * added text paramters to the options                            |
  18. //| * added colors to the options                                    |
  19. //|                                                                  |
  20. //+------------------------------------------------------------------+
  21. #property copyright "Copyright ?2006, Profitrader."
  22. #property link      "profitrader@inbox.ru"
  23. #property indicator_chart_window
  24. #property indicator_buffers 7
  25. extern string wmtext1                = "pivot timeframe";
  26. extern string wmtext2                = "Daily=1, monthly=2";
  27. extern int    pivot_timeframe        = 1;
  28. extern string mltext1                = "first instance supports main pivot levels";
  29. extern string mltext2                = "to add mid pivot levels, load this";
  30. extern string mltext3                = "indicator a second time and set below true";
  31. extern bool   addMidLevels           = false;
  32. extern string bartext                = "set to number of bars to use";
  33. extern int    BarsToProcess          = 2000;
  34. extern string linetext               = "below line/text style is configured";
  35. extern string text_font              = "Arial";
  36. extern int    text_size              = 7;
  37. extern color  text_color             = Red;
  38. extern string tstext1                = "text_shift shifts the line text by N spaces";
  39. extern int    text_shift             = 30;
  40. extern int    line_thickness_main    = 3;
  41. extern int    line_thickness_mid     = 1;
  42. extern color  line_color_main        = Lime;           // Black
  43. extern color  line_color_support1    = Black;      // DodgerBlue
  44. extern color  line_color_resistance1 = Black;       // OrangeRed
  45. extern color  line_color_support2    = Black;           // RoyalBlue
  46. extern color  line_color_resistance2 = Black;           // Crimson
  47. extern color  line_color_support3    = Black;           // Blue
  48. extern color  line_color_resistance3 = Black;           // Maroon
  49. //---- buffers
  50. double PBuffer[];
  51. double S1Buffer[];
  52. double R1Buffer[];
  53. double S2Buffer[];
  54. double R2Buffer[];
  55. double S3Buffer[];
  56. double R3Buffer[];
  57. //---- global variables
  58. datetime current_time;
  59. double   multiplier;
  60. double   last_high,last_low,last_close;
  61. double   P,S1,R1,S2,R2,S3,R3, MS1, MS2, MS3, MR1, MR2, MR3, dP,dS1,dR1,dS2,dR2,dS3,dR3;
  62. int      i;
  63. int      line_thickness;
  64. int      pivot_bar;
  65. int      pivot_timeframe_const;
  66. string   pregap = "";
  67. string   timeframe_prefix;
  68. string   timeframe_prefix_text;
  69. //+------------------------------------------------------------------+
  70. //| Custom indicator initialization function                         |
  71. //+------------------------------------------------------------------+
  72. int init()
  73. {
  74. /*
  75.     //Accommodate different quote sizes
  76.     double multiplier;
  77.     if(Digits == 2 || Digits == 4) multiplier = 1;
  78.     if(Digits == 3 || Digits == 5) multiplier = 10;
  79.     if(Digits == 6) multiplier = 100;   
  80. */
  81.    //Accommodate different quote sizes
  82.    if(StringFind(Symbol(),"JPY",0)<0)  multiplier = 10000;
  83.    if(StringFind(Symbol(),"JPY",0)>=0) multiplier = 100;
  84.   
  85.    SetIndexBuffer(0,PBuffer);
  86.    //SetIndexBuffer(1,S1Buffer);
  87.    //SetIndexBuffer(2,R1Buffer);
  88.    //SetIndexBuffer(3,S2Buffer);
  89.    //SetIndexBuffer(4,R2Buffer);
  90.    //SetIndexBuffer(5,S3Buffer);
  91.    //SetIndexBuffer(6,R3Buffer);
  92.    
  93.    if(addMidLevels == true) line_thickness = line_thickness_mid;
  94.    else line_thickness = line_thickness_main;
  95.    
  96.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_main);
  97.    // SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support1);
  98.    // SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance1);
  99.    // SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support2);
  100.    // SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance2);
  101.    // SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support3);
  102.    // SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance3);
  103.    if( pivot_timeframe == 1) pivot_timeframe_const = PERIOD_D1;
  104.    if( pivot_timeframe == 2) pivot_timeframe_const = PERIOD_MN1;
  105.    
  106.    if(pivot_timeframe == 1) timeframe_prefix = "Daily ";
  107.    if(pivot_timeframe == 2) timeframe_prefix = "Monthly ";
  108.    pregap="";   
  109.    for(i=0; i<text_shift;i++) pregap = pregap + " ";
  110.    if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  111.    timeframe_prefix_text = pregap + timeframe_prefix;
  112.       
  113.    SetIndexLabel(0,timeframe_prefix + "Pivot Point");
  114.    //SetIndexLabel(1,timeframe_prefix + "Support 1");
  115.   // SetIndexLabel(2,timeframe_prefix + "Resistance 1");
  116.   // SetIndexLabel(3,timeframe_prefix + "Support 2");
  117.   // SetIndexLabel(4,timeframe_prefix + "Resistance 2");
  118.   // SetIndexLabel(5,timeframe_prefix + "Support 3");
  119.   // SetIndexLabel(6,timeframe_prefix + "Resistance 3");
  120.    
  121.    //the line text objects
  122.    ObjectCreate(timeframe_prefix + "Pivot",OBJ_TEXT,0,0,0);
  123.    ObjectSetText(timeframe_prefix + "Pivot",timeframe_prefix_text + "Pivot", text_size, text_font, text_color);
  124.    //ObjectCreate(timeframe_prefix + "Res1",OBJ_TEXT,0,0,0);
  125.    //ObjectSetText(timeframe_prefix + "Res1",timeframe_prefix_text + "Res1", text_size, text_font, text_color);
  126.    //ObjectCreate(timeframe_prefix + "Sup1",OBJ_TEXT,0,0,0);
  127.    //ObjectSetText(timeframe_prefix + "Sup1",timeframe_prefix_text + "Sup1", text_size, text_font, text_color);
  128.    //ObjectCreate(timeframe_prefix + "Res2",OBJ_TEXT,0,0,0);
  129.    //ObjectSetText(timeframe_prefix + "Res2",timeframe_prefix_text + "Res2", text_size, text_font, text_color);
  130.    //ObjectCreate(timeframe_prefix + "Sup2",OBJ_TEXT,0,0,0);
  131.    //ObjectSetText(timeframe_prefix + "Sup2",timeframe_prefix_text + "Sup2", text_size, text_font, text_color);
  132.    //ObjectCreate(timeframe_prefix + "Res3",OBJ_TEXT,0,0,0);
  133.    //ObjectSetText(timeframe_prefix + "Res3",timeframe_prefix_text + "Res3", text_size, text_font, text_color);
  134.    //ObjectCreate(timeframe_prefix + "Sup3",OBJ_TEXT,0,0,0);
  135.    //ObjectSetText(timeframe_prefix + "Sup3",timeframe_prefix_text + "Sup3", text_size, text_font, text_color);
  136.    
  137.    // the current pivot lines extension
  138.    // why this? Beginning of a new week or month, the index lines are almost not visible
  139.    // to compensate, we print a dotted helper line (Trend line, not an index line) from the current bar to the end
  140. //   ObjectCreate(timeframe_prefix + "Pivot ext", OBJ_TREND,0, 0,0,0,0);
  141. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_COLOR, line_color_main);
  142. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_STYLE, STYLE_DOT);
  143. //   ObjectCreate(timeframe_prefix + "Res1 ext", OBJ_TREND,0, 0,0,0,0);
  144. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_COLOR, line_color_resistance1);
  145. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_STYLE, STYLE_DOT);
  146. //   ObjectCreate(timeframe_prefix + "Sup1 ext", OBJ_TREND,0, 0,0,0,0);
  147. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_COLOR, line_color_support1);
  148. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_STYLE, STYLE_DOT);
  149. //   ObjectCreate(timeframe_prefix + "Res2 ext", OBJ_TREND,0, 0,0,0,0);
  150. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_COLOR, line_color_resistance2);
  151. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_STYLE, STYLE_DOT);
  152. //   ObjectCreate(timeframe_prefix + "Sup2 ext", OBJ_TREND,0, 0,0,0,0);
  153. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_COLOR, line_color_support2);
  154. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_STYLE, STYLE_DOT);
  155. //   ObjectCreate(timeframe_prefix + "Res3 ext", OBJ_TREND,0, 0,0,0,0);
  156. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_COLOR, line_color_resistance3);
  157. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_STYLE, STYLE_DOT);
  158. //   ObjectCreate(timeframe_prefix + "Sup3 ext", OBJ_TREND,0, 0,0,0,0);
  159. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_COLOR, line_color_support3);
  160. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_STYLE, STYLE_DOT);
  161.       
  162.    return(0);
  163. }
  164. //+------------------------------------------------------------------+
  165. //| Custor indicator deinitialization function                       |
  166. //+------------------------------------------------------------------+
  167. int deinit()
  168.   {
  169.    ObjectDelete(timeframe_prefix + "Pivot");
  170.    ObjectDelete(timeframe_prefix + "Sup1");
  171.    ObjectDelete(timeframe_prefix + "Res1");
  172.    ObjectDelete(timeframe_prefix + "Sup2");
  173.    ObjectDelete(timeframe_prefix + "Res2");
  174.    ObjectDelete(timeframe_prefix + "Sup3");
  175.    ObjectDelete(timeframe_prefix + "Res3");
  176.    
  177.    ObjectDelete(timeframe_prefix + "Pivot ext");
  178.    ObjectDelete(timeframe_prefix + "Res1 ext");
  179.    ObjectDelete(timeframe_prefix + "Res2 ext");
  180.    ObjectDelete(timeframe_prefix + "Res3 ext");
  181.    ObjectDelete(timeframe_prefix + "Sup1 ext");
  182.    ObjectDelete(timeframe_prefix + "Sup2 ext");
  183.    ObjectDelete(timeframe_prefix + "Sup3 ext");
  184.    
  185.    return(0);
  186.   }
  187. //+------------------------------------------------------------------+
  188. //| Custom indicator iteration function                              |
  189. //+------------------------------------------------------------------+
  190. int start()
  191. {
  192.    int i,counted_bars=IndicatorCounted();
  193.    //---- check for possible errors
  194.    if(counted_bars<0) return(-1);
  195.    //---- last counted bar will be recounted
  196.    if(counted_bars>0) counted_bars--;  
  197.    int Limit=Bars-counted_bars;
  198.    
  199.    if(pivot_timeframe == 1) if(Period()>PERIOD_D1) return(-1);
  200.    if(pivot_timeframe == 2) if(Period()>PERIOD_W1) return(-1);
  201.    if(Limit>BarsToProcess) Limit=BarsToProcess;
  202.    for(i=Limit-1; i>=0; i--)
  203.    {
  204.        // looking for the current time   
  205.        current_time = Time[i];
  206.        // and seach the corresponding bar in the pivot timeframe
  207.        pivot_bar = iBarShift( NULL, pivot_timeframe_const, current_time);
  208.        // read the values of that previous week/month
  209.        last_low=iLow(NULL, pivot_timeframe_const, pivot_bar+1);
  210.        last_high=iHigh(NULL, pivot_timeframe_const, pivot_bar+1);
  211.        last_close=iClose(NULL, pivot_timeframe_const, pivot_bar+1);
  212.       
  213.        // calculate main pivot and S/R lines                    
  214.        P=(last_high+last_low+last_close)/3;
  215.        R1=(2*P)-last_low;
  216.        S1=(2*P)-last_high;
  217.        R2=P+(last_high-last_low);
  218.        S2=P-(last_high-last_low);
  219.        R3=(2*P)+(last_high-(2*last_low));
  220.        S3=(2*P)-((2*last_high)-last_low);
  221.       
  222.        // calculate mid S/R lines                    
  223.        MS3 = S3 + ((S2-S3) / 2);
  224.        MS2 = S2 + ((S1-S2) / 2);
  225.        MS1 = S1 + ((P-S1) / 2);
  226.        MR1 = P + ((R1-P) / 2);
  227.        MR2 = R1 + ((R2-R1) / 2);
  228.        MR3 = R2 + ((R3-R2) / 2);
  229.       
  230.        // copy either main or mid values to the temp display variables
  231.        if( addMidLevels == false)
  232.        {
  233.          dP=P;
  234.          dS1=S1;
  235.          dR1=R1;
  236.          dS2=S2;
  237.          dR2=R2;
  238.          dS3=S3;
  239.          dR3=R3;
  240.        }
  241.        else
  242.        {
  243.          dP=0;
  244.          dS1=MS1;
  245.          dR1=MR1;
  246.          dS2=MS2;
  247.          dR2=MR2;
  248.          dS3=MS3;
  249.          dR3=MR3;
  250.       }
  251.    
  252.        PBuffer[i]=dP;
  253.        S1Buffer[i]=dS1;
  254.        R1Buffer[i]=dR1;
  255.        S2Buffer[i]=dS2;
  256.        R2Buffer[i]=dR2;
  257.        S3Buffer[i]=dS3;
  258.        R3Buffer[i]=dR3;
  259.     } // end for i loop
  260.    
  261.     pregap = "";   
  262.     for(i=0; i<text_shift;i++) pregap = pregap + " ";
  263.     if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  264.     timeframe_prefix_text = pregap + timeframe_prefix;
  265.       
  266.     // move the text to the current bar
  267.     ObjectMove(timeframe_prefix + "Pivot",0,Time[0],dP);
  268.     ObjectSetText(timeframe_prefix + "Pivot", timeframe_prefix_text + "Pivot ("+DoubleToStr((dP-Close[0]) * multiplier, 1)+" pts)");        
  269. //    ObjectMove(timeframe_prefix + "Sup1",0,Time[0],dS1);
  270. //    ObjectSetText(timeframe_prefix + "Sup1", timeframe_prefix_text + "Sup1 ("+DoubleToStr((dS1-Close[0]) * multiplier, 1)+" pts)");   
  271. //    ObjectMove(timeframe_prefix + "Res1",0,Time[0],dR1);
  272. //    ObjectSetText(timeframe_prefix + "Res1", timeframe_prefix_text + "Res1 ("+DoubleToStr((dR1-Close[0]) * multiplier, 1)+" pts)");            
  273. //    ObjectMove(timeframe_prefix + "Sup2",0,Time[0],dS2);
  274. //    ObjectSetText(timeframe_prefix + "Sup2", timeframe_prefix_text + "Sup2 ("+DoubleToStr((dS2-Close[0]) * multiplier, 1)+" pts)");               
  275. //    ObjectMove(timeframe_prefix + "Res2",0,Time[0],dR2);
  276. //    ObjectSetText(timeframe_prefix + "Res2", timeframe_prefix_text + "Res2 ("+DoubleToStr((dR2-Close[0]) * multiplier, 1)+" pts)");                    
  277. //    ObjectMove(timeframe_prefix + "Sup3",0,Time[0],dS3);
  278. //    ObjectSetText(timeframe_prefix + "Sup3", timeframe_prefix_text + "Sup3 ("+DoubleToStr((dS3-Close[0]) * multiplier, 1)+" pts)");                        
  279. //    ObjectMove(timeframe_prefix + "Res3",0,Time[0],dR3);
  280. //    ObjectSetText(timeframe_prefix + "Res3", timeframe_prefix_text + "Res3 ("+DoubleToStr((dR3-Close[0]) * multiplier, 1)+" pts)");                           
  281.    
  282.     // move the helper extension lines to the current bar
  283.     ObjectMove(timeframe_prefix + "Pivot ext", 0, Time[1],dP);
  284.   //  ObjectMove(timeframe_prefix + "Pivot ext", 1, Time[0],dP);
  285. //   ObjectMove(timeframe_prefix + "Res1 ext", 0, Time[1],dR1);
  286. //   ObjectMove(timeframe_prefix + "Res1 ext", 1, Time[0],dR1);
  287.   //  ObjectMove(timeframe_prefix + "Res2 ext", 0, Time[1],dR2);
  288.   //  ObjectMove(timeframe_prefix + "Res2 ext", 1, Time[0],dR2);
  289. //   ObjectMove(timeframe_prefix + "Res3 ext", 0, Time[1],dR3);
  290. //   ObjectMove(timeframe_prefix + "Res3 ext", 1, Time[0],dR3);
  291. //   ObjectMove(timeframe_prefix + "Sup1 ext", 0, Time[1],dS1);
  292. //   ObjectMove(timeframe_prefix + "Sup1 ext", 1, Time[0],dS1);
  293. //   ObjectMove(timeframe_prefix + "Sup2 ext", 0, Time[1],dS2);
  294. //   ObjectMove(timeframe_prefix + "Sup2 ext", 1, Time[0],dS2);
  295. //   ObjectMove(timeframe_prefix + "Sup3 ext", 0, Time[1],dS3);
  296. //   ObjectMove(timeframe_prefix + "Sup3 ext", 1, Time[0],dS3);
  297.    
  298.     //----
  299.     return(0);
  300. }
  301. //+------------------------------------------------------------------+
复制代码

月走势代码:

  1. //+------------------------------------------------------------------+
  2. //|                                                     Weekly Pivot |
  3. //|                                    Copyright ?2006, Profitrader |
  4. //|                                    Coded/Verified by Profitrader |
  5. //|                                  Modified by Nanningbob May 2012 |
  6. //+------------------------------------------------------------------+
  7. //
  8. // Modified for 10.2 by nanningbob April 2012
  9. // Modified by candletiger@forexfactory April 2012
  10. // Version ct4
  11. //+------------------------------------------------------------------+
  12. //| Supported features/additions/modifications:                      |
  13. //| * paints pivot lines for *every* week or month in history        |
  14. //| * paints 3 S/L levels                                            |
  15. //| * with a second instance, mid lines can be added                 |
  16. //| * for the current week/month, an extension line is drawn         |
  17. //| * added text paramters to the options                            |
  18. //| * added colors to the options                                    |
  19. //|                                                                  |
  20. //+------------------------------------------------------------------+
  21. #property copyright "Copyright ?2006, Profitrader."
  22. #property link      "profitrader@inbox.ru"
  23. #property indicator_chart_window
  24. #property indicator_buffers 7
  25. extern string wmtext1                = "pivot timeframe";
  26. extern string wmtext2                = "Weekly=1, monthly=2";
  27. extern int    pivot_timeframe        = 2;
  28. extern string mltext1                = "first instance supports main pivot levels";
  29. extern string mltext2                = "to add mid pivot levels, load this";
  30. extern string mltext3                = "indicator a second time and set below true";
  31. extern bool   addMidLevels           = false;
  32. extern string bartext                = "set to number of bars to use";
  33. extern int    BarsToProcess          = 200;
  34. extern string linetext               = "below line/text style is configured";
  35. extern string text_font              = "Arial";
  36. extern int    text_size              = 7;
  37. extern color  text_color             = Red;
  38. extern string tstext1                = "text_shift shifts the line text by N spaces";
  39. extern int    text_shift             = 30;
  40. extern int    line_thickness_main    = 3;
  41. extern int    line_thickness_mid     = 1;
  42. extern color  line_color_main        = Black;           // Black
  43. extern color  line_color_support1    = AliceBlue;      // DodgerBlue
  44. extern color  line_color_resistance1 = AliceBlue;       // OrangeRed
  45. extern color  line_color_support2    = AliceBlue;           // RoyalBlue
  46. extern color  line_color_resistance2 = AliceBlue;           // Crimson
  47. extern color  line_color_support3    = AliceBlue;           // Blue
  48. extern color  line_color_resistance3 = AliceBlue;           // Maroon
  49. //---- buffers
  50. double PBuffer[];
  51. double S1Buffer[];
  52. double R1Buffer[];
  53. double S2Buffer[];
  54. double R2Buffer[];
  55. double S3Buffer[];
  56. double R3Buffer[];
  57. //---- global variables
  58. datetime current_time;
  59. double   multiplier;
  60. double   last_high,last_low,last_close;
  61. double   P,S1,R1,S2,R2,S3,R3, MS1, MS2, MS3, MR1, MR2, MR3, dP,dS1,dR1,dS2,dR2,dS3,dR3;
  62. int      i;
  63. int      line_thickness;
  64. int      pivot_bar;
  65. int      pivot_timeframe_const;
  66. string   pregap = "";
  67. string   timeframe_prefix;
  68. string   timeframe_prefix_text;
  69. //+------------------------------------------------------------------+
  70. //| Custom indicator initialization function                         |
  71. //+------------------------------------------------------------------+
  72. int init()
  73. {
  74. /*
  75.     //Accommodate different quote sizes
  76.     double multiplier;
  77.     if(Digits == 2 || Digits == 4) multiplier = 1;
  78.     if(Digits == 3 || Digits == 5) multiplier = 10;
  79.     if(Digits == 6) multiplier = 100;   
  80. */
  81.    //Accommodate different quote sizes
  82.    if(StringFind(Symbol(),"JPY",0)<0)  multiplier = 10000;
  83.    if(StringFind(Symbol(),"JPY",0)>=0) multiplier = 100;
  84.   
  85.    SetIndexBuffer(0,PBuffer);
  86.    //SetIndexBuffer(1,S1Buffer);
  87.    //SetIndexBuffer(2,R1Buffer);
  88.    //SetIndexBuffer(3,S2Buffer);
  89.    //SetIndexBuffer(4,R2Buffer);
  90.    //SetIndexBuffer(5,S3Buffer);
  91.    //SetIndexBuffer(6,R3Buffer);
  92.    
  93.    if(addMidLevels == true) line_thickness = line_thickness_mid;
  94.    else line_thickness = line_thickness_main;
  95.    
  96.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_main);
  97.    // SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support1);
  98.    // SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance1);
  99.    // SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support2);
  100.    // SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance2);
  101.    // SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support3);
  102.    // SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance3);
  103.    if( pivot_timeframe == 1) pivot_timeframe_const = PERIOD_D1;
  104.    if( pivot_timeframe == 2) pivot_timeframe_const = PERIOD_MN1;
  105.    
  106.    if(pivot_timeframe == 1) timeframe_prefix = "Weekly ";
  107.    if(pivot_timeframe == 2) timeframe_prefix = "Monthly ";
  108.    pregap="";   
  109.    for(i=0; i<text_shift;i++) pregap = pregap + " ";
  110.    if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  111.    timeframe_prefix_text = pregap + timeframe_prefix;
  112.       
  113.    SetIndexLabel(0,timeframe_prefix + "Pivot Point");
  114.    //SetIndexLabel(1,timeframe_prefix + "Support 1");
  115.   // SetIndexLabel(2,timeframe_prefix + "Resistance 1");
  116.   // SetIndexLabel(3,timeframe_prefix + "Support 2");
  117.   // SetIndexLabel(4,timeframe_prefix + "Resistance 2");
  118.   // SetIndexLabel(5,timeframe_prefix + "Support 3");
  119.   // SetIndexLabel(6,timeframe_prefix + "Resistance 3");
  120.    
  121.    //the line text objects
  122.    ObjectCreate(timeframe_prefix + "Pivot",OBJ_TEXT,0,0,0);
  123.    ObjectSetText(timeframe_prefix + "Pivot",timeframe_prefix_text + "Pivot", text_size, text_font, text_color);
  124.    //ObjectCreate(timeframe_prefix + "Res1",OBJ_TEXT,0,0,0);
  125.    //ObjectSetText(timeframe_prefix + "Res1",timeframe_prefix_text + "Res1", text_size, text_font, text_color);
  126.    //ObjectCreate(timeframe_prefix + "Sup1",OBJ_TEXT,0,0,0);
  127.    //ObjectSetText(timeframe_prefix + "Sup1",timeframe_prefix_text + "Sup1", text_size, text_font, text_color);
  128.    //ObjectCreate(timeframe_prefix + "Res2",OBJ_TEXT,0,0,0);
  129.    //ObjectSetText(timeframe_prefix + "Res2",timeframe_prefix_text + "Res2", text_size, text_font, text_color);
  130.    //ObjectCreate(timeframe_prefix + "Sup2",OBJ_TEXT,0,0,0);
  131.    //ObjectSetText(timeframe_prefix + "Sup2",timeframe_prefix_text + "Sup2", text_size, text_font, text_color);
  132.    //ObjectCreate(timeframe_prefix + "Res3",OBJ_TEXT,0,0,0);
  133.    //ObjectSetText(timeframe_prefix + "Res3",timeframe_prefix_text + "Res3", text_size, text_font, text_color);
  134.    //ObjectCreate(timeframe_prefix + "Sup3",OBJ_TEXT,0,0,0);
  135.    //ObjectSetText(timeframe_prefix + "Sup3",timeframe_prefix_text + "Sup3", text_size, text_font, text_color);
  136.    
  137.    // the current pivot lines extension
  138.    // why this? Beginning of a new week or month, the index lines are almost not visible
  139.    // to compensate, we print a dotted helper line (Trend line, not an index line) from the current bar to the end
  140. //   ObjectCreate(timeframe_prefix + "Pivot ext", OBJ_TREND,0, 0,0,0,0);
  141. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_COLOR, line_color_main);
  142. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_STYLE, STYLE_DOT);
  143. //   ObjectCreate(timeframe_prefix + "Res1 ext", OBJ_TREND,0, 0,0,0,0);
  144. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_COLOR, line_color_resistance1);
  145. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_STYLE, STYLE_DOT);
  146. //   ObjectCreate(timeframe_prefix + "Sup1 ext", OBJ_TREND,0, 0,0,0,0);
  147. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_COLOR, line_color_support1);
  148. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_STYLE, STYLE_DOT);
  149. //   ObjectCreate(timeframe_prefix + "Res2 ext", OBJ_TREND,0, 0,0,0,0);
  150. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_COLOR, line_color_resistance2);
  151. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_STYLE, STYLE_DOT);
  152. //   ObjectCreate(timeframe_prefix + "Sup2 ext", OBJ_TREND,0, 0,0,0,0);
  153. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_COLOR, line_color_support2);
  154. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_STYLE, STYLE_DOT);
  155. //   ObjectCreate(timeframe_prefix + "Res3 ext", OBJ_TREND,0, 0,0,0,0);
  156. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_COLOR, line_color_resistance3);
  157. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_STYLE, STYLE_DOT);
  158. //   ObjectCreate(timeframe_prefix + "Sup3 ext", OBJ_TREND,0, 0,0,0,0);
  159. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_COLOR, line_color_support3);
  160. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_STYLE, STYLE_DOT);
  161.       
  162.    return(0);
  163. }
  164. //+------------------------------------------------------------------+
  165. //| Custor indicator deinitialization function                       |
  166. //+------------------------------------------------------------------+
  167. int deinit()
  168.   {
  169.    ObjectDelete(timeframe_prefix + "Pivot");
  170.    ObjectDelete(timeframe_prefix + "Sup1");
  171.    ObjectDelete(timeframe_prefix + "Res1");
  172.    ObjectDelete(timeframe_prefix + "Sup2");
  173.    ObjectDelete(timeframe_prefix + "Res2");
  174.    ObjectDelete(timeframe_prefix + "Sup3");
  175.    ObjectDelete(timeframe_prefix + "Res3");
  176.    
  177.    ObjectDelete(timeframe_prefix + "Pivot ext");
  178.    ObjectDelete(timeframe_prefix + "Res1 ext");
  179.    ObjectDelete(timeframe_prefix + "Res2 ext");
  180.    ObjectDelete(timeframe_prefix + "Res3 ext");
  181.    ObjectDelete(timeframe_prefix + "Sup1 ext");
  182.    ObjectDelete(timeframe_prefix + "Sup2 ext");
  183.    ObjectDelete(timeframe_prefix + "Sup3 ext");
  184.    
  185.    return(0);
  186.   }
  187. //+------------------------------------------------------------------+
  188. //| Custom indicator iteration function                              |
  189. //+------------------------------------------------------------------+
  190. int start()
  191. {
  192.    int i,counted_bars=IndicatorCounted();
  193.    //---- check for possible errors
  194.    if(counted_bars<0) return(-1);
  195.    //---- last counted bar will be recounted
  196.    if(counted_bars>0) counted_bars--;  
  197.    int Limit=Bars-counted_bars;
  198.    
  199.    if(pivot_timeframe == 1) if(Period()>PERIOD_D1) return(-1);
  200.    if(pivot_timeframe == 2) if(Period()>PERIOD_W1) return(-1);
  201.    if(Limit>BarsToProcess) Limit=BarsToProcess;
  202.    for(i=Limit-1; i>=0; i--)
  203.    {
  204.        // looking for the current time   
  205.        current_time = Time[i];
  206.        // and seach the corresponding bar in the pivot timeframe
  207.        pivot_bar = iBarShift( NULL, pivot_timeframe_const, current_time);
  208.        // read the values of that previous week/month
  209.        last_low=iLow(NULL, pivot_timeframe_const, pivot_bar+1);
  210.        last_high=iHigh(NULL, pivot_timeframe_const, pivot_bar+1);
  211.        last_close=iClose(NULL, pivot_timeframe_const, pivot_bar+1);
  212.       
  213.        // calculate main pivot and S/R lines                    
  214.        P=(last_high+last_low+last_close)/3;
  215.        R1=(2*P)-last_low;
  216.        S1=(2*P)-last_high;
  217.        R2=P+(last_high-last_low);
  218.        S2=P-(last_high-last_low);
  219.        R3=(2*P)+(last_high-(2*last_low));
  220.        S3=(2*P)-((2*last_high)-last_low);
  221.       
  222.        // calculate mid S/R lines                    
  223.        MS3 = S3 + ((S2-S3) / 2);
  224.        MS2 = S2 + ((S1-S2) / 2);
  225.        MS1 = S1 + ((P-S1) / 2);
  226.        MR1 = P + ((R1-P) / 2);
  227.        MR2 = R1 + ((R2-R1) / 2);
  228.        MR3 = R2 + ((R3-R2) / 2);
  229.       
  230.        // copy either main or mid values to the temp display variables
  231.        if( addMidLevels == false)
  232.        {
  233.          dP=P;
  234.          dS1=S1;
  235.          dR1=R1;
  236.          dS2=S2;
  237.          dR2=R2;
  238.          dS3=S3;
  239.          dR3=R3;
  240.        }
  241.        else
  242.        {
  243.          dP=0;
  244.          dS1=MS1;
  245.          dR1=MR1;
  246.          dS2=MS2;
  247.          dR2=MR2;
  248.          dS3=MS3;
  249.          dR3=MR3;
  250.       }
  251.    
  252.        PBuffer[i]=dP;
  253.        S1Buffer[i]=dS1;
  254.        R1Buffer[i]=dR1;
  255.        S2Buffer[i]=dS2;
  256.        R2Buffer[i]=dR2;
  257.        S3Buffer[i]=dS3;
  258.        R3Buffer[i]=dR3;
  259.     } // end for i loop
  260.    
  261.     pregap = "";   
  262.     for(i=0; i<text_shift;i++) pregap = pregap + " ";
  263.     if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  264.     timeframe_prefix_text = pregap + timeframe_prefix;
  265.       
  266.     // move the text to the current bar
  267.     ObjectMove(timeframe_prefix + "Pivot",0,Time[0],dP);
  268.     ObjectSetText(timeframe_prefix + "Pivot", timeframe_prefix_text + "Pivot ("+DoubleToStr((dP-Close[0]) * multiplier, 1)+" pts)");        
  269. //    ObjectMove(timeframe_prefix + "Sup1",0,Time[0],dS1);
  270. //    ObjectSetText(timeframe_prefix + "Sup1", timeframe_prefix_text + "Sup1 ("+DoubleToStr((dS1-Close[0]) * multiplier, 1)+" pts)");   
  271. //    ObjectMove(timeframe_prefix + "Res1",0,Time[0],dR1);
  272. //    ObjectSetText(timeframe_prefix + "Res1", timeframe_prefix_text + "Res1 ("+DoubleToStr((dR1-Close[0]) * multiplier, 1)+" pts)");            
  273. //    ObjectMove(timeframe_prefix + "Sup2",0,Time[0],dS2);
  274. //    ObjectSetText(timeframe_prefix + "Sup2", timeframe_prefix_text + "Sup2 ("+DoubleToStr((dS2-Close[0]) * multiplier, 1)+" pts)");               
  275. //    ObjectMove(timeframe_prefix + "Res2",0,Time[0],dR2);
  276. //    ObjectSetText(timeframe_prefix + "Res2", timeframe_prefix_text + "Res2 ("+DoubleToStr((dR2-Close[0]) * multiplier, 1)+" pts)");                    
  277. //    ObjectMove(timeframe_prefix + "Sup3",0,Time[0],dS3);
  278. //    ObjectSetText(timeframe_prefix + "Sup3", timeframe_prefix_text + "Sup3 ("+DoubleToStr((dS3-Close[0]) * multiplier, 1)+" pts)");                        
  279. //    ObjectMove(timeframe_prefix + "Res3",0,Time[0],dR3);
  280. //    ObjectSetText(timeframe_prefix + "Res3", timeframe_prefix_text + "Res3 ("+DoubleToStr((dR3-Close[0]) * multiplier, 1)+" pts)");                           
  281.    
  282.     // move the helper extension lines to the current bar
  283.     ObjectMove(timeframe_prefix + "Pivot ext", 0, Time[1],dP);
  284.   //  ObjectMove(timeframe_prefix + "Pivot ext", 1, Time[0],dP);
  285. //   ObjectMove(timeframe_prefix + "Res1 ext", 0, Time[1],dR1);
  286. //   ObjectMove(timeframe_prefix + "Res1 ext", 1, Time[0],dR1);
  287.   //  ObjectMove(timeframe_prefix + "Res2 ext", 0, Time[1],dR2);
  288.   //  ObjectMove(timeframe_prefix + "Res2 ext", 1, Time[0],dR2);
  289. //   ObjectMove(timeframe_prefix + "Res3 ext", 0, Time[1],dR3);
  290. //   ObjectMove(timeframe_prefix + "Res3 ext", 1, Time[0],dR3);
  291. //   ObjectMove(timeframe_prefix + "Sup1 ext", 0, Time[1],dS1);
  292. //   ObjectMove(timeframe_prefix + "Sup1 ext", 1, Time[0],dS1);
  293. //   ObjectMove(timeframe_prefix + "Sup2 ext", 0, Time[1],dS2);
  294. //   ObjectMove(timeframe_prefix + "Sup2 ext", 1, Time[0],dS2);
  295. //   ObjectMove(timeframe_prefix + "Sup3 ext", 0, Time[1],dS3);
  296. //   ObjectMove(timeframe_prefix + "Sup3 ext", 1, Time[0],dS3);
  297.    
  298.     //----
  299.     return(0);
  300. }
  301. //+------------------------------------------------------------------+
复制代码

周走势代码:

  1. //+------------------------------------------------------------------+
  2. //|                                                     Weekly Pivot |
  3. //|                                    Copyright ?2006, Profitrader |
  4. //|                                    Coded/Verified by Profitrader |
  5. //|                                  Modified by Nanningbob May 2012 |
  6. //+------------------------------------------------------------------+
  7. //
  8. // Modified for 10.2 by nanningbob April 2012
  9. // Modified by candletiger@forexfactory April 2012
  10. // Version ct4
  11. //+------------------------------------------------------------------+
  12. //| Supported features/additions/modifications:                      |
  13. //| * paints pivot lines for *every* week or month in history        |
  14. //| * paints 3 S/L levels                                            |
  15. //| * with a second instance, mid lines can be added                 |
  16. //| * for the current week/month, an extension line is drawn         |
  17. //| * added text paramters to the options                            |
  18. //| * added colors to the options                                    |
  19. //|                                                                  |
  20. //+------------------------------------------------------------------+
  21. #property copyright "Copyright ?2006, Profitrader."
  22. #property link      "profitrader@inbox.ru"
  23. #property indicator_chart_window
  24. #property indicator_buffers 7
  25. extern string wmtext1                = "pivot timeframe";
  26. extern string wmtext2                = "Weekly=1, monthly=2";
  27. extern int    pivot_timeframe        = 1;
  28. extern string mltext1                = "first instance supports main pivot levels";
  29. extern string mltext2                = "to add mid pivot levels, load this";
  30. extern string mltext3                = "indicator a second time and set below true";
  31. extern bool   addMidLevels           = false;
  32. extern string bartext                = "set to number of bars to use";
  33. extern int    BarsToProcess          = 2000;
  34. extern string linetext               = "below line/text style is configured";
  35. extern string text_font              = "Arial";
  36. extern int    text_size              = 7;
  37. extern color  text_color             = Red;
  38. extern string tstext1                = "text_shift shifts the line text by N spaces";
  39. extern int    text_shift             = 30;
  40. extern int    line_thickness_main    = 3;
  41. extern int    line_thickness_mid     = 1;
  42. extern color  line_color_main        = Gold;           // Black
  43. extern color  line_color_support1    = Black;      // DodgerBlue
  44. extern color  line_color_resistance1 = Black;       // OrangeRed
  45. extern color  line_color_support2    = Black;           // RoyalBlue
  46. extern color  line_color_resistance2 = Black;           // Crimson
  47. extern color  line_color_support3    = Black;           // Blue
  48. extern color  line_color_resistance3 = Black;           // Maroon
  49. //---- buffers
  50. double PBuffer[];
  51. double S1Buffer[];
  52. double R1Buffer[];
  53. double S2Buffer[];
  54. double R2Buffer[];
  55. double S3Buffer[];
  56. double R3Buffer[];
  57. //---- global variables
  58. datetime current_time;
  59. double   multiplier;
  60. double   last_high,last_low,last_close;
  61. double   P,S1,R1,S2,R2,S3,R3, MS1, MS2, MS3, MR1, MR2, MR3, dP,dS1,dR1,dS2,dR2,dS3,dR3;
  62. int      i;
  63. int      line_thickness;
  64. int      pivot_bar;
  65. int      pivot_timeframe_const;
  66. string   pregap = "";
  67. string   timeframe_prefix;
  68. string   timeframe_prefix_text;
  69. //+------------------------------------------------------------------+
  70. //| Custom indicator initialization function                         |
  71. //+------------------------------------------------------------------+
  72. int init()
  73. {
  74. /*
  75.     //Accommodate different quote sizes
  76.     double multiplier;
  77.     if(Digits == 2 || Digits == 4) multiplier = 1;
  78.     if(Digits == 3 || Digits == 5) multiplier = 10;
  79.     if(Digits == 6) multiplier = 100;   
  80. */
  81.    //Accommodate different quote sizes
  82.    if(StringFind(Symbol(),"JPY",0)<0)  multiplier = 10000;
  83.    if(StringFind(Symbol(),"JPY",0)>=0) multiplier = 100;
  84.   
  85.    SetIndexBuffer(0,PBuffer);
  86.    //SetIndexBuffer(1,S1Buffer);
  87.    //SetIndexBuffer(2,R1Buffer);
  88.    //SetIndexBuffer(3,S2Buffer);
  89.    //SetIndexBuffer(4,R2Buffer);
  90.    //SetIndexBuffer(5,S3Buffer);
  91.    //SetIndexBuffer(6,R3Buffer);
  92.    
  93.    if(addMidLevels == true) line_thickness = line_thickness_mid;
  94.    else line_thickness = line_thickness_main;
  95.    
  96.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3, line_color_main);
  97.    //SetIndexStyle(1,DRAW_LINE,STYLE_DOT,line_thickness, line_color_support1);
  98.    //SetIndexStyle(2,DRAW_LINE,STYLE_DOT,line_thickness, line_color_resistance1);
  99.    //SetIndexStyle(3,DRAW_LINE,STYLE_DOT,line_thickness, line_color_support2);
  100.    //SetIndexStyle(4,DRAW_LINE,STYLE_DOT,line_thickness, line_color_resistance2);
  101.    // SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_support3);
  102.    // SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,line_thickness, line_color_resistance3);
  103.    if( pivot_timeframe == 1) pivot_timeframe_const = PERIOD_W1;
  104.    if( pivot_timeframe == 2) pivot_timeframe_const = PERIOD_MN1;
  105.    
  106.    if(pivot_timeframe == 1) timeframe_prefix = "Weekly ";
  107.    if(pivot_timeframe == 2) timeframe_prefix = "Monthly ";
  108.    pregap="";   
  109.    for(i=0; i<text_shift;i++) pregap = pregap + " ";
  110.    if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  111.    timeframe_prefix_text = pregap + timeframe_prefix;
  112.       
  113.    SetIndexLabel(0,timeframe_prefix + "Pivot Point");
  114.    //SetIndexLabel(1,timeframe_prefix + "Support 1");
  115.    //SetIndexLabel(2,timeframe_prefix + "Resistance 1");
  116.   // SetIndexLabel(3,timeframe_prefix + "Support 2");
  117.   // SetIndexLabel(4,timeframe_prefix + "Resistance 2");
  118.   // SetIndexLabel(5,timeframe_prefix + "Support 3");
  119.   // SetIndexLabel(6,timeframe_prefix + "Resistance 3");
  120.    
  121.    //the line text objects
  122.    ObjectCreate(timeframe_prefix + "Pivot",OBJ_TEXT,0,0,0);
  123.    ObjectSetText(timeframe_prefix + "Pivot",timeframe_prefix_text + "Pivot", text_size, text_font, text_color);
  124.    //ObjectCreate(timeframe_prefix + "Res1",OBJ_TEXT,0,0,0);
  125.    //ObjectSetText(timeframe_prefix + "Res1",timeframe_prefix_text + "Res1", text_size, text_font, text_color);
  126.    //ObjectCreate(timeframe_prefix + "Sup1",OBJ_TEXT,0,0,0);
  127.    //ObjectSetText(timeframe_prefix + "Sup1",timeframe_prefix_text + "Sup1", text_size, text_font, text_color);
  128.    //ObjectCreate(timeframe_prefix + "Res2",OBJ_TEXT,0,0,0);
  129.    //ObjectSetText(timeframe_prefix + "Res2",timeframe_prefix_text + "Res2", text_size, text_font, text_color);
  130.    //ObjectCreate(timeframe_prefix + "Sup2",OBJ_TEXT,0,0,0);
  131.    //ObjectSetText(timeframe_prefix + "Sup2",timeframe_prefix_text + "Sup2", text_size, text_font, text_color);
  132.    //ObjectCreate(timeframe_prefix + "Res3",OBJ_TEXT,0,0,0);
  133.    //ObjectSetText(timeframe_prefix + "Res3",timeframe_prefix_text + "Res3", text_size, text_font, text_color);
  134.    //ObjectCreate(timeframe_prefix + "Sup3",OBJ_TEXT,0,0,0);
  135.    //ObjectSetText(timeframe_prefix + "Sup3",timeframe_prefix_text + "Sup3", text_size, text_font, text_color);
  136.    
  137.    // the current pivot lines extension
  138.    // why this? Beginning of a new week or month, the index lines are almost not visible
  139.    // to compensate, we print a dotted helper line (Trend line, not an index line) from the current bar to the end
  140. //   ObjectCreate(timeframe_prefix + "Pivot ext", OBJ_TREND,0, 0,0,0,0);
  141. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_COLOR, line_color_main);
  142. //   ObjectSet(timeframe_prefix + "Pivot ext", OBJPROP_STYLE, STYLE_DOT);
  143. //   ObjectCreate(timeframe_prefix + "Res1 ext", OBJ_TREND,0, 0,0,0,0);
  144. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_COLOR, line_color_resistance1);
  145. //   ObjectSet(timeframe_prefix + "Res1 ext", OBJPROP_STYLE, STYLE_DOT);
  146. //   ObjectCreate(timeframe_prefix + "Sup1 ext", OBJ_TREND,0, 0,0,0,0);
  147. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_COLOR, line_color_support1);
  148. //   ObjectSet(timeframe_prefix + "Sup1 ext", OBJPROP_STYLE, STYLE_DOT);
  149. //   ObjectCreate(timeframe_prefix + "Res2 ext", OBJ_TREND,0, 0,0,0,0);
  150. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_COLOR, line_color_resistance2);
  151. //   ObjectSet(timeframe_prefix + "Res2 ext", OBJPROP_STYLE, STYLE_DOT);
  152. //   ObjectCreate(timeframe_prefix + "Sup2 ext", OBJ_TREND,0, 0,0,0,0);
  153. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_COLOR, line_color_support2);
  154. //   ObjectSet(timeframe_prefix + "Sup2 ext", OBJPROP_STYLE, STYLE_DOT);
  155. //   ObjectCreate(timeframe_prefix + "Res3 ext", OBJ_TREND,0, 0,0,0,0);
  156. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_COLOR, line_color_resistance3);
  157. //   ObjectSet(timeframe_prefix + "Res3 ext", OBJPROP_STYLE, STYLE_DOT);
  158. //   ObjectCreate(timeframe_prefix + "Sup3 ext", OBJ_TREND,0, 0,0,0,0);
  159. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_COLOR, line_color_support3);
  160. //   ObjectSet(timeframe_prefix + "Sup3 ext", OBJPROP_STYLE, STYLE_DOT);
  161.       
  162.    return(0);
  163. }
  164. //+------------------------------------------------------------------+
  165. //| Custor indicator deinitialization function                       |
  166. //+------------------------------------------------------------------+
  167. int deinit()
  168.   {
  169.    ObjectDelete(timeframe_prefix + "Pivot");
  170.    ObjectDelete(timeframe_prefix + "Sup1");
  171.    ObjectDelete(timeframe_prefix + "Res1");
  172.    ObjectDelete(timeframe_prefix + "Sup2");
  173.    ObjectDelete(timeframe_prefix + "Res2");
  174.    ObjectDelete(timeframe_prefix + "Sup3");
  175.    ObjectDelete(timeframe_prefix + "Res3");
  176.    
  177.    ObjectDelete(timeframe_prefix + "Pivot ext");
  178.    ObjectDelete(timeframe_prefix + "Res1 ext");
  179.    ObjectDelete(timeframe_prefix + "Res2 ext");
  180.    ObjectDelete(timeframe_prefix + "Res3 ext");
  181.    ObjectDelete(timeframe_prefix + "Sup1 ext");
  182.    ObjectDelete(timeframe_prefix + "Sup2 ext");
  183.    ObjectDelete(timeframe_prefix + "Sup3 ext");
  184.    
  185.    return(0);
  186.   }
  187. //+------------------------------------------------------------------+
  188. //| Custom indicator iteration function                              |
  189. //+------------------------------------------------------------------+
  190. int start()
  191. {
  192.    int i,counted_bars=IndicatorCounted();
  193.    //---- check for possible errors
  194.    if(counted_bars<0) return(-1);
  195.    //---- last counted bar will be recounted
  196.    if(counted_bars>0) counted_bars--;  
  197.    int Limit=Bars-counted_bars;
  198.    
  199.    if(pivot_timeframe == 1) if(Period()>PERIOD_D1) return(-1);
  200.    if(pivot_timeframe == 2) if(Period()>PERIOD_W1) return(-1);
  201.    if(Limit>BarsToProcess) Limit=BarsToProcess;
  202.    for(i=Limit-1; i>=0; i--)
  203.    {
  204.        // looking for the current time   
  205.        current_time = Time[i];
  206.        // and seach the corresponding bar in the pivot timeframe
  207.        pivot_bar = iBarShift( NULL, pivot_timeframe_const, current_time);
  208.        // read the values of that previous week/month
  209.        last_low=iLow(NULL, pivot_timeframe_const, pivot_bar+1);
  210.        last_high=iHigh(NULL, pivot_timeframe_const, pivot_bar+1);
  211.        last_close=iClose(NULL, pivot_timeframe_const, pivot_bar+1);
  212.       
  213.        // calculate main pivot and S/R lines                    
  214.        P=(last_high+last_low+last_close)/3;
  215.        R1=(2*P)-last_low;
  216.        S1=(2*P)-last_high;
  217.        R2=P+(last_high-last_low);
  218.        S2=P-(last_high-last_low);
  219.        R3=(2*P)+(last_high-(2*last_low));
  220.        S3=(2*P)-((2*last_high)-last_low);
  221.       
  222.        // calculate mid S/R lines                    
  223.        MS3 = S3 + ((S2-S3) / 2);
  224.        MS2 = S2 + ((S1-S2) / 2);
  225.        MS1 = S1 + ((P-S1) / 2);
  226.        MR1 = P + ((R1-P) / 2);
  227.        MR2 = R1 + ((R2-R1) / 2);
  228.        MR3 = R2 + ((R3-R2) / 2);
  229.       
  230.        // copy either main or mid values to the temp display variables
  231.        if( addMidLevels == false)
  232.        {
  233.          dP=P;
  234.          dS1=S1;
  235.          dR1=R1;
  236.          dS2=S2;
  237.          dR2=R2;
  238.          dS3=S3;
  239.          dR3=R3;
  240.        }
  241.        else
  242.        {
  243.          dP=0;
  244.          dS1=MS1;
  245.          dR1=MR1;
  246.          dS2=MS2;
  247.          dR2=MR2;
  248.          dS3=MS3;
  249.          dR3=MR3;
  250.       }
  251.    
  252.        PBuffer[i]=dP;
  253.        S1Buffer[i]=dS1;
  254.        R1Buffer[i]=dR1;
  255.        S2Buffer[i]=dS2;
  256.        R2Buffer[i]=dR2;
  257.        S3Buffer[i]=dS3;
  258.        R3Buffer[i]=dR3;
  259.     } // end for i loop
  260.    
  261.     pregap = "";   
  262.     for(i=0; i<text_shift;i++) pregap = pregap + " ";
  263.     if(addMidLevels == true) timeframe_prefix = timeframe_prefix + "Mid ";
  264.     timeframe_prefix_text = pregap + timeframe_prefix;
  265.       
  266.     // move the text to the current bar
  267.     ObjectMove(timeframe_prefix + "Pivot",0,Time[0],dP);
  268.     ObjectSetText(timeframe_prefix + "Pivot", timeframe_prefix_text + "Pivot ("+DoubleToStr((dP-Close[0]) * multiplier, 1)+" pts)");        
  269.     ObjectMove(timeframe_prefix + "Sup1",0,Time[0],dS1);
  270.     ObjectSetText(timeframe_prefix + "Sup1", timeframe_prefix_text + "Sup1 ("+DoubleToStr((dS1-Close[0]) * multiplier, 1)+" pts)");   
  271.     ObjectMove(timeframe_prefix + "Res1",0,Time[0],dR1);
  272.     ObjectSetText(timeframe_prefix + "Res1", timeframe_prefix_text + "Res1 ("+DoubleToStr((dR1-Close[0]) * multiplier, 1)+" pts)");            
  273.     ObjectMove(timeframe_prefix + "Sup2",0,Time[0],dS2);
  274.     ObjectSetText(timeframe_prefix + "Sup2", timeframe_prefix_text + "Sup2 ("+DoubleToStr((dS2-Close[0]) * multiplier, 1)+" pts)");               
  275.     ObjectMove(timeframe_prefix + "Res2",0,Time[0],dR2);
  276.     ObjectSetText(timeframe_prefix + "Res2", timeframe_prefix_text + "Res2 ("+DoubleToStr((dR2-Close[0]) * multiplier, 1)+" pts)");                    
  277. //    ObjectMove(timeframe_prefix + "Sup3",0,Time[0],dS3);
  278. //    ObjectSetText(timeframe_prefix + "Sup3", timeframe_prefix_text + "Sup3 ("+DoubleToStr((dS3-Close[0]) * multiplier, 1)+" pts)");                        
  279. //    ObjectMove(timeframe_prefix + "Res3",0,Time[0],dR3);
  280. //    ObjectSetText(timeframe_prefix + "Res3", timeframe_prefix_text + "Res3 ("+DoubleToStr((dR3-Close[0]) * multiplier, 1)+" pts)");                           
  281.    
  282.     // move the helper extension lines to the current bar
  283. //    ObjectMove(timeframe_prefix + "Pivot ext", 0, Time[1],dP);
  284. //    ObjectMove(timeframe_prefix + "Pivot ext", 1, Time[0],dP);
  285. //   ObjectMove(timeframe_prefix + "Res1 ext", 0, Time[1],dR1);
  286. //    ObjectMove(timeframe_prefix + "Res1 ext", 1, Time[0],dR1);
  287.   //  ObjectMove(timeframe_prefix + "Res2 ext", 0, Time[1],dR2);
  288.   //  ObjectMove(timeframe_prefix + "Res2 ext", 1, Time[0],dR2);
  289. //   ObjectMove(timeframe_prefix + "Res3 ext", 0, Time[1],dR3);
  290. //   ObjectMove(timeframe_prefix + "Res3 ext", 1, Time[0],dR3);
  291. //    ObjectMove(timeframe_prefix + "Sup1 ext", 0, Time[1],dS1);
  292. //    ObjectMove(timeframe_prefix + "Sup1 ext", 1, Time[0],dS1);
  293. //   ObjectMove(timeframe_prefix + "Sup2 ext", 0, Time[1],dS2);
  294. //   ObjectMove(timeframe_prefix + "Sup2 ext", 1, Time[0],dS2);
  295. //   ObjectMove(timeframe_prefix + "Sup3 ext", 0, Time[1],dS3);
  296. //   ObjectMove(timeframe_prefix + "Sup3 ext", 1, Time[0],dS3);
  297.    
  298.     //----
  299.     return(0);
  300. }
  301. //+------------------------------------------------------------------+
复制代码

生命哥-BOB系统.zip

362.11 KB, 下载次数: 48, 下载积分: 金钱 -8

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 转播转播 分享分享 分享淘帖 支持支持 保留保留

321

主题

3万

积分

6

精华

百变霹雳小小招财猫!

大型投行

金钱
36815 美元
权重
437
来自 2楼
发表于 2014-9-18 13:39 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:34 编辑

帮田野哥贴图


4

主题

244

积分

0

精华

见习操盘手

金钱
244 美元
权重
14
板凳
发表于 2014-3-26 19:14 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:34 编辑

新手,没有权限下载[/quote]
努力,回帖,加油~

3

主题

429

积分

0

精华

见习操盘手

金钱
429 美元
权重
2
地板
发表于 2014-3-26 23:57 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:34 编辑

没贴图,           

1

主题

6848

积分

0

精华

高级操盘手

金钱
6848 美元
权重
1
5
发表于 2014-3-30 20:27 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

没有图啊,看不出效果怎么样

0

主题

22

积分

0

精华

外汇入门

金钱
22 美元
权重
0
6
发表于 2014-4-6 15:47 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

x学习来了

0

主题

60

积分

0

精华

外汇入门

金钱
60 美元
权重
0
7
发表于 2014-4-7 12:15 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

没有图啊,看不出效果怎么样

0

主题

28

积分

0

精华

外汇入门

金钱
28 美元
权重
0
8
发表于 2014-4-7 16:34 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

谢谢分享!

0

主题

28

积分

0

精华

外汇入门

金钱
28 美元
权重
0
9
发表于 2014-4-7 16:35 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

谢谢分享!

0

主题

12

积分

0

精华

见习期-审核

金钱
12 美元
权重
0
10
发表于 2014-4-12 15:43 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:35 编辑

无图无真相啊!

0

主题

12

积分

0

精华

见习期-审核

金钱
12 美元
权重
0
11
发表于 2014-4-12 16:40 | 只看该作者
5xx版ex4文件:
生命哥-BOB系统mt4-5xx-ex4.zip (17.52 KB, 下载次数: 8)
上张图:

6

主题

660

积分

0

精华

初级操盘手

金钱
660 美元
权重
5
12
发表于 2014-4-17 02:34 | 只看该作者
{:soso_e179:}

1

主题

1380

积分

1

精华

初级操盘手

金钱
1380 美元
权重
0
13
发表于 2014-4-18 17:58 | 只看该作者
谢谢分享  

0

主题

60

积分

0

精华

外汇入门

金钱
60 美元
权重
0
14
发表于 2014-5-20 07:09 | 只看该作者
谢谢分享  

0

主题

24

积分

0

精华

外汇入门

金钱
24 美元
权重
0
15
发表于 2014-5-20 22:20 | 只看该作者
努力,回帖,加油~

0

主题

28

积分

0

精华

外汇入门

金钱
28 美元
权重
0
16
发表于 2014-5-24 11:22 | 只看该作者
回复

使用道具 举报

0

主题

28

积分

0

精华

外汇入门

金钱
28 美元
权重
0
17
发表于 2014-5-28 14:21 | 只看该作者
无图无真相

0

主题

9

积分

0

精华

见习期-审核

金钱
9 美元
权重
0
18
发表于 2014-6-17 18:52 | 只看该作者
不知道好不好用。。。

0

主题

20

积分

0

精华

外汇入门

金钱
20 美元
权重
0
19
发表于 2014-6-19 22:26 | 只看该作者
高端大气上档次,我等楷模

0

主题

37

积分

0

精华

外汇入门

金钱
37 美元
权重
0
20
发表于 2014-6-27 19:50 | 只看该作者
{:soso_e139:}

2

主题

440

积分

0

精华

见习操盘手

金钱
440 美元
权重
0
21
发表于 2014-8-14 23:43 | 只看该作者
谢谢分享  
您需要登录后才可以回帖 登录 | 快捷注册(禁q号)

本版积分规则

QQ|黄金吧|黄金论坛|手机版|指标下载|非农|目录|交易危机

版权所有: ©2014-2021 fx3q.com Powered by Discuz! X3
皖ICP备: 2024050410号-2

风险提示:杠杆风险高,交易要谨慎 声明:坛友发言和回复均为个人观点,不代表论坛立场。
若有侵权请联系fx3q@qq.com删除

快速回复 返回顶部 返回列表