♥ 0 |
Hi Pete Hahn,
Once again, great site, videos and overall content!! I have a question.
I have created a script (or, to put it mildly, copied and cobbled a script together using your help!) that does Dollar Cost Average over the time frame selected, shown below:
input tradeSize = 0; def exit = GetYYYYMMDD() > endDate; AddOrder(OrderType.BUY_TO_OPEN, signal, open[-1], round(dollar/open,0), Color.CYAN, Color.CYAN); AddOrder (orderType.BUY_TO_OPEN,signal,open[-1],tradesize,color.cyan,color.cyan); AddOrder(OrderType.SELL_TO_CLOSE, exit, open[-1], tradeSize, Color.MAGENTA, Color.MAGENTA);
I can choose for one of two things:
It then sells all my positions at the specified end date.
I am looking for help with two things:
2. Lets say I wanted to set up a strategy, that bought stock every time a signal occurred (for example, RSI was overbought) and wanted to compare this to the DCA strategy. To try to explain better.
DCA RSI 1 $100 2 $100 3 $100 $300 4 $100 5 $100 6 $100 7 $100 8 $100 $500 9 $100 $100 10 $100 11 $100 12 $100
Hopefully, it shows what I mean. DCA has a signal once a month, with $100 worth of stock being bought. RSI has a signal sporadically, but in the above example, the signal to buy occurs in month 3, 8 and 9. Therefore I wold want in month 3 to buy $300 worth of shares (as 3 months x $100) and in month 8 to buy $500 (as from month 3 to month 8 = 5 months = $500). So rather than buying stock every month, you save the same amount and buy whenever the signal occure.
(I hope I explained this!!)
Marked as spam
|