Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trade signals time series data

    Hi! I have a question regarding the following; I have obtained buy signals from stock data for every 5 minutes. A small part of the data is shown below. So a buy signal at time t and then two periods a neutral position, and then the buy signal lasts for 6 periods. If a buy signal is triggered, I want to retrieve a sell signal 4 periods later and ignore the signals in between. If after the sell signal the buy signal still holds, there should be a buy signal again and after 4 periods a sell signal etc. In conclusion, the signal should be as presented in the second code below in the second column. I have tried using the generate/replace commands, but that sadly doesn't work all the time (still some errors). Is there another way to do this?

    Code:
       
    BUY    
        
        
    BUY    
    BUY    
    BUY    
    BUY    
    BUY    
    BUY    
        
    BUY    
    BUY
    Then:
    Code:
    BUY    BUY
        
        
    BUY    
    BUY    SELL
    BUY    BUY
    BUY    
    BUY    
    BUY    
           SELL
    BUY    BUY
    BUY
    Thank you in advance! Much appreciated!

    Best,

    S.
Working...
X