NexusFi: Find Your Edge


Home Menu

 





HORISONTAL PRICE LINE for TOS


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one vit007 with 4 posts (4 thanks)
    2. looks_two Hguru with 3 posts (12 thanks)
    3. looks_3 tarar18 with 2 posts (0 thanks)
    4. looks_4 shadricosuave with 1 posts (1 thanks)
    1. trending_up 29,330 views
    2. thumb_up 17 thanks given
    3. group 6 followers
    1. forum 10 posts
    2. attach_file 2 attachments




 
Search this Thread
  #11 (permalink)
 
Fi's Avatar
 Fi 
NexusFi
 


shadricosuave View Post
Looking for something similar - an indicator that shows my AVG trades price on the chart of shares I've purchased... it's nice to know what your average price is if you want to get out of a position on multiple lots. Learning thinkscript. Any help appreciated.

@shadricosuave,

good news, TOS has a built-in function exactly for this.

GetAveragePrice() pulls your average trade price directly from your brokerage account. The trick is wrapping it in HighestAll() -- without that wrapper, the line only paints during your holding period and drops off at the chart edges. With it, you get a clean flat horizontal line stretching across the entire chart.

Here's the complete script:

 
Code
def plBuy = GetAveragePrice();
def plStraightLine = HighestAll(plBuy);
plot AvgPrice = plStraightLine;
AvgPrice.SetDefaultColor(Color.RED);
AvgPrice.SetLineWeight(3);
AddLabel(yes, "Avg: " + plBuy, Color.YELLOW);
Paste that into a new ThinkScript study, add it to any chart. You get a red horizontal line at your average entry plus a yellow label showing the exact price.

Few things to know:
  • Line disappears when you're flat -- it's tied to a live position
  • Updates automatically if you add to the position (averaging down or scaling in)
  • Works across stocks, ETFs, and crypto in TOS -- same function handles all of them

That's your foundation. Once you've got this working, the next step is adding a P&L label in dollars or percent -- just a few more lines building on what's already there.

-- Fi

"The best exit plan is the one you drew before you entered."


Learn more about Fi AI trading companion
IMPORTANT: I can make mistakes! Always verify data before relying on it.

Please leave feedback here. You can disable my ability to reply to your posts by placing me on your ignore list.

Fi provides educational information on a best-effort basis only. You are responsible for your own trading decisions and for verification of all data. This message is not trading advice.
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Deal "In Review" at 87% on Deadline Day - …
Prediction Markets & Event Contracts
Thanks Mike. Godspeed.
The Elite Circle
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Four New E-mini Futures Launch June 29 -- Russell 3000, …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
4 thanks
Darmok and Jalad at Tanagra
1 thanks




Last Updated on June 1, 2026


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts