TrillionStrategySessions

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:03 回复:0 关注量:854
GBPUSDH1.png

  1. //+-------------------------------------------------------------------+
  2. //|                                                                   |
  3. //|                       Copyright ?2004, metaQuotes Software Corp. |
  4. //|                                         http://www.metaquotes.net |
  5. //|                  tweaked by accrete at accrete.com                |
  6. //+-------------------------------------------------------------------+
  7. #property copyright "Copyright ?2004, metaQuotes Software Corp."
  8. #property link      "http://www.metaquotes.net"

  9. #property indicator_chart_window

  10. extern int Time_Shift=0;//set to = 16:00 New York on your broker feed

  11. extern bool Previous_Session_H_M_L = true;
  12. extern bool Show_Yesterdays_Close = false;
  13. extern bool Show_Yesterdays_Open = false;

  14. extern color        LineColorOpen        =CornflowerBlue;
  15. extern int Line_Width_Open  =2;
  16. extern color   LineColorClose = SandyBrown;
  17. extern int Line_Width_Close  =2;


  18. double Session_HML=0;
  19. double day_high=0;
  20. double day_low=0;
  21. double yesterday_high=0;
  22. double yesterday_open=0;
  23. double yesterday_low=0;
  24. double yesterday_close=0;
  25. double today_open=0;
  26. double today_high=0;
  27. double today_low=0;
  28. double P=0;//Prior Session Open
  29. double Q=0;
  30. double Y1; //Prior Session Close
  31. double R1,R2,R3;
  32. double M0,M1,M2,M3,M4,M5;
  33. double S1,S2,S3;
  34. double HBu6,HBu5,HBu4,HBu3,HBu2,HBu1;
  35. double HBd6,HBd5,HBd4,HBd3,HBd2,HBd1;
  36. double L4,L3;
  37. double nQ=0;
  38. double nD=0;
  39. double D=0;
  40. double rates_h1[2][6];
  41. double rates_d1[2][6];

  42. //+------------------------------------------------------------------+
  43. //| Custom indicator initialization function                         |
  44. //+------------------------------------------------------------------+
  45. int init()
  46.   {
  47. //---- indicators
  48. R1=0; R2=0; R3=0;
  49. M0=0; M1=0; M2=0; M3=0; M4=0; M5=0;
  50. S1=0; S2=0; S3=0;
  51. HBu6=0; HBu5=0; HBu4=0; HBu3=0; HBu2=0; HBu1=0;
  52. HBd6=0; HBd5=0; HBd4=0; HBd3=0; HBd2=0; HBd1=0;
  53. L4=0; L3=0;
  54. Y1=0;


  55. //----
  56.    return(0);
  57.   }
  58. //+------------------------------------------------------------------+
  59. //| Custor indicator deinitialization function                       |
  60. //+------------------------------------------------------------------+
  61. int deinit()
  62.   {
  63. //---- TODO: add your code here
  64. ObjectDelete("R1 Label");
  65. ObjectDelete("R1 Line");
  66. ObjectDelete("R2 Label");
  67. ObjectDelete("R2 Line");
  68. ObjectDelete("R3 Label");
  69. ObjectDelete("R3 Line");
  70. ObjectDelete("S1 Label");
  71. ObjectDelete("S1 Line");
  72. ObjectDelete("S2 Label");
  73. ObjectDelete("S2 Line");
  74. ObjectDelete("S3 Label");
  75. ObjectDelete("S3 Line");
  76. ObjectDelete("P Label");
  77. ObjectDelete("P Line");
  78. ObjectDelete("Y1 Label");
  79. ObjectDelete("Y1 Line");




  80. ObjectDelete("L3 Label");
  81. ObjectDelete("L3 Line");
  82. ObjectDelete("L4 Label");
  83. ObjectDelete("L4 Line");
  84. ObjectDelete("M5 Label");
  85. ObjectDelete("M5 Line");
  86. ObjectDelete("M4 Label");
  87. ObjectDelete("M4 Line");
  88. ObjectDelete("M3 Label");
  89. ObjectDelete("M3 Line");
  90. ObjectDelete("M2 Label");
  91. ObjectDelete("M2 Line");
  92. ObjectDelete("M1 Label");
  93. ObjectDelete("M1 Line");
  94. ObjectDelete("M0 Label");
  95. ObjectDelete("M0 Line");
  96. //----
  97.    return(0);
  98.   }
  99. //+------------------------------------------------------------------+
  100. //| Custom indicator iteration function                              |
  101. //+------------------------------------------------------------------+
  102. int start()
  103.   {
  104.       int i=0, j=0;
  105. //---- TODO: add your code here

  106. //---- exit if period is greater than daily charts
  107. if(Period() > 1440)
  108. {
  109. Print("Error - Chart period is greater than 1 day.");
  110. return(-1); // then exit
  111. }

  112. //---- Get new daily prices

  113. ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);
  114. yesterday_high = rates_d1[1][3];
  115. yesterday_low = rates_d1[1][2];
  116. day_high = rates_d1[0][3];
  117. day_low = rates_d1[0][2];

  118. ArrayCopyRates(rates_h1, Symbol(), PERIOD_H1);
  119. for (i=0;i<=25;i++)
  120. {
  121.    if (TimeMinute(rates_h1[i][0])==0 && (TimeHour(rates_h1[i][0])-Time_Shift)==0)
  122.    {
  123.       yesterday_close = rates_h1[i+1][4];      
  124.       yesterday_open = rates_h1[i+24][1];
  125.       today_open = rates_h1[i][1];      
  126.       break;
  127.    }
  128. }

  129. //---- Calculate ATM_Pivots

  130. D = (day_high - day_low);
  131. Q = (yesterday_high - yesterday_low);
  132. // P = yesterday_close;
  133. R2 = yesterday_close+(Q*0.50);
  134. R1 = yesterday_close+(Q*0.35);
  135. S1 = yesterday_close-(Q*0.35);
  136. S2 = yesterday_close-(Q*0.50);
  137. //P = (yesterday_high + yesterday_low + yesterday_close) / 3; //original pivot code

  138. // Previous Days High, Median, and Low:
  139. M3 = (yesterday_high + yesterday_low)/2;
  140. M2 = yesterday_low;
  141. M1 = yesterday_high;
  142. P = yesterday_open;
  143. Y1 = yesterday_close;


  144. //H4 = (Q*0.55)+yesterday_close;
  145. // H3 = yesterday_close+(Q*0.125);
  146. //R3 = (2*P)+(yesterday_high-(2*yesterday_low));
  147.        
  148.        
  149.        
  150.        
  151.        
  152. //M5 = (R2+R3)/2;
  153. //        R2 = P-S1+R1;
  154. //M4 = (R1+R2)/2;
  155. //        R1 = (2*P)-yesterday_low;
  156. //M3 = (P+R1)/2;
  157. //        P = (yesterday_high + yesterday_low + yesterday_close)/3;
  158. //M2 = (P+S1)/2;
  159. //        S1 = (2*P)-yesterday_high;
  160. //M1 = (S1+S2)/2;
  161. //        S2 = P-R1+S1;
  162. //S3 = (2*P)-((2* yesterday_high)-yesterday_low);
  163. //L3 = yesterday_close-(Q*0.27);       
  164. //L4 = yesterday_close-(Q*0.55);       
  165. //M0 = (S2+S3)/2;

  166. if (Q > 5)
  167. {
  168.         nQ = Q;
  169. }
  170. else
  171. {
  172.         nQ = Q*10000;
  173. }

  174. if (D > 5)
  175. {
  176.         nD = D;
  177. }
  178. else
  179. {
  180.         nD = D*10000;
  181. }
  182. //Comment("$TrillionStrategy           Prior Range = ",nQ,"        Current Range = ",nD, "nSession Open = ", yesterday_open,"      Session Close = ",yesterday_close);

  183. //---- Set line labels on chart window


  184. //------ Midpoints ATM_Pivots

  185.    if (Previous_Session_H_M_L==true)
  186.    {

  187.       if(ObjectFind("M3 label") != 0)
  188.       {
  189.       ObjectCreate("M3 label", OBJ_TEXT, 0, CurTime(), M3);
  190.       ObjectSetText("M3 label", "                                              sM", 8, "Arial", Violet);
  191.       }
  192.       else
  193.       {
  194.       ObjectMove("M3 label", 0, CurTime(), M3);
  195.       }

  196.       if(ObjectFind("M2 label") != 0)
  197.       {
  198.       ObjectCreate("M2 label", OBJ_TEXT, 0, CurTime(), M2);
  199.       ObjectSetText("M2 label", "                                              sL", 8, "Arial", Red);
  200.       }
  201.       else
  202.       {
  203.       ObjectMove("M2 label", 0, CurTime(), M2);
  204.       }

  205.       if(ObjectFind("M1 label") != 0)
  206.       {
  207.       ObjectCreate("M1 label", OBJ_TEXT, 0, CurTime(), M1);
  208.       ObjectSetText("M1 label", "                                              sH", 8, "Arial", Lime);
  209.       }
  210.       else
  211.       {
  212.       ObjectMove("M1 label", 0, CurTime(), M1);
  213.       }
  214.    
  215.       if(ObjectFind("M3 line") != 0)
  216.       {
  217.       ObjectCreate("M3 line", OBJ_HLINE, 0, Time[40], M3);
  218.       ObjectSet("M3 line", OBJPROP_STYLE, STYLE_DASH);
  219.       ObjectSet("M3 line", OBJPROP_COLOR, Violet);
  220.       }
  221.       else
  222.       {
  223.       ObjectMove("M3 line", 0, Time[40], M3);
  224.       }

  225.       if(ObjectFind("M2 line") != 0)
  226.       {
  227.       ObjectCreate("M2 line", OBJ_HLINE, 0, Time[40], M2);
  228.       ObjectSet("M2 line", OBJPROP_STYLE, STYLE_DASH);
  229.       ObjectSet("M2 line", OBJPROP_COLOR, Red);
  230.       }
  231.       else
  232.       {
  233.       ObjectMove("M2 line", 0, Time[40], M2);
  234.       }

  235.       if(ObjectFind("M1 line") != 0)
  236.       {
  237.       ObjectCreate("M1 line", OBJ_HLINE, 0, Time[40], M1);
  238.       ObjectSet("M1 line", OBJPROP_STYLE, STYLE_DASH);
  239.       ObjectSet("M1 line", OBJPROP_COLOR, Lime);
  240.       }
  241.       else
  242.       {
  243.       ObjectMove("M1 line", 0, Time[40], M1);
  244.       }
  245. }

  246.     if (Show_Yesterdays_Close==true)
  247.    {
  248.            if(ObjectFind("P label") != 0)
  249.       {
  250.       ObjectCreate("P label", OBJ_TEXT, 0, CurTime(), P);
  251.       ObjectSetText("P label", "                       Open", 12, "Arial", LineColorOpen);
  252.       }
  253.       else
  254.       {
  255.       ObjectMove("P label", 0, CurTime(), P);
  256.       }   
  257.             if(ObjectFind("P line") != 0)
  258.       {
  259.       ObjectCreate("P line", OBJ_HLINE, 0, Time[40], P);
  260.       ObjectSet("P line", OBJPROP_STYLE, STYLE_SOLID);
  261.       ObjectSet("P line", OBJPROP_WIDTH, Line_Width_Open);
  262.       ObjectSet("P line", OBJPROP_COLOR, LineColorOpen);
  263.       }
  264.       else
  265.       {
  266.       ObjectMove("P line", 0, Time[40], P);
  267.       }  

  268. }
  269. //------ Show Yesterday's Open:

  270. if ( Show_Yesterdays_Open==true)
  271.    {
  272.            if(ObjectFind("Y1 label") != 0)
  273.       {
  274.       ObjectCreate("Y1 label", OBJ_TEXT, 0, CurTime(), Y1);
  275.       ObjectSetText("Y1 label", "                        Close", 12, "Arial", LineColorClose);
  276.       }
  277.       else
  278.       {
  279.       ObjectMove("Y1 label", 0, CurTime(), Y1);
  280.       }   
  281.             if(ObjectFind("Y1 line") != 0)
  282.       {
  283.       ObjectCreate("Y1 line", OBJ_HLINE, 0, Time[40], Y1);
  284.       ObjectSet("Y1 line", OBJPROP_STYLE, STYLE_SOLID);
  285.        ObjectSet("Y1 line", OBJPROP_WIDTH, Line_Width_Close);
  286.       ObjectSet("Y1 line", OBJPROP_COLOR, LineColorClose);
  287.       }
  288.       else
  289.       {
  290.       ObjectMove("Y1 line", 0, Time[40], Y1);
  291.       }  

  292. }
  293. //----End of Midpoint Pivots Draw

  294. //---- End Of Program
  295.    return(0);
  296.   }
  297. //+------------------------------------------------------------------+
打赏