Join useThinkScript to post your question to a community of 21,000+ developers and traders.
The syntax is correct. Without what chart, symbol, time aggregation, etc. It is not possible to determine where you went astray.I'd like to use the following on a Forex chart (e.g., EUR/USD, or NZD/USD, etc.) But it's not working. Is there another way to get Quantity with Forex symbols?
Code:def qty = GetQuantity(); AddLabel(yes, "Qty: " + qty, color.CYAN);
I moved your post to this thread because there are 4 pages describing the various ways to plot THE CURRENT ACTIVE TRADES IN YOUR PORTFOLIO.What I am looking to achieve is to plot a green arrow pointing up on the chart at the price I bought into the trade. No details about the number of shares or time or anything else. Just the arrow up at my entry on the chart, and when I sell I want to plot a red arrow pointing down at the price I sold. Think about it as the TOS price bubble/ pill but without any number of shares or price, just the red or green arrow.
Is this possible to code?
def x = GetQuantity();
plot start = x[1] == 0 and x <> 0;
start.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
start.setdefaultcolor(color.cyan);
plot end = x[1] <> 0 and x == 0;
end.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
end.setdefaultcolor(color.magenta);
OMGOODNESS!@Jony Giant @MerryDay . . . maybe this? I believe I read once that portfolio functions are limited to one year of data (please don't quote me on that) so not certain how far back in time this code will show. It appears to work for recent trades.
You absolute LEGEND. This is exactly what I was looking for!! This should definitely be integrated in TOS by default. THANK YOU!@Jony Giant @MerryDay . . . maybe this? I believe I read once that portfolio functions are limited to one year of data (please don't quote me on that) so not certain how far back in time this code will show. It appears to work for recent trades.
Code:def x = GetQuantity(); plot start = x[1] == 0 and x <> 0; start.setpaintingstrategy(paintingstrategy.boolean_arrow_up); start.setdefaultcolor(color.cyan); plot end = x[1] <> 0 and x == 0; end.setpaintingstrategy(paintingstrategy.boolean_arrow_down); end.setdefaultcolor(color.magenta);
@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -You absolute LEGEND. This is exactly what I was looking for!! This should definitely be integrated in TOS by default. THANK YOU!
PS: It looks like it plots the arrows when I open the position and when I close it, but it doesn't plot anything if I add more shares after the trade is open. Is still a huge leap though! Thank you!
plot add = x > 0 and x > x[1];
add.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
add.setdefaultcolor(color.white);
plot subtract = x > 0 and x < x[1];
subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
subtract.setdefaultcolor(color.gray);
THANK YOU! You are a LEGEND! exactly what I was looking for.@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -
Code:plot add = x > 0 and x > x[1]; add.setpaintingstrategy(paintingstrategy.boolean_arrow_up); add.setdefaultcolor(color.white); plot subtract = x > 0 and x < x[1]; subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down); subtract.setdefaultcolor(color.gray);
plot Data = close;
segment of code in each new study that is created. Just delete that line of code before pasting in the code you actually want.Same problem... cyan box shows with "Entry:0" in it ...i have a trade.on ... nothing else shows@Kylep19 - The lines will only show on the chart when you enter a trade, but there should be a cyan colored label showing in the upper left corner of your chart.
Here ya go:I tend to do single trades with 100% of my account funds. ToS knows how much money is in my account at any time. I'd like to focus on the price of the equity I'm buying and let the system calculate how many shares I can buy with the money in my account. But I've never heard of a broker doing that for a client. Is it possible somehow? I waste a lot of time pecking at my calculator program to figure out how many shares I can buy as the price is flying around. I'm buying volatile equities where the price ramps up and down a lot.
def SBP = GetTotalCash () ;
AddLabel(yes,
" Total Cash = " + SBP +
" You can buy: " + roundDown(SBP/close,0) +" shares", Color.blue);
Thanks for your code, it helps a lot! Also I'm wondering if there is a way to make the arrow placed right at the price level we traded in and out? Right now they are placed either on the top of the candle or below, hard to tell the accurate price especially on a long candle.@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -
Code:plot add = x > 0 and x > x[1]; add.setpaintingstrategy(paintingstrategy.boolean_arrow_up); add.setdefaultcolor(color.white); plot subtract = x > 0 and x < x[1]; subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down); subtract.setdefaultcolor(color.gray);
That is not possible. ToS doesn't provide us any portfolio information other than a P/L YTD.Thanks for your code, it helps a lot! Also I'm wondering if there is a way to make the arrow placed right at the price level we traded in and out? Right now they are placed either on the top of the candle or below, hard to tell the accurate price especially on a long candle.
def Trades = Fundamental(FundamentalType.TICK_COUNT);
def newDay1 = GetDay() <> GetDay()[1];
rec todaystrades = if newDay1 then trades else todaystrades[1] + trades;
AddLabel(yes,(todaystrades), (if todaystrades > 100 then Color.whITE else Color.BLACK));
plot data=todaystrades;
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Short/Long Entry Line on Chart for ThinkorSwim | Indicators | 3 | ||
Bullish Market Entry Point for ThinkorSwim | Indicators | 36 | ||
N | Entries and Target For ThinkOrSwim | Indicators | 8 | |
Darvas Box with Target Levels for ThinkorSwim (Scalping Strategy) | Indicators | 19 | ||
Take Profit Indicator for ThinkorSwim | Indicators | 1 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.