MCreek
New member
In the art of giving back for all I have gained on this site I've been working on a position monitoring and pice target tool that shows trade information, cost, profit/loss, number of shares, long, short, etc. and price targets. I began testing this before the TDA and Schwab merger. There was some bugs in it after the merger but I think I have them worked out. It was ogrinally coded to only display whenyou opened a position on a stock, but following the merger it became problematic and wouldn't always display. I fixed it to remain on your chart as a label. It's a pretty straightforward tool to keep track of your positions and price targets. You can set your price target in the label settings, as well as change the background color of the main label. I added a few default tagerts by percent. {default "5%", "7%", "10%", "12%", "20%", "25%"}; just as a starting point bt you can easily change the hard code as you like.
You open a position and the secondary target label automatically calculates the sale price based on your entry price. The seconday label remains yellow until you reach your target and them turns green and also sends an audible alert.
I've purposely used in on winning and loosing trades and put it through the paces. I think it's a great tool. At least for me it is. I can see at a glance how my trade is doing.
(don't include in the code stamsp script)
Happy Trading!! GLTA!!
You open a position and the secondary target label automatically calculates the sale price based on your entry price. The seconday label remains yellow until you reach your target and them turns green and also sends an audible alert.
I've purposely used in on winning and loosing trades and put it through the paces. I think it's a great tool. At least for me it is. I can see at a glance how my trade is doing.
Code:
(don't include in the code stamsp script)
def qty = GetQuantity();
def avePrice = if qty != 0 then GetAveragePrice() else 0;
def openCost = qty * avePrice;
def netliq = qty * close;
def PL = netliq - openCost;
def price = close(priceType = PriceType.LAST);
#
input Label_Color_Choice = {"magneta", "cyan", default
"pink", "light.grey", "orange", "red", "light.green", "grey", "limelight", "white"};
#
#Add the label with position and P/L information
AddLabel(yes, (if qty > 0 then "Long " else if qty < 0 then "Short " else "No Position ") + AbsValue(qty) +
" Shares Cost $" + openCost + " AvgPrice " + avePrice +
" P/L $" + PL + " = " + (if openCost != 0 then AsPercent(PL / openCost) else "0%"),
GetColor(Label_Color_Choice));
#Input to select the target percentage
input targetPercentage = {default "5%", "7%", "10%", "12%", "20%", "25%"};
#Calculate the target price based on the selected percentage
def targetPrice = avePrice * (1 + (if targetPercentage == targetPercentage."5%" then 0.05 else
if targetPercentage == targetPercentage."7%" then 0.07 else
if targetPercentage == targetPercentage."10%" then 0.10 else
if targetPercentage == targetPercentage."12%" then 0.12 else
if targetPercentage == targetPercentage."20%" then 0.20 else
if targetPercentage == targetPercentage."25%" then 0.25 else 0));
# Define the condition for reaching the target price
def targetReached = close >= targetPrice;
# Add the label with conditional color
AddLabel(yes, "TargetPrice $" + targetPrice, if targetReached then Color.GREEN else Color.YELLOW);
# Add audible alert when target price is reached
Alert(targetReached, "Target Price Reached!", Alert.BAR, Sound.Chimes);
Happy Trading!! GLTA!!