Advertisement
Guest User

murrey

a guest
Nov 13th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.16 KB | None | 0 0
  1. //+------------------------------------------------------------------+
  2. //| Murrey_Math_Line_X.mq4 |
  3. //| Copyright © 2004, Vladislav Goshkov (VG).|
  4. //| 4vg@mail.ru |
  5. //| code change by Alex.Piech.FinGeR |
  6. //+------------------------------------------------------------------+
  7. #property copyright "Vladislav Goshkov (VG) && Alex.Piech.FinGeR"
  8. #property link "4vg@mail.ru && regnif@gmx.net"
  9.  
  10. #property indicator_chart_window
  11.  
  12. // ============================================================================================
  13. // * Line 8/8 è 0/8 (Ultimate Support and Ultimate Resistance).
  14. // * Those lines are the most strong concerning Support and esistance.
  15. // ============================================================================================
  16. //* Line 7/8 (Weak, Place to Stop and Reverse).
  17. //* This line is weak. If suddenly the price was going too fast and too far and stops around this line
  18. //* it means the price will reverse down very soon. If the price did not stop near this line this price
  19. //* will continue the movement to the line 8/8.
  20. // ============================================================================================
  21. //* Line 1/8 (Weak, Place to Stop and Reverse).
  22. //* This line is weak. If suddenly the price was going too fast and too far and stops around this line
  23. //* it means the price will reverse up very soon. If the price did not stop near this line this price
  24. //* will continue the movement down to the line 0/8.
  25. // ============================================================================================
  26. //* Line 2/8 and 6/8 (Pivot, Reverse)
  27. //* Those two lines yield the line 4/8 only to the strength to reverse the price movement.
  28. // ============================================================================================
  29. //* Line 5/8 (Top of Trading Range)
  30. //* The price is spending the about 40% of the time on the movement between the lines 5/8 and 3/8.
  31. //* If the price is moving near line 5/8 and stopping near the line during the 10 - 12 days so it means
  32. //* that it is necessary to sell in this "bonus zone" (some people are doing like this) but if the price is keeping the tendency to stay above
  33. //* 5/8 line, so it means that the price will be above. But if the price is droping below 5/8 line it means that the price will continue
  34. //* falling to the next level of resistance.
  35. // ============================================================================================
  36. //* Line 3/8 (Bottom of Trading Range).
  37. //* If the price is below this line and in uptrend it means that it will be very difficult for the price to break this level.
  38. //* If the price broke this line during the uptrend and staying above during the 10 12 days it means that the price will be above this line
  39. //* during the 40% of its time moving between this line and 5/8 line.
  40. // ============================================================================================
  41. //* Line 4/8 (Major Support/Resistance Line).
  42. //* It is the major line concerning support and resistance. This leve is the better for the new sell or buy.
  43. //* It is the strong level of support of the price is above 4/8. It is the fine resistance line if the price is below this 4/8 line.
  44. //* ñîïğîòèâëåíèÿ.
  45. // ============================================================================================
  46. extern int P = 64;
  47. extern int MMPeriod = 1440;
  48. extern int StepBack = 0;
  49.  
  50. extern color mml_clr_m_2_8 = White; // [-2]/8
  51. extern color mml_clr_m_1_8 = White; // [-1]/8
  52. extern color mml_clr_0_8 = Aqua; // [0]/8
  53. extern color mml_clr_1_8 = Yellow; // [1]/8
  54. extern color mml_clr_2_8 = Red; // [2]/8
  55. extern color mml_clr_3_8 = Green; // [3]/8
  56. extern color mml_clr_4_8 = Blue; // [4]/8
  57. extern color mml_clr_5_8 = Green; // [5]/8
  58. extern color mml_clr_6_8 = Red; // [6]/8
  59. extern color mml_clr_7_8 = Yellow; // [7]/8
  60. extern color mml_clr_8_8 = Aqua; // [8]/8
  61. extern color mml_clr_p_1_8 = White; // [+1]/8
  62. extern color mml_clr_p_2_8 = White; // [+2]/8
  63.  
  64. extern int mml_wdth_m_2_8 = 2; // [-2]/8
  65. extern int mml_wdth_m_1_8 = 1; // [-1]/8
  66. extern int mml_wdth_0_8 = 1; // [0]/8
  67. extern int mml_wdth_1_8 = 1; // [1]/8
  68. extern int mml_wdth_2_8 = 1; // [2]/8
  69. extern int mml_wdth_3_8 = 1; // [3]/8
  70. extern int mml_wdth_4_8 = 1; // [4]/8
  71. extern int mml_wdth_5_8 = 1; // [5]/8
  72. extern int mml_wdth_6_8 = 1; // [6]/8
  73. extern int mml_wdth_7_8 = 1; // [7]/8
  74. extern int mml_wdth_8_8 = 1; // [8]/8
  75. extern int mml_wdth_p_1_8 = 1; // [+1]/8
  76. extern int mml_wdth_p_2_8 = 2; // [+2]/8
  77.  
  78. extern color MarkColor = Blue;
  79. extern int MarkNumber = 217;
  80.  
  81.  
  82. double dmml = 0,
  83. dvtl = 0,
  84. sum = 0,
  85. v1 = 0,
  86. v2 = 0,
  87. mn = 0,
  88. mx = 0,
  89. x1 = 0,
  90. x2 = 0,
  91. x3 = 0,
  92. x4 = 0,
  93. x5 = 0,
  94. x6 = 0,
  95. y1 = 0,
  96. y2 = 0,
  97. y3 = 0,
  98. y4 = 0,
  99. y5 = 0,
  100. y6 = 0,
  101. octave = 0,
  102. fractal = 0,
  103. range = 0,
  104. finalH = 0,
  105. finalL = 0,
  106. mml[13];
  107.  
  108. string ln_txt[13],
  109. buff_str = "";
  110.  
  111. int
  112. bn_v1 = 0,
  113. bn_v2 = 0,
  114. OctLinesCnt = 13,
  115. mml_thk = 8,
  116. mml_clr[13],
  117. mml_wdth[13],
  118. mml_shft = 35,
  119. nTime = 0,
  120. CurPeriod = 0,
  121. nDigits = 0,
  122. i = 0;
  123. int NewPeriod=0;
  124. //+------------------------------------------------------------------+
  125. //| Custom indicator initialization function |
  126. //+------------------------------------------------------------------+
  127. int init() {
  128. //---- indicators
  129. if(MMPeriod>0)
  130. NewPeriod = P*MathCeil(MMPeriod/Period());
  131. else NewPeriod = P;
  132.  
  133. ln_txt[0] = "[-2/8]P";// "extremely overshoot [-2/8]";// [-2/8]
  134. ln_txt[1] = "[-1/8]P";// "overshoot [-1/8]";// [-1/8]
  135. ln_txt[2] = "[0/8]P";// "Ultimate Support - extremely oversold [0/8]";// [0/8]
  136. ln_txt[3] = "[1/8]P";// "Weak, Place to Stop and Reverse - [1/8]";// [1/8]
  137. ln_txt[4] = "[2/8]P";// "Pivot, Reverse - major [2/8]";// [2/8]
  138. ln_txt[5] = "[3/8]P";// "Bottom of Trading Range - [3/8], if 10-12 bars then 40% Time. BUY Premium Zone";//[3/8]
  139. ln_txt[6] = "[4/8]P";// "Major Support/Resistance Pivotal Point [4/8]- Best New BUY or SELL level";// [4/8]
  140. ln_txt[7] = "[5/8]P";// "Top of Trading Range - [5/8], if 10-12 bars then 40% Time. SELL Premium Zone";//[5/8]
  141. ln_txt[8] = "[6/8]P";// "Pivot, Reverse - major [6/8]";// [6/8]
  142. ln_txt[9] = "[7/8]P";// "Weak, Place to Stop and Reverse - [7/8]";// [7/8]
  143. ln_txt[10] = "[8/8]P";// "Ultimate Resistance - extremely overbought [8/8]";// [8/8]
  144. ln_txt[11] = "[+1/8]P";// "overshoot [+1/8]";// [+1/8]
  145. ln_txt[12] = "[+2/8]P";// "extremely overshoot [+2/8]";// [+2/8]
  146.  
  147. //mml_shft = 3;
  148. mml_thk = 3;
  149.  
  150. // Íà÷àëüíàÿ óñòàíîâêà öâåòîâ óğîâíåé îêòàâ è òîëùèíû ëèíèé
  151. mml_clr[0] = mml_clr_m_2_8; mml_wdth[0] = mml_wdth_m_2_8; // [-2]/8
  152. mml_clr[1] = mml_clr_m_1_8; mml_wdth[1] = mml_wdth_m_1_8; // [-1]/8
  153. mml_clr[2] = mml_clr_0_8; mml_wdth[2] = mml_wdth_0_8; // [0]/8
  154. mml_clr[3] = mml_clr_1_8; mml_wdth[3] = mml_wdth_1_8; // [1]/8
  155. mml_clr[4] = mml_clr_2_8; mml_wdth[4] = mml_wdth_2_8; // [2]/8
  156. mml_clr[5] = mml_clr_3_8; mml_wdth[5] = mml_wdth_3_8; // [3]/8
  157. mml_clr[6] = mml_clr_4_8; mml_wdth[6] = mml_wdth_4_8; // [4]/8
  158. mml_clr[7] = mml_clr_5_8; mml_wdth[7] = mml_wdth_5_8; // [5]/8
  159. mml_clr[8] = mml_clr_6_8; mml_wdth[8] = mml_wdth_6_8; // [6]/8
  160. mml_clr[9] = mml_clr_7_8; mml_wdth[9] = mml_wdth_7_8; // [7]/8
  161. mml_clr[10] = mml_clr_8_8; mml_wdth[10]= mml_wdth_8_8; // [8]/8
  162. mml_clr[11] = mml_clr_p_1_8; mml_wdth[11]= mml_wdth_p_1_8; // [+1]/8
  163. mml_clr[12] = mml_clr_p_2_8; mml_wdth[12]= mml_wdth_p_2_8; // [+2]/8
  164.  
  165.  
  166. //----
  167. return(0);
  168. }
  169.  
  170. //+------------------------------------------------------------------+
  171. //| Custor indicator deinitialization function |
  172. //+------------------------------------------------------------------+
  173. int deinit() {
  174. //---- TODO: add your code here
  175. Comment(" ");
  176. for(i=0;i<OctLinesCnt;i++) {
  177. buff_str = "mml"+i;
  178. ObjectDelete(buff_str);
  179. buff_str = "mml_txt"+i;
  180. ObjectDelete(buff_str);
  181. buff_str = "MML_LatestCulcBar";
  182. ObjectDelete(buff_str);
  183. }
  184. //----
  185. return(0);
  186. }
  187. //+------------------------------------------------------------------+
  188. //| Custom indicator iteration function |
  189. //+------------------------------------------------------------------+
  190. int start() {
  191.  
  192. //---- TODO: add your code here
  193.  
  194. if( (nTime != Time[0]) || (CurPeriod != Period()) ) {
  195.  
  196. //price
  197. bn_v1 = Lowest(NULL,0,MODE_LOW,NewPeriod+StepBack,StepBack);
  198. bn_v2 = Highest(NULL,0,MODE_HIGH,NewPeriod+StepBack,StepBack);
  199.  
  200. v1 = Low[bn_v1];
  201. v2 = High[bn_v2];
  202.  
  203. //determine fractal.....
  204. if( v2<=250000 && v2>25000 )
  205. fractal=100000;
  206. else
  207. if( v2<=25000 && v2>2500 )
  208. fractal=10000;
  209. else
  210. if( v2<=2500 && v2>250 )
  211. fractal=1000;
  212. else
  213. if( v2<=250 && v2>25 )
  214. fractal=100;
  215. else
  216. if( v2<=25 && v2>12.5 )
  217. fractal=12.5;
  218. else
  219. if( v2<=12.5 && v2>6.25)
  220. fractal=12.5;
  221. else
  222. if( v2<=6.25 && v2>3.125 )
  223. fractal=6.25;
  224. else
  225. if( v2<=3.125 && v2>1.5625 )
  226. fractal=3.125;
  227. else
  228. if( v2<=1.5625 && v2>0.390625 )
  229. fractal=1.5625;
  230. else
  231. if( v2<=0.390625 && v2>0)
  232. fractal=0.1953125;
  233.  
  234. range=(v2-v1);
  235. sum=MathFloor(MathLog(fractal/range)/MathLog(2));
  236. octave=fractal*(MathPow(0.5,sum));
  237. mn=MathFloor(v1/octave)*octave;
  238. if( (mn+octave)>v2 )
  239. mx=mn+octave;
  240. else
  241. mx=mn+(2*octave);
  242.  
  243.  
  244. // calculating xx
  245. //x2
  246. if( (v1>=(3*(mx-mn)/16+mn)) && (v2<=(9*(mx-mn)/16+mn)) )
  247. x2=mn+(mx-mn)/2;
  248. else x2=0;
  249. //x1
  250. if( (v1>=(mn-(mx-mn)/8))&& (v2<=(5*(mx-mn)/8+mn)) && (x2==0) )
  251. x1=mn+(mx-mn)/2;
  252. else x1=0;
  253.  
  254. //x4
  255. if( (v1>=(mn+7*(mx-mn)/16))&& (v2<=(13*(mx-mn)/16+mn)) )
  256. x4=mn+3*(mx-mn)/4;
  257. else x4=0;
  258.  
  259. //x5
  260. if( (v1>=(mn+3*(mx-mn)/8))&& (v2<=(9*(mx-mn)/8+mn))&& (x4==0) )
  261. x5=mx;
  262. else x5=0;
  263.  
  264. //x3
  265. if( (v1>=(mn+(mx-mn)/8))&& (v2<=(7*(mx-mn)/8+mn))&& (x1==0) && (x2==0) && (x4==0) && (x5==0) )
  266. x3=mn+3*(mx-mn)/4;
  267. else x3=0;
  268.  
  269. //x6
  270. if( (x1+x2+x3+x4+x5) ==0 )
  271. x6=mx;
  272. else x6=0;
  273.  
  274. finalH = x1+x2+x3+x4+x5+x6;
  275. // calculating yy
  276. //y1
  277. if( x1>0 )
  278. y1=mn;
  279. else y1=0;
  280.  
  281. //y2
  282. if( x2>0 )
  283. y2=mn+(mx-mn)/4;
  284. else y2=0;
  285.  
  286. //y3
  287. if( x3>0 )
  288. y3=mn+(mx-mn)/4;
  289. else y3=0;
  290.  
  291. //y4
  292. if( x4>0 )
  293. y4=mn+(mx-mn)/2;
  294. else y4=0;
  295.  
  296. //y5
  297. if( x5>0 )
  298. y5=mn+(mx-mn)/2;
  299. else y5=0;
  300.  
  301. //y6
  302. if( (finalH>0) && ((y1+y2+y3+y4+y5)==0) )
  303. y6=mn;
  304. else y6=0;
  305.  
  306. finalL = y1+y2+y3+y4+y5+y6;
  307.  
  308. for( i=0; i<OctLinesCnt; i++) {
  309. mml[i] = 0;
  310. }
  311.  
  312. dmml = (finalH-finalL)/8;
  313.  
  314. mml[0] =(finalL-dmml*2); //-2/8
  315. for( i=1; i<OctLinesCnt; i++) {
  316. mml[i] = mml[i-1] + dmml;
  317. }
  318. for( i=0; i<OctLinesCnt; i++ ){
  319. buff_str = "mml"+i;
  320. if(ObjectFind(buff_str) == -1) {
  321. ObjectCreate(buff_str, OBJ_HLINE , 0,Time[0], mml[i]);
  322. ObjectSet(buff_str, OBJPROP_STYLE, STYLE_SOLID);
  323. ObjectSet(buff_str, OBJPROP_COLOR, mml_clr[i]);
  324. ObjectSet(buff_str, OBJPROP_WIDTH, mml_wdth[i]);
  325. ObjectMove(buff_str, 0, Time[0], mml[i]);
  326. }
  327. else {
  328. ObjectMove(buff_str, 0, Time[0], mml[i]);
  329. }
  330.  
  331. buff_str = "mml_txt"+i;
  332. if(ObjectFind(buff_str) == -1) {
  333. ObjectCreate(buff_str, OBJ_TEXT, 0, Time[mml_shft], mml_shft);
  334. ObjectSetText(buff_str, ln_txt[i], 8, "Arial", mml_clr[i]);
  335. ObjectMove(buff_str, 0, Time[mml_shft], mml[i]);
  336. }
  337. else {
  338. ObjectMove(buff_str, 0, Time[mml_shft], mml[i]);
  339. }
  340. } // for( i=1; i<=OctLinesCnt; i++ ){
  341.  
  342. nTime = Time[0];
  343. CurPeriod= Period();
  344.  
  345. buff_str = "MML_LatestCulcBar";
  346. if(ObjectFind(buff_str) == -1) {
  347. ObjectCreate(buff_str, OBJ_ARROW,0, Time[StepBack], Low[StepBack]-2*Point );
  348. ObjectSet(buff_str, OBJPROP_ARROWCODE, MarkNumber);
  349. ObjectSet(buff_str, OBJPROP_COLOR, MarkColor);
  350. }
  351. else {
  352. ObjectMove(buff_str, 0, Time[StepBack], Low[StepBack]-2*Point );
  353. }
  354.  
  355. }
  356.  
  357. //---- End Of Program
  358. return(0);
  359. }
  360. //+------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement