This is brilliant. I am going to define my hotkeys using your script template and try it in my simulator (this is my 2nd week in the simulator).
I think there is one caveat of the script which I describe below. Please correct me if I am wrong.
When calculating the number of shares one could afford with current account buying power:(e.g. DefSahre = BP*0.98), your script would be using the "stop loss" price instead of actual bid/ask price. This difference would lead to not having enough buying power when going for a long position with current account buying power. I guess you must have realized that and hence set 98% of total buying power as default. I could not think of an easy way to deal with this issue as we do need the stop loss price in the calculation. But I think this could be listed as "know issues" of the script to warn potential users.
(Additional note: DefSahre = BP*0.98: This was confusing to me at first: how could buying power ($) multiple 0.98 is equal to share number?. After I checked the Dastrader manual and realized that it was actually calculating BP*0.98/Price. This was really Dastrader's fault. I share this here in case other users had the same confusion.)