Create a Vertical line for current time with this code

Branch

Branch

Member
VIP
HELP! Can someone add a vertical line to the code below?

Code:
input barsback = 0;
input price = close;
def vClose= close;
def nan = double NaN;
def bn = BarNumber();
def month = GetMonth()
def monthDay = GetDayOfMonth(GetYYYYMMDD();
def currentBar = HighestAll(if !IsNaN(price) then bn else Double NaN);
def highestClose = HighestAll(if IsNaN(vClose[-1]) then vClose else nan);

plot hc= highestClose;
plot hc2 = highestClose2;

hc.SetPaintingStrategy(PaintingStrategy.DASHES);
hc.SetDefaultColor(Color.CYAN)
hc2.SetPaintingStrategy(PaintingStrategy.DASHES)
hc2.SetDefaultColor(Color.WHITE);

assert(barsBack >= 0, ""bars back" cannot be negative");
AddChartBubble(bn==current - barsBack, price,

""+ (if price==close then "$" else if price == open then "Open $" else if price == low then "Low: $" else if price == high then "High:$" else if price ++ OHLC4 then "OHLC4$" else if price == HLC3 then "HLC3 $" else "Value: ")+price,(

If price==close then Color.CYAN else if price == open then Color.WHITE else if price == low then Color.RED else if price == high then Color.WHITE else if price == OHLC4 then  Color.WHITE else if price == HLC3 then Color.Magenta else color.PLUM, yes);
 
Last edited by a moderator:
S

SolidChiken

New member
2019 Donor
Can post a valid codes first? That would get the help easier
 
Branch

Branch

Member
VIP
This one should work- I do apologize SolidChiken
Code:
input barsBack = 0;
input price= close;

#---------------------------------------------------------------------------------------------
def vClose = close;
def nan = double.NaN;
def bn = BarNumber();
def month = GetMonth();
def monthDay = GetDayOfMonth(GetYYYYMMDD());
def currentBar = HighestAll(if  !IsNaN(price) then bn else Double.NaN);
def highestClose = HighestAll(if IsNaN(vClose[-1]) then vClose else nan);
def highestClose2 = HighestAll(if IsNaN(vClose[-1]) then vClose else nan);
plot hc = highestClose;

hc.SetPaintingStrategy(PaintingStrategy.DASHES);
hc.SetDefaultColor(Color.CYAN);

#---------------------------------------------------------------------------------------------
assert(barsBack >= 0, "''bars back'' cannot be negative ");

AddChartBubble(bn == currentBar - barsBack, price,

#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
"" +  ( if price == close  then " $"  else  if price == open  then  "Open: $" else  if price == low  then  "Low: $"   else  if    price == high   then  "High: $"   else  if    price == OHLC4  then  "OHLC4 $" else  if    price == HLC3  then  " HLC3 $" else  " Value:  " )+ price,(

# this section for color
if   price == close  then  Color.YELLOW else  if    price == open  then  Color.CYAN  else  if    price == low  then  Color.CYAN  else  if price == high then  Color.CYAN else  if    price == OHLC4 then  Color.CYAN else  if    price == HLC3 then  Color.CYAN else  Color.CYAN), yes);

#THE END
 
Last edited by a moderator:
S

SolidChiken

New member
2019 Donor
Add the following to your code.

AddVerticalLine(if IsNaN(vClose[-1]) then vClose else nan, "", Color.CYAN, Curve.MEDIUM_DASH);
 
Branch

Branch

Member
VIP
Okay SolidChiken I am going to ask one more task/favor/request of you. Can you provide at the point where the vertical and horizontal points (price) cross the option to "Draw as: dot" at the size of "1-5"? Now I about to see how really good you guys are. But to my lack of knowledge in ThinkScript this task is probably easy.
 
S

SolidChiken

New member
2019 Donor
Hi @Branch... I'm afraid to tell you that I dunno how to code that. Ha... Let's wait someone else to assist your request
 
Branch

Branch

Member
VIP
I am going to give it a shot. I will try an if statement something to the thought "when the two lines cross" theory.
 
Branch

Branch

Member
VIP
SolidChiken - I came up with this
plot Signal = if hc[-1] equals vClose then hc else Double.Nan;
And I noticed that the "plot Signal" would also plot the highest close on past bars when current vClose price close. I am good with that. Now I have to make it work in my favor (seeing past price close...etc.)

Thanks again SolidChiken (SC)
 

Similar threads

Top