Hello,
I've put together a simple profit/loss zone indicator/study that will help with visualizing profit/loss zones. I would love to see others add/expand/improve this for automation as well as to use in range-bar setup. Here's the code, and a couple of use-cases.
The process of displaying this is very crude, but it's manual. I trade on another platform for day-trading and use TOS for visualizing, so I wanted a way to see my stop zones. The way it works is you enter a profit/loss range in $ amount. I trade using ATR, so I either use 1:1 ATR for my range, or .5:1 ATR range for tighter moves. The zones can switch between buy and sell. Yellow dotted line indicates $ figure you are in at. the plot posts at a certain time, and for a duration after, which you can extend if you like. You can switch on/off by indicating if you're in. Here are the figures:
Value: 00.00 # Use this to indicate the rage between your loss/take profit. If you believe $ will go up by $0.05, then type 0.05
dollarvalue: 0000 # Use this to indicate your dollar value. The number will divide by 100, so 4000 = 40.00 aka $40.00
Buy: yes/no #this is if you are long or short. Buy yes means long, buy no means short. Its crude but I understand it...
Thyme: 0000 # Use this to indicate time. 0630 is 06:30... 834 is 08:34.. etc
min: 0 #How many minutes you expect to sit in your trade... I use 10 or so by default depending on volitility
are you in: yes/no #show the graph or not, I had it automatic with getquantity() but again I use this for charting more than trading on TOS
The zones are 1x 2x 3x and -1x -2x, I added clouds as well just to give me a better look. I would love to use this on Range bars using ATR ranges because this is how I mainly trade, priceaction intraday. If anyone has tips to make this indicator simpler, easier, and faster, I would love that. I want to add a vertical line for time, and extend my yellow horizontal line left as well to show price... Similar to the vertical drawing/horz drawing for time/price. If I could also trigger this study every time my price/time drawings cross, that would be amazing!!!
Just Labels from the 2nd Script:
Profit and Loss Zones:
Code:
# Crude Buy Sell Zone indicator by ANTHDKN 06.04.2021
# Free to use to all
# First posted on usethinkscript.com
# Manual entries for positions
input value = .07;
input dollarvalue = 0;
input buy = yes;
input thyme = 0630;
input min = 2; # Mins till
def BUY_YES_SELL_NO = if buy then no else yes;
def thymeOffset = 0300;
def showAt = thyme + thymeoffset;
def avg = dollarvalue * .01;
input AreYouIn = no;
# Average True Range Label
AddLabel(!AreYouIn, "ATR: " + AsDollars(ATR()), Color.YELLOW);
# You are in Label
addlabel(areyouin, "In at " + asdollars(avg), color.white);
# Profit/Loss zones as multiple of ATR
# Sell Side
def targetprice03 = if !Buy_Yes_Sell_No
then (avg * .01) - (value * 3)
else (avg * .01) + (value * 3);
def targetprice02 = if !Buy_Yes_Sell_No
then (avg * .01) - (value * 2)
else (avg * .01) + (value * 2);
def targetprice01 = if !Buy_Yes_Sell_No
then (avg * .01) - (value)
else (avg * .01) + (value);
#Buy Side
def targetprice1 = if Buy_Yes_Sell_No
then (avg * .01) + (value)
else (avg * .01) - (value);
def targetprice2 = if Buy_Yes_Sell_No
then (avg * .01) + (value * 2)
else (avg * .01) - (value * 2);
def targetprice3 = if Buy_Yes_Sell_No
then (avg * .01) + (value * 3)
else (avg * .01) - (value * 3);
### Lines
def showLines = if AreYouIn
then (if secondstillTime(showAt) <= 0
and secondsFromTime(showat) <= thymeOffset * min
then 1 else 0)
else no;
plot downside2 = if showLines
then (if !Buy_Yes_Sell_No
then avg - (value*2)
else avg + (value*2))
else Double.NaN;
downside2.SetStyle(Curve.FIRM);
downside2.SetDefaultColor(Color.DARK_RED);
plot downside1 = if showLines
then (if !Buy_Yes_Sell_No
then avg - (value)
else avg + (value))
else Double.NaN;
downside1.SetStyle(Curve.SHORT_DASH);
downside1.SetDefaultColor(Color.RED);
plot avgprice = if showLines then avg else Double.NaN;
avgprice.SetStyle(Curve.SHORT_DASH);
avgprice.SetDefaultColor(Color.YELLOW);
plot upside1 = if showLines
then (if !Buy_Yes_Sell_No
then avg + (value)
else avg - (value))
else Double.NaN;
upside1.SetStyle(Curve.SHORT_DASH);
upside1.SetDefaultColor(Color.LIGHT_GREEN);
plot upside2 = if showLines
then (if !Buy_Yes_Sell_No
then avg + (value*2)
else avg - (value*2))
else Double.NaN;
upside2.SetStyle(Curve.SHORT_DASH);
upside2.SetDefaultColor(Color.LIGHT_GREEN);
plot upside3 = if showLines
then (if !Buy_Yes_Sell_No
then avg + (value*3)
else avg - (value*3))
else Double.NaN;
upside3.SetStyle(Curve.FIRM);
upside3.SetDefaultColor(Color.DARK_GREEN);
### Clouds
AddCloud((downside1+downside2)/2, downside2, Color.DARK_RED, Color.DARK_RED);
AddCloud(((upside1+upside3)/2), upside3, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud((downside1+downside2)/2, ((upside1+upside3)/2), Color.gray, Color.gray);
### Alerts
def SoundAlert = high crosses above upside2 or low crosses below downside1;
Alert(SoundAlert, "Something exciting just happened with " + GetSymbol(), Alert.BAR, Sound.Ring);
#AddLabel(AreYouIn,
# "[-" + AsPercent(value*2 / TargetPrice2) + "]" +
# ":" + AsDollars(targetprice01) +
# " [-" + AsPercent(value / targetprice01) + "]" +
# ":" + AsDollars(TargetPrice01),
# if avg <= 0
# then Color.BLACK
# else Color.LIGHT_RED);
#AddLabel(AreYouIn, "[" + AsPercent(value / TargetPrice1) + "]:" +
# AsDollars(TargetPrice1) + " " +
# "[" + AsPercent((value * 2) / TargetPrice2) + "]:" #+
# AsDollars(TargetPrice2) + " " +
# "[" + AsPercent((value * 3) / TargetPrice3) + "]:" +
# AsDollars(TargetPrice3) + " ",
# if avg <= 0
# then Color.BLACK
# else Color.LIGHT_GREEN);
Code:
# Crude Buy Sell Zone indicator by ANTHDKN 06.04.2021
# Free to use to all
# First posted on usethinkscript.com
# Auto entries from positions
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);
AddLabel(AreYouIn,
getquantity() +
"@" + avg +
"= $" +
(avg * getquantity()),
Color.WHITE);
AddLabel(AreYouIn,
if GetOpenPL() > 0
then "P/L: $" + GetOpenPL() + " [" +
aspercent(getopenPL() / (avg * getquantity())) + "]"
else "P/L: -$" + GetOpenPL() + " [" +
aspercent(getopenPL() / (avg * getquantity())) + "]",
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);
#AddLabel(AreYouIn,
# "[-" + AsPercent(value*2 / TargetPrice2) + "]" +
# ":" + AsDollars(targetprice01) +
# " [-" + AsPercent(value / targetprice01) + "]" +
# ":" + AsDollars(TargetPrice01),
# if avg <= 0
# then Color.BLACK
# else Color.LIGHT_RED);
#AddLabel(AreYouIn, "[" + AsPercent(value / TargetPrice1) + "]:" +
# AsDollars(TargetPrice1) + " " +
# "[" + AsPercent((value * 2) / TargetPrice2) + "]:" #+
# AsDollars(TargetPrice2) + " " +
# "[" + AsPercent((value * 3) / TargetPrice3) + "]:" +
# AsDollars(TargetPrice3) + " ",
# if avg <= 0
# then Color.BLACK
# else Color.LIGHT_GREEN);