Buy one symbol on the same bar another symbol exits

Hello, I've been reading this forum, checking the documentation and trying many things, but I wan't able to find an answer. Could you please help me with this problem or point me to the solution if I missed it?

Let's say I trade only 2 symbols: UPRO and SPXU.
Let's say my algorithm finds the best moment to buy UPRO and then sells it (with a variable trailing stop)
How can I do to trigger a "buy" on SPXU the same day that UPRO just exited?
My 2 symbols are in a Watchlist that I backtest with "apply to *Filter".
I tried many solutions (using Foreign, SetForeign, Equity(1), calculating the trail stop myself, etc...) but with not luck. I think my main problem is that I cannot access the Sell array from UPRO, while the "current" symbol is SPXU.

Many thanks in advance!

Have you read through this post? You can get some ideas including the 3rd method of using a CBT.
You can get all the Signals from the Signal object for each bar.

1 Like

Many thanks Travick!

It's really appreciated!

Thanks to your help I figured out that I could calculate all my enter and exit signals (for both UPRO and SPXU) from the underlying Index. (SP500).

1 Like