Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Expected Move Labels ###
- # This script will add expected move labels, #
- # in dollars, to charts. IT IS INTENDED TO BE#
- # USED ONLY ON CHARTS WITH DAILY BARS. The #
- # math will not work one charts with other #
- # settings. #
- ### Settings for coloring ###
- input dayCountDanger = 1; #hint: Out of the last two days, this number of violations of the expected move will turn the label red.
- input weekCountDanger = 5; #hint: Out of the last ten days, this number of violations of the expected move will turn the label red.
- input weekCountWarning = 2; #hint: Out of the last ten days, this number of violations of the expected move will turn the label yellow.
- input monthCountDanger = 11; #hint: Out of the last twenty two days, this number of violations of the expected move will turn the label red.
- input monthCountWarning = 5; #hint: Out of the last twenty two days, this number of violations of the expected move will turn the label yellow.
- input violationMetric = close; # hint: The metric that will count as a violation against the expected move.
- ### Calculate the expected move ###
- def IVBase = imp_volatility();
- def ExMoveBase = close * IVBase;
- def ExMoveOneDay = close * IVBase * Sqrt(1/365);
- def ExMoveOneWeek = close * IVBase * Sqrt(7/365);
- def ExMoveOneMonth = close * IVBase * Sqrt(30/365);
- ### Determine violations ###
- def dayCount = fold i = 1 to 5 with countA = 0
- do
- if violationMetric[i] > (violationMetric + ExMoveOneDay) or violationMetric[i] < (violationMetric - ExMoveOneDay) then
- countA + 1
- else
- countA;
- def weekCount = fold n = 1 to 10 with countB = 0
- do
- if violationMetric[n] > (violationMetric + ExMoveOneWeek) or violationMetric[n] < (violationMetric - ExMoveOneWeek) then
- countB + 1
- else
- countB;
- def monthCount = fold m = 1 to 22 with countC = 0
- do
- if violationMetric[m] > (violationMetric + ExMoveOneMonth) or violationMetric[m] < (violationMetric - ExMoveOneMonth) then
- countC + 1
- else
- countC;
- ### Add labels to chart ###
- AddLabel(yes, "Expected Moves at 68% confidence", Color.WHITE);
- AddLabel(yes, "1 Day: +/-" + AsDollars(ExMoveOneDay) + "(" + dayCount + ")", if dayCount > 1 then Color.RED else if dayCount == 1 then Color.YELLOW else Color.GREEN);
- AddLabel(yes, "1 Week: +/-" + AsDollars(ExMoveOneWeek) + "(" + weekCount + ")", if weekCount >= 5 then Color.RED else if weekCount > 2 and weekCount < 5 then Color.YELLOW else Color.GREEN);
- AddLabel(yes, "1 Month: +/-" + AsDollars(ExMoveOneMonth) + "(" + monthCount + ")", if monthCount >= 11 then Color.RED else if monthCount > 5 and monthCount < 11 then Color.YELLOW else Color.GREEN);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement