I apologize that my explanation was not clear enough. The idea behind this data is that I have obtained lots of buy signals using a certain formula to buy a certain stock. However, I want a delay in when the actual (3rd column) buy signal is generated; this needs to occur when there are 3 consecutive buy signals. The generated new BUY signal is the starting points of the SELL signal. I want to buy the stock at time T and sell it after a fixed time of 4 periods. So I buy the stock and 4 periods later I sell it.
Basically;
1) Three consecutive 'buy' signals (1, 2, 3) (2nd column) produce a 'BUY' signal (3) (3rd column).
2) If a 'BUY' signal is produced in the 3rd column, a SELL signal is generated after 4 periods.
3) All signals between BUY and SELL in the 3rd column are ignored.
4) If it happens that a BUY and SELL signal in the 3rd column are generated in the same place, the SELL signals 'wins' (since I want to buy the stock, hold it, and sell it 4 periods later).
5) There can never be two BUY signals or two SELL signals after each other in the third column. After a BUY 4 periods later is a SELL. But after a SELL there can directly be a BUY, or after 1 period, or 2 periods, or more etc. , that depends on whether there are 3 consecutive buy signals in the 2nd column.
With point (3) above I mean the following. In the example below no BUY signal is generated at, for example at period 5, because although there are indeed three consecutive buy signals (3, 4, 5), there was already a buy signal triggered earlier and a sell signal 4 period later, and hence all signals in between are ignored. The same applies to why a buy signal in the third column at 6 does not work; there are indeed three consecutive buy signals in column 2 (4, 5, 6), but there was a buy signal earlier and I haven't closed that trade yet (I hold it and sell it after 4 periods). The second BUY signal (8) is correct and should be generated because there were 3 consecutive buy signals in the 2nd column (marked in red), and there is no issue with conflicting signals since the last signal was a SELL and because after a stock is bought and sold, the next trade can take place. So, after each BUY and SELL in the 3rd column, it starts again with the question whether there are 3 consecutive buy signals.
This follows the same reasoning as the previous example.
In the example below, you would also expect a BUY signal at (7). However, the SELL signal has priority since the stock needs to be sold first (I only allow 1 trade performed at the same time, no multiple ongoing/open positions).
I hope that the rules are clear! You're helping me a lot with this, I really appreciate your help
Basically;
1) Three consecutive 'buy' signals (1, 2, 3) (2nd column) produce a 'BUY' signal (3) (3rd column).
2) If a 'BUY' signal is produced in the 3rd column, a SELL signal is generated after 4 periods.
3) All signals between BUY and SELL in the 3rd column are ignored.
4) If it happens that a BUY and SELL signal in the 3rd column are generated in the same place, the SELL signals 'wins' (since I want to buy the stock, hold it, and sell it 4 periods later).
5) There can never be two BUY signals or two SELL signals after each other in the third column. After a BUY 4 periods later is a SELL. But after a SELL there can directly be a BUY, or after 1 period, or 2 periods, or more etc. , that depends on whether there are 3 consecutive buy signals in the 2nd column.
1. | BUY | |
2. | BUY | |
3. | BUY | BUY |
4. | ||
5. | ||
6. | ||
7. | SELL | |
8. | ||
9. |
1. | BUY | |
2. | BUY | |
3. | BUY | BUY |
4. | BUY | |
5. | BUY | |
6. | BUY | |
7. | BUY | SELL |
8. | BUY | BUY |
9. | ||
10. | ||
11. | ||
12. | SELL |
1. | BUY | |
2. | BUY | |
3. | BUY | BUY |
4. | BUY | |
5. | ||
6. | BUY | |
7. | BUY | SELL |
8. | BUY | BUY |
9. | ||
10. | ||
11. | ||
12. | SELL |
1. | BUY | |
2. | BUY | |
3. | BUY | BUY |
4. | ||
5. | BUY | |
6. | BUY | |
7. | BUY | SELL |
8. | ||

Comment