For example, let's assume that the strategy is running on hourly bars. It purchases one contract at 1:00, a second contract at 2:00 and a third contract at 3:00. I'd like to close each position after that position has been open for five hours -- i.e., it would sell one contract at 6:00, a second contract at 7:00 and a third contract at 8:00.
I currently have the following code for my entry and exit. The exit is based on the "TimeExit (Bars) LE" signal:
Code: Select all
If Time >= EnterStart AND Time < EnterEnd then begin
Buy 1 contract next bar at Close Limit;
end;
If BarsSinceEntry = BarToExitOn then begin
Sell 1 contract next bar at market;
end;
Is there any way to achieve this? Thanks in advance for any pointers.