RickK
Active member
Hey all,
I've been working on a project that will plot certain lines based on a certain calculation and I was able to piece together some
code from a pivot points indicator. It does a great job of plotting the lines and the bubbles, but I have a couple of
questions. Currently, the lines will be plotted into perpetuity to the left and into perpetuity to the right.
Here's the code:
I've been working on a project that will plot certain lines based on a certain calculation and I was able to piece together some
code from a pivot points indicator. It does a great job of plotting the lines and the bubbles, but I have a couple of
questions. Currently, the lines will be plotted into perpetuity to the left and into perpetuity to the right.
- Is there a way to have the lines begin on a futures contract roll date and end on the next roll? ... but without having to set my chart to a minimum of a 1 month period?
- Is there a way to get the bubbles to display at the plotted lines even if I scroll back 1, 5, 10 days?
Here's the code:
Code:
input anchor = 3883.40;
input factor = 1.173;
input showbubble = yes;
input shiftbubble = 0;
def n1 = shiftbubble + 1;
def target = anchor * factor;
plot line0 = anchor;
plot line_100 = anchor * factor * -1;
plot line100 = anchor * factor;
plot line_035 = anchor - ((target - anchor) * -0.035);
plot line035 = anchor - ((target - anchor) * 0.035);
plot line_7 = anchor - ((target - anchor) * -0.07);
plot line7 = anchor - ((target - anchor) * 0.07);
plot line_13 = anchor - ((target - anchor) * -0.13);
plot line13 = anchor - ((target - anchor) * 0.13);
plot line_20 = anchor - ((target - anchor) * -0.20);
plot line20 = anchor - ((target - anchor) * 0.20);
plot line_33 = anchor - ((target - anchor) * -0.33);
plot line33 = anchor - ((target - anchor) * 0.33);
plot line_67 = anchor - ((target - anchor) * -0.67);
plot line67 = anchor - ((target - anchor) * 0.67);
line0.SetDefaultColor(Color.downtick);
line_100.SetDefaultColor(Color.downtick);
line100.SetDefaultColor(Color.downtick);
line_035.SetDefaultColor(Color.downtick);
line035.SetDefaultColor(Color.downtick);
line_7.SetDefaultColor(Color.downtick);
line7.SetDefaultColor(Color.downtick);
line_13.SetDefaultColor(Color.downtick);
line13.SetDefaultColor(Color.downtick);
line_33.SetDefaultColor(Color.downtick);
line33.SetDefaultColor(Color.downtick);
line_67.SetDefaultColor(Color.downtick);
line67.SetDefaultColor(Color.downtick);
line_20.SetDefaultColor(Color.downtick);
line20.SetDefaultColor(Color.downtick);
def cond = showbubble and IsNaN(close[shiftbubble]) and !IsNaN(close[n1]) ;
AddChartBubble(cond, line0, "0% Mo", Color.downtick);
AddChartBubble(cond, line_100, "100% Mo", Color.downtick);
AddChartBubble(cond, line100, "-100% Mo", Color.downtick);
AddChartBubble(cond, line035, "-3.5% Mo", Color.downtick);
AddChartBubble(cond, line_035, "3.5% Mo", Color.downtick);
AddChartBubble(cond, line_7, "7% Mo", Color.downtick);
AddChartBubble(cond, line7, "-7% Mo", Color.downtick);
AddChartBubble(cond, line_13, "13% Mo", Color.downtick);
AddChartBubble(cond, line13, "-13% Mo", Color.downtick);
AddChartBubble(cond, line_20, "20% Mo", Color.downtick);
AddChartBubble(cond, line20, "-20% Mo", Color.downtick);
AddChartBubble(cond, line_33, "33% Mo", Color.downtick);
AddChartBubble(cond, line33, "-33% Mo", Color.downtick);
AddChartBubble(cond, line_67, "67% Mo", Color.downtick);
AddChartBubble(cond, line67, "-67% Mo", Color.downtick);
#end