Hi to all,
I need to code an ea with these conditions:
I need to code an ea with these conditions:
- Enter a long position at the close of each day whenever the closing price is higher than any close in the previous 8-days and the 50-day SMA is also above the 100-day SMA. Set a stop-loss at the 8-day low.
- Enter a short position at the close of each day whenever the closing price is lower than any close in the previous 8-days and the 50-day SMA is also below the 100-day SMA. Set a stop-loss at the 8-day high.
- A long position will be exited after 22-days or if it is stopped out. However, all long positions will be exited prior to their 22-day time-based exit should the price close lower than it has ever closed in the previous 8-days or if the 50-day SMA closes below the 100-day SMA.
- A short position will be exited after 22-days or if it is stopped out. However, ALL short positions will be exited prior to their 22-day time-based exit should the price close higher than it has ever closed in the previous 8-days or if the 50-day SMA closes above the 100-day SMA.
How can I code the exit on 22 days old positions? How can I do that with more than one position at a time? It is possible to build an indicator to perform this task? It is possible to do this with molanis sb and cib?
tnx and regards