ToS Trade Button script?

richardm

New member
VIP
Not sure where to post this.

I've put together something that approximately zero people have asked for. It's a PowerShell script that brute forces the layout of every set of trade buttons defined in your ToS workspace XML (mine has 38). I got tired of constantly fixing a bunch of stupid buttons every time I modified my ToS layout.

I've run this with ToS open -- no need to shut it down and restart. Just re-open the workspace layout and ToS will ingest your modifications from the XML file.

Ruby:
# Your workspace XML file - MAKE A BACKUP COPY BEFORE YOU MESS WITH ANYTHING
# This process has had minimal testing.
$ToSXmlFile = "workspace.STONKS.xml"

# Your desired buttons in the order you want them to appear.
# These button names are not documented anywhere(?).
# Adding a new button to this list will require adding it manually within
# ToS, saving the workspace, then inspecting the XML file
# to learn the correct button names.
$NewButtons = '"FIRST_LINE;QUANTITY;BUY_BID;BUY_MKT;FLAT;MULTI_CANCEL;SELL_MKT;SELL_ASK;POSITION;WORKING_ORDERS;SECOND_LINE;TIF;ORDER_TEMPLATE;ORDER_SETUP"'

# PowerShell magic gnomes understand XML
$xml = New-Object XML
$xml.Load($ToSXmlFile)

# This uses XPath syntax to search the entire XML for TRADE_BUTTONS attributes.
# Every successful hit becomes an element added to the $OldButtons array.
$OldButtons = ($Xml.SelectNodes('//@TRADE_BUTTONS'))

# This steps through each element in the $OldButtons array overwriting whatever's
# in the Value property.  New buttons go brrr.
$OldButtons | foreach { $_.Value = 'TRADE_BUTTONS='+$NewButtons }

# Write it out.
# FYI The Out-Xml cmdlet munches XML formatting - the Save() method does not.
$Xml.Save($ToSXmlFile)

This is crappy code but I want it simple and easy to understand.
"If it's not simple; simply not"

Anyone else hacking their ToS XML file? I'm surprised nobody's talking about this -- I think there might be some low-hanging fruit in there when it comes to scriptable conveniences.
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not sure where to post this.

I've put together something that approximately zero people have asked for. It's a PowerShell script that brute forces the layout of every set of trade buttons defined in your ToS workspace XML (mine has 38). I got tired of constantly fixing a bunch of stupid buttons every time I modified my ToS layout.

I've run this with ToS open -- no need to shut it down and restart. Just re-open the workspace layout and ToS will ingest your modifications from the XML file.

Ruby:
# Your workspace XML file - MAKE A BACKUP COPY BEFORE YOU MESS WITH ANYTHING
# This process has had minimal testing.
$ToSXmlFile = "workspace.STONKS.xml"

# Your desired buttons in the order you want them to appear.
# These button names are not documented anywhere(?).
# Adding a new button to this list will require adding it manually within
# ToS, saving the workspace, then inspecting the XML file
# to learn the correct button names.
$NewButtons = '"FIRST_LINE;QUANTITY;BUY_BID;BUY_MKT;FLAT;MULTI_CANCEL;SELL_MKT;SELL_ASK;POSITION;WORKING_ORDERS;SECOND_LINE;TIF;ORDER_TEMPLATE;ORDER_SETUP"'

# PowerShell magic gnomes understand XML
$xml = New-Object XML
$xml.Load($ToSXmlFile)

# This uses XPath syntax to search the entire XML for TRADE_BUTTONS attributes.
# Every successful hit becomes an element added to the $OldButtons array.
$OldButtons = ($Xml.SelectNodes('//@TRADE_BUTTONS'))

# This steps through each element in the $OldButtons array overwriting whatever's
# in the Value property.  New buttons go brrr.
$OldButtons | foreach { $_.Value = 'TRADE_BUTTONS='+$NewButtons }

# Write it out.
# FYI The Out-Xml cmdlet munches XML formatting - the Save() method does not.
$Xml.Save($ToSXmlFile)

This is crappy code but I want it simple and easy to understand.
"If it's not simple; simply not"

Anyone else hacking their ToS XML file? I'm surprised nobody's talking about this -- I think there might be some low-hanging fruit in there when it comes to scriptable conveniences.

Have you tried just saving a grid template or flexible grid template instead? That should save the button order, as opposed to a chart style which only saves the chart data.

This is what I've done, so each time I need a new chart grid or flexible grid I just start with the template, which arranges the active trader buttons, etc. It also checks or un-checks the "auto send" option in case you want to use chart trading without having to click "confirm" every time.
 
Have you tried just saving a grid template or flexible grid template instead? That should save the button order, as opposed to a chart style which only saves the chart data.

This is what I've done, so each time I need a new chart grid or flexible grid I just start with the template, which arranges the active trader buttons, etc. It also checks or un-checks the "auto send" option in case you want to use chart trading without having to click "confirm" every time.

Acktually... I'm running ToS on Linux with a multi-monitor setup. Loading/saving chart grids tickle an upstream Java bug that's been lingering for close to a decade. Something along the lines of "Can't connect to X11 window server using '0:0' as the value of the display" then ToS (or more specifically the underlying java process) has to be killed.

Only workaround I've found is shutting down all but the primary display before doing anything with chart grids. Come to think of it... I could install a copy of ToS in a virtual machine for this.🤔
 
Acktually... I'm running ToS on Linux with a multi-monitor setup. Loading/saving chart grids tickle an upstream Java bug that's been lingering for close to a decade. Something along the lines of "Can't connect to X11 window server using '0:0' as the value of the display" then ToS (or more specifically the underlying java process) has to be killed.

Only workaround I've found is shutting down all but the primary display before doing anything with chart grids. Come to think of it... I could install a copy of ToS in a virtual machine for this.🤔

Ugh. Sounds like an unfixable problem unless you go the VM route, or just buy a Windows PC. Best of luck.
 
Have you tried just saving a grid template or flexible grid template instead? That should save the button order, as opposed to a chart style which only saves the chart data.

This is what I've done, so each time I need a new chart grid or flexible grid I just start with the template, which arranges the active trader buttons, etc. It also checks or un-checks the "auto send" option in case you want to use chart trading without having to click "confirm" every time.
Interesting post! Thank you for sharing.
How did you create a flexible grid template?
Thanks
 
Just "Save Flexible Grid As". It will save your charts, studies, symbols, Active Trader configuration... everything. And, if you happen to accidentally close the window, just open any new flexible grid, then click the template you saved and it's back.

You can save a "template" version that's just a version configured with you button layout, etc. the way you want it. It doesn't have to contain studies, etc., but I find it helpful for all of the above.

1687523637168.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
256 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top