Re: [R] Producing a SMA signal when closing price is above the moving average for 3 days

2012-09-04 Thread William Dunlap
You could think of your problem as one of combining a signal that tells when the state of the system should change to (or remain at) on and a signal that tells when it should change to off to come up with a series giving the state at each time point. E.g., OnOrOff - function(toOn, toOff, wasOn){

[R] Producing a SMA signal when closing price is above the moving average for 3 days

2012-09-03 Thread Douglas Karabasz
I have loaded price data for GE and then calculated a 50 day simple moving average. Then I have a created a ifelse statement that produce a 1 when GE's closing price is above the simple moving average and a 0 when GE Closing price is below the 50 day simple moving average. However, what I