Can this be changed to minutes? When I put it on an interday chart, I am getting a day for each minute showing.
+ " | "+ " Bought: " +BuyBarsAgo +" days ago",
https://usethinkscript.com/threads/...quities-in-thinkorswim.7089/page-6#post-77993
+ " | "+ " Bought: " +BuyBarsAgo +" days ago",
https://usethinkscript.com/threads/...quities-in-thinkorswim.7089/page-6#post-77993
Code:
# Current P/L Status
input value = .07;
def avg = getaveragePrice();
def AreYouIn = if getquantity() != 0 then yes else no;
def targetprice02 = (avg) - (value*2);
def TargetPrice01 = (avg) - value;
def TargetPrice1 = (avg) + value;
def TargetPrice2 = (avg) + (value * 2);
def TargetPrice3 = (avg) + (value * 3);
def Entry = if isNaN(avg) then Entry[1] else avg;
def LastEntryBar = if Entry != Entry[1] then barNumber() else LastEntryBar[1];
def BuyBarsAgo = if barNumber() != LastEntryBar
then barNumber() - LastEntryBar
else if barNumber() == LastEntryBar
then Double.NaN
else BuyBarsAgo[1];
AddLabel(AreYouIn,
"Cost: " +round(avg,2) +
(if GetOpenPL() > 0
then " | "+ "P/L: $" + GetOpenPL() +
" | "+ aspercent(getopenPL() / (avg * getquantity()))
else " | "+ "P/L: -$" + GetOpenPL() +
" | "+ aspercent(getopenPL() / (avg * getquantity())))
+ " | "+ " Bought: " +BuyBarsAgo +" days ago",
if GetOpenPL() > 0
then Color.DARK_GREEN
else Color.DARK_RED);
plot downside2 = if avg != 0 then TargetPrice02 else double.nan;
downside2.setstyle(curve.FIRM);
downside2.setdefaultColor(color.DARK_RED);
plot downside1 = if avg != 0 then TargetPrice01 else double.nan;
downside1.setstyle(curve.SHORT_DASH);
downside1.setdefaultColor(color.red);
plot avgprice = if avg != 0 then avg else double.nan;
avgprice.setstyle(curve.SHORT_DASH);
avgprice.setdefaultColor(color.Yellow);
plot upside1 = if avg != 0 then TargetPrice1 else double.nan;
upside1.setstyle(curve.SHORT_DASH);
upside1.setdefaultColor(color.light_GREEN);
plot upside2 = if avg != 0 then TargetPrice2 else double.nan;
upside2.setstyle(curve.SHORT_DASH);
upside2.setdefaultColor(color.light_GREEN);
plot upside3 = if avg != 0 then TargetPrice3 else double.nan;
upside3.setstyle(curve.FIRM);
upside3.setdefaultColor(color.dark_GREEN);
Last edited by a moderator: