odayum 0 Posted June 20, 2021 Hey all, I'm trying to figure out how to script a hotkey in DAS for adding to or creating a new position that will buy or short a set number of shares and then set a stop loss for fixed amount calculated based on the overall position and average cost per share. For example I want to buy 100 shares and I want to set my stop to fixed amount say $100 dollars. The math for this seems pretty basic just (average cost- (risk amount/position)) but I can't seem to make that work in a hotkey script. I would also want the script to update the stop if I add to the position so for example for a $10 stock: the first time I hit the button it buys 100 shares at current ask then sets a stop to sell 100 shares at $9, then I hit it again (assuming the ask is still $10) it buys another 100 shares (now I have 200 shares) and sets the new stop loss (cancelling the old) to sell 200 shares at $9.50. and then will do that each time I mash the button so were I to hit it 10 times for a 1000 shares my new stop loss would be to sell 1000 shares at $9.90. Any help would be greatly appreciated!! Share this post Link to post Share on other sites