Announcement

Collapse
No announcement yet.

All in All Out Lot Size - Buying & Selling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • All in All Out Lot Size - Buying & Selling

    I am running a Back Test on the S&P 500 index and I have my buy/sell indicators working right. However, I'm noticing a problem with how many shares are bought and sold.
    I think that when you are entering your information for the
    ...then the following will happen everytime:
    and using the formula: "doLong()" the "lotSize" is what I need to alter. I currently have "Strategy.DEFAULT" selected for the buy signal, and "Strategy.ALL" for the sell signal. How do I change the "lotSize" to the current portfolio/capital value divided by the share price when a buy is signaled? For example, if the closing price is $933.41, and the portfolio has $100,000.00, then purchase 107 shares (round down to nearest share). For the next buy signal, the portfolio has $113,837.38 and the price is $1,128.55, then purchase 92 shares.

    Issue:
    When the formula indicates a buy, purchase as many shares as possible without using margin (i.e. cash only). When a sell is indicated, sell all shares currently held.

    Solutions?
    This would be were someone would help
    Shawn Peters
    IT Guy
    Christian Financial Association
Working...
X