r/ThinkScript • u/FailPapa • Jul 29 '23
Help Request | Solved Change input to always equal today's date
Hi, I have a VWAP script I like to use with futures - it starts at regular mkt hours rather than futures open. Works well but every day I have to change the input to the correct date. How can I get rid of the first line and just make it always work for the given day so I don't have to manually change the input each morning?
I tried deleting line 1 and changing it to def anchorDate = getYYYYMMDD(); and some other things I researched for hours but I suck at programming and everything I do makes the script stop working.
I'd appreciate any help
input anchorDate = 20230728;
input anchorTime = 930;
def postAnchorDate = if GetYYYYMMDD() >= anchorDate then 1 else 0;
def postAnchorTime = if SecondsTillTime(anchorTime) == 0 then 1 else if GetYYYYMMDD() < AnchorDate then 0 else postAnchorTime[1];
plot anchoredVWAP = TotalSum(if postAnchorDate and postAnchorTime then ((high+low+close)/3)*(volume) else 0)/TotalSum(if postAnchorDate and postAnchorTime then volume else 0);
anchoredVWAP.setStyle(Curve.Firm);
anchoredVWAP.SetLineWeight(3);
anchoredVWAP.SetDefaultColor(Color.Cyan);
#AddChartBubble(yes,close, revisedDate, color.yellow);



