Don't like ads? PRO users don't see any ads ;-)

# Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 2.97 KB  |  hits: 8  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. #Plots the average weekly range over AR_period. Once the
2. #weekly low is hit, a fill to the 50% AR is very likely.
3. #Difficulty is to know when the daily/weekly bottom is hit
4.
5.
6. input timeFrame = {DAY, default WEEK, MONTH};
7. input timeFrame2 = {"4 hours", default DAY, WEEK,MONTH};
8. #input timeFrame3 = {DAY,default WEEK};
9. #input timeFrame4 = {WEEK,default MONTH};
10. input AR_period = {"1", "3","10","14", default  "20","120"};
11. #input AR_week ={default "26"};
12. #input AR_month={default "24"};
13. input showOnlyToday = yes;
14.
15. def OM = open(period = timeFrame);
16. def CM = close(period = timeFrame);
17.
18. def OW = open(period = timeFrame2);
19. def CW = close(period = timeFrame2);
20.
21. def AvgDayRange = high(period = timeFrame2)[AR_period] - low(period = timeFrame2)[AR_period];
22. #def AvgWeekRange = high(period = timeFrame3)[AR_week] - low(period = timeFrame3)[AR_week];
23. #def AvgMonthRange = high(period = timeFrame4)[AR_month] - low(period = timeFrame4)[AR_month];
24. def calc_AR100 = low(period = timeFrame2) + AvgDayRange;
25. def calc_AR50 = low(period = timeFrame2) + 0.5 * AvgDayRange;
26. def calc_AR65 = low(period = timeFrame2) + 0.65 * AvgDayRange;
27. def calc_AR0 =  (high(period = timeFrame2) + low(period = timeFrame2)) / 2.0;
28. def calc_mAR100 = high(period = timeFrame2) - AvgDayRange;
29. def calc_mAR50 = high(period = timeFrame2) - 0.5 * AvgDayRange;
30. def calc_mAR65 = high(period = timeFrame2) - 0.65 * AvgDayRange;
31. AddChartLabel(yes,concat(concat(concat(concat(concat("AvgDailyRange: ",AvgDayRange)," (CurrentDayRange: "), round((high(period = timeFrame2)-low(period=timeFrame2))/AvgDayRange*100,2)),"% of ADR"),AR_period));
32. #AddChartLabel(yes,concat(concat(concat(concat("AvgWeeklyRange: ",AvgWeekRange)," (CurrentWeekRange: "), round((high(period = timeFrame3)-low(period=timeFrame3))/AvgWeekRange*100,2)),"% of AWR"));
33. #AddChartLabel(yes,concat(concat(concat(concat("AvgMonthlyRange: ",AvgMonthRange)," (CurrentMonthRange: "), round((high(period = timeFrame4)-low(period=timeFrame4))/AvgMonthRange*100,2)),"% of AMR"));
34. AddChartLabel(yes, concat("AR Projection Up ", calc_AR100));
35. AddChartLabel(yes, concat("AR Projection Down ", calc_mAR100));
36. plot AR100;
37. plot AR50;
38. plot AR0;
39. plot mAR50;
40. plot mAR100;
41.
42. if (showOnlyToday and !IsNaN(close(period = timeFrame2)[-1])) or
43. (getAggregationPeriod() > if timeFrame == timeFrame.WEEK then AggregationPeriod.WEEK else AggregationPeriod.MONTH)
44. then {
45.     AR100 = Double.NaN;
46.     AR50 = Double.NaN;
47.     AR0 = Double.NaN;
48.     mAR50 = Double.NaN;
49.     mAR100 = Double.NaN;
50. }
51. else {
52.     AR100 = calc_AR100;
53.     AR50 = calc_AR50;
54.     AR0 = calc_AR0;
55.     mAR50 = calc_mAR50;
56.     mAR100 = calc_mAR100;
57. }
58.
59.
60. AR0.SetDefaultColor(color.white);
61. mAR100.SetDefaultColor(color.red);
62. mAR50.SetDefaultColor(color.red);
63. AR50.SetDefaultColor(color.blue);
64. AR100.SetDefaultColor(color.blue);
65.
66. AR0.SetStyle(Curve.FIRM);
67. mAR100.SetStyle(Curve.FIRM);
68. mAR100.SetLineWeight(5);
69. mAR50.SetStyle(Curve.FIRM);
70. AR100.SetStyle(Curve.FIRM);
71. AR100.SetLineWeight(5);
72. AR50.SetStyle(Curve.FIRM);