Balazs Horvath 0 Posted Sunday at 05:26 PM Hi, I have an issue with the following script which comes from the DAS video series: CXL ALLSYMB;StopPrice = Price;Share=Price*100;Price=AvgCost;SShare=Price*100;Share=Share-SShare;Price=Share;Price=Share/100;Share=Pos * Price;Price=Ask-StopPrice;SShare=Share / Price;DefShare=BP*0.97;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;SShare=DefShare-SShare;Share=0.5*SShare;Price=Ask+0.05;TogSShare;TIF=DAY+;ROUTE=SMRTL;BUY=SEND;DefShare=10; TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+; It calculates the number of shares and risk perfectly fine, my only problem is with the set condition of capping the position size of 97% of the Buying Power. Actually I modified it to 60%, but when I use the script, every time my unrealized profit allows to buy more shares than the capping, the script doesn’t work properly as it ignores the cap and I end up having a much larger position than 60% of my buying power. It just ignores this cap. Has anyone experienced the same? Any solution for that? Share this post Link to post Share on other sites
peterB 325 Posted Monday at 07:27 AM (edited) it is 60% of the current BP so if you still have some BP on the 2nd key press it will use the 60% of the rest and add a true BP check for the first key press looks like this $myBP=5000; $want=$risk/$pricetostop; if ($myBP<=$want*LAST) { $amount=round($myBP*0.97/LAST,0)-1; } else { $amount=$want; } for the add it is more complicated for more modern hotkeys go here Edited Monday at 07:29 AM by peterB Share this post Link to post Share on other sites
Balazs Horvath 0 Posted Monday at 07:06 PM Thanks Peter but here it is what I dont understand: I reset my account size and BP to $60,000 (I used the DEMO version and in this case Replay mode) and set the cap to 0,99 both for my first long entry and the second adding entry (I use "Equalized Risk" script for going long (and short also) and the above mentioned "Adding to winning position" scripts, both from the DAS video series). Below are the screenshots of the result. After adding to my position I ended up having 562 shares at $164 which gives a $92,000 position which is a way above my BP ($60,000). How is it possible? I have to add that I have reset my account just before taking this test trade, so maybe I have to wait one day for DAS to process this new setup? (My previous BP was $100,000 by default) Sorry for bothering you with this staff, but it annoys me.... Thanks again for the previous answer, I will check out the links you have provided! Share this post Link to post Share on other sites