Adding a filter in the portfolio equity curve

Hello,
I am exploring the strategies and AFLs to find out different ways to improve.
I was curious if there's any way to add a filter at the backtest level so that the trades will not happen if a particular condition is met.
Just like, if someone just trades on SP500 and puts a condition that sell everything when it closes below EMA 50D at the month end and buy again when it closes above EMA 50D.
The same way if the backtest equity curve closes below its EMA 50D, it will sell everything but keep considering the stocks (but not trade) so that the equity curve goes above EMA 50D at month end, it will buy and keep going.

Can any one please provide any pointers here?
Thanks in advance !!

Exactly this is explained in the Knowledge Base:

I would do the backtest , save the equity, and then use the equity saved (as referenced by Tomasz) as a filter in a second bactest

Thanks for the reference, in the article, it is referencing the GSPC, but how would reference the equity curve created by the backtest itself? Basically my portfolio is my index and I want to create a filter (like I mentioned for SP500) during the backtest itself.

In the reference, it is using the GSPC as the ticker but how would you filter through the equity curve itself which was created by backtest?

first you create a copy of the equity...

1 Like