Hi, I would like the backtest a trading strategy but I’m not sure how to do it.
The strategy is the following;
Bull:
- Stock has to be above previous day close at least +2% (already have code for this)
- stock then has to fall at least 1%, this is counted from candle high to low instead of close
- position is opened once stock regains half of it’s previous fall.
- This whole process has to happen in under 2 hours, typically it happens in under 30 minutes so 5 minute timeframe will be used, but since PRT only opens a position on the close of candle, maybe 1 minute timeframe would work better.
Bear:
- Stock has to be below previous day close at least -2%(already have code for this)
- stock then has to rise at least 1%, this is counted from candle low to high instead close.
- position is opened when stock falls to half of the previous rise
- This process also has the same 2 hour time limit.
Written Example;
Bull:
- Stock is up +2% on close, price is 100 at 9:00 am
- Stock price then falls very fast too 98.5 at 9:15am (over 1% fall)
- Stock price then rises too 99.25 at 9:30am.
- As soon as price reaches 99.25, position is opened.
- Process started at 9:00 a,m and finished at 9:30am which is under the 2 hour time limit.
Attached are some labelled pictures of charts where this happens.
Hope I made this clear enough, thanks in advance.