Hello guys, I would like to reprocess the equity line resulting from a WFA with three parameters: Par1, Par2, Par3.
The system I'm testing opens up to 4 positions simultaneously, (backtestRegularRawMulti) with a logic like: buy = indicator < threshold;
For each entry signal, the corresponding exit signal is determined by the first to occur among the following 3 conditions:
- time exit (applyStop(stopTypeExit, StopModeBars, Par1)
- take profit (applyStop(stopTypeProfit, StopModePercent, Par2)
- logic Exit (Cross(C, MA(C, Par3))
Now:
When I perform a WFA, trades eventually opened at the end of the period are closed. If I use the Flip(Buy, Sell) function to convert buy signals from pulse to state (as described in another post), since the system is backtest raw multi, more trades are opened than necessary, which is not desirable.
One possible solution I'm considering might be to derive the buy signals from the report:
- report explore -> report -> trades -> copy table
- save the table as CSV
- load the CSV into a matrix
- extract the "date" column and generate buy signals from that
and calculate exit signals normally, but this is also not ideal because the parameters that determine the exit rules change during the WFA process.
So, it would be necessary to export the WFA report to a CSV file (using the batch function) and then derive the dates and parameter values from that file and then associate them in some vectors to use as parameters for calculating exit conditions.
But I still encounter a problem that I'm not sure if I can solve with CBT:
When a trade goes to market, I want the set of parameters (Par1, Par2, and Par3) associated with that trade to remain valid until its closure, regardless of whether in the meantime the WFA has found a new set. The new set will only be valid for new trades.
For example,
if when the market trade has a closing condition: cross with MA(C, 10) and holding period 7 days, and it remains open after a WFA update whose new parameters are MAperiod = 5 and holding = 3, I don't want it to be closed after 3 days or at the crossing of the MA 5.
I have studied the CBT documentation and understood that the signal generation phase occurs in phase 1, before the part where I can interact with the CBT. I would need to be able to assign extra attributes to the trade so that I can recall them somehow later during the backtest. Is it possible in any way with CBT?
Do you have any advice on how I could simulate this system correctly?