| Kevin_in_GA 4,599 posts
 msg #126329
 - Ignore Kevin_in_GA
 | 11/26/2015 11:40:17 AM 
 Some code for managing amounts at risk:
 
 /*DETERMINE THE MAXIMUM AMOUNT YOU ARE WILLING TO LOSE*/
 SET{ACCOUNTSIZE, 25000}
 SET{RISKLEVEL, ACCOUNTSIZE * 0.01}
 
 Here I have set up the code to put only 1% of your trading equity at risk on any given trade, which in this example is only $250. All you need to do is set your account size at whatever the amount is that you can currently trade using this system.
 
 /* VAN THARP POSITION SIZING - SET THE STOP LOSS AND SHARE SIZE BASED ON LIMIT ENTRY AND AMOUNT WILLING TO LOSE*/
 SET{ENTRYPRICE, xxx}
 SET{2ATR, 2 * ATR(20)}
 SET{STOPLOSS, ENTRYPRICE - 2ATR}
 
 Once you have decided where your entry will be I use twice the value of the ATR(20) as the point for positioning the stop loss. Just a simple subtraction of this amount from the entry price - this should give the stock enough room to fluctuate normally without triggering the stop loss.
 
 /*DETERMINE THE NUMBER OF SHARES TO BE PURCHASED*/
 SET{SHARESTOBUY1, RISKLEVEL/2ATR}
 SET{SHARESTOBUY, ROUND(SHARESTOBUY1, 0)}
 
 Just a quick comment here - SF code does not let you do more than 1 mathematical operation in any given SET{} statement. Here I have determined the required number of shares, then used the ROUND() function to make the output a whole number for ease in placing orders. When I place my orders I usually round to the nearest 5 shares since that is easier to actually get an order filled - odd amounts like 17 are harder to get filled than 15 or 20 shares.
 
 /*TOTAL AMOUNT OF EQUITY USED IN THIS TRADE*/
 SET{POSITIONAMT, LIMITENTRY * SHARESTOBUY}
 
 /*PERCENT OF TRADING CAPITAL USED IN THIS TRADE*/
 SET{POSITIONPCT1, POSITIONAMT / ACCOUNTSIZE}
 SET{POSITIONPCT, POSITIONPCT1 * 100}
 
 
 
 |