Advertisement
gs9777

Untitled

Dec 6th, 2021
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. input showOnlyToday = YES;
  2.  
  3.  
  4. def day = GetDay();
  5. def lastDay = GetLastDay();
  6. def isToday = If(day == lastDay, 1, 0);
  7. def shouldPlot = If(showOnlyToday and isToday, 1, If(!showOnlyToday, 1, 0));
  8.  
  9. input Market_Open_Time = 0730;
  10. input Market_Close_Time = 1600;
  11. input rollingPeriodMinutes = 60;
  12.  
  13. def factor = (SecondsFromTime(Market_Open_Time) / (60 * rollingPeriodMinutes) / 100);
  14. def rolloverTime = if factor == Round(factor) then 1 else 0;
  15.  
  16. rec H1 = compoundValue(1, if !rolloverTime then if high > H1[1] then high else H1[1] else high, high);
  17. rec H = compoundValue(1, if rolloverTime then H1[1] else H[1], high);
  18. rec L1 = compoundValue(1, if !rolloverTime then if low < L1[1] then low else L1[1] else low, low);
  19. rec L = compoundValue(1, if rolloverTime then L1[1] else L[1], low);
  20. rec C = compoundValue(1, if rolloverTime then close[1] else C[1], close);
  21. rec O = compoundValue(1, if rolloverTime then open else O[1], open);
  22. rec X_VAR = if C < O then (H + 2 * L + C) else if C > O then (2 * H + L + C) else (H + L + 2 * C);
  23.  
  24. rec PP_VAR;
  25. rec R1_VAR;
  26. rec R2_VAR;
  27. rec R3_VAR;
  28. rec R4_VAR;
  29. rec S1_VAR;
  30. rec S2_VAR;
  31. rec S3_VAR;
  32. rec S4_VAR;
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. PP_VAR = if shouldPlot then (H + L + C) / 3 else Double.NaN;
  41. R1_VAR = if shouldPlot then PP_VAR + (H - L) / 2 else Double.NaN;
  42. R2_VAR = if shouldPlot then PP_VAR + (H - L) * 1.272 else Double.NaN;
  43. R3_VAR = if shouldPlot then PP_VAR + (H - L) else Double.NaN;
  44. R4_VAR = Double.NaN;
  45. S1_VAR = if shouldPlot then PP_VAR - (H - L) / 2 else Double.NaN;
  46. S2_VAR = if shouldPlot then PP_VAR - (H - L) * 1.272 else Double.NaN;
  47. S3_VAR = if shouldPlot then PP_VAR - (H - L) else Double.NaN;
  48. S4_VAR = Double.NaN;
  49.  
  50.  
  51.  
  52. plot PP = PP_VAR;
  53. plot R1 = R1_VAR;
  54. plot R2 = R2_VAR;
  55. plot R3 = R3_VAR;
  56. plot R4 = R4_VAR;
  57. plot S1 = S1_VAR;
  58. plot S2 = S2_VAR;
  59. plot S3 = S3_VAR;
  60. plot S4 = S4_VAR;
  61.  
  62. PP.SetDefaultColor(Color.WHITE);
  63.  
  64. R1.SetDefaultColor(Color.RED);
  65. R2.SetDefaultColor(Color.RED);
  66. R3.SetDefaultColor(Color.RED);
  67. R4.SetDefaultColor(Color.RED);
  68.  
  69. S1.SetDefaultColor(Color.GREEN);
  70. S2.SetDefaultColor(Color.GREEN);
  71. S3.SetDefaultColor(Color.GREEN);
  72. S4.SetDefaultColor(Color.GREEN);
  73.  
  74. PP.SetStyle(Curve.POINTS);
  75. R1.SetStyle(Curve.POINTS);
  76. R2.SetStyle(Curve.POINTS);
  77. R3.SetStyle(Curve.POINTS);
  78. R4.SetStyle(Curve.POINTS);
  79. S1.SetStyle(Curve.POINTS);
  80. S2.SetStyle(Curve.POINTS);
  81. S3.SetStyle(Curve.POINTS);
  82. S4.SetStyle(Curve.POINTS);
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement