I came up with what I thought was a simple signal to close a position when the open profit of the entire portfolio passes a certain level, but when I apply the signal to my portfolio strategy it never triggers during backtesting. It triggers fine when I use a different exit condition, so I'm guessing the problem is with the Portfolio_OpenPositionProfit function. Can it not be used in backtesting? Does it only return values in real-time trading? Is there a backtest-friendly alternative? TIA
Code: Select all
[IntrabarOrderGeneration = false]
inputs: TP (100), SL (-100);
condition1 = Portfolio_OpenPositionProfit crosses over TP or Portfolio_OpenPositionProfit crosses under SL;
condition2 = marketposition > 0;
condition3 = marketposition < 0;
If condition1 and condition2 then
Sell ("LX") next bar at market;
If condition1 and condition3 then
BuyToCover ("SX") next bar at market;