[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Open position, scaling out



PureBytes Links

Trading Reference Links

Hello,

I'd like to do open a position @ the same time and then close it in
pieces 1, 2, and 3 months later.

I'm doing something like:

if (entry condition) then begin
    Buy("1m") next bar at market;
    Buy("2m") next bar at market;
    Buy("3m") next bar at market;
end;

if MarketPosition = 1 then begin
    if BarsSinceEntry >= 20 then begin
        Sell("1mX" ) from entry ("1m") next bar at market;
    end;
    if BarsSinceEntry >= 40 then begin
        Sell("2mX" ) from entry ("2m") next bar at market;
    end;
    if BarsSinceEntry >= 60 then begin
        Sell("3mX" ) from entry ("3m") next bar at market;
    end;
end;


The problem appears to be that I can't distinguish BarsSinceEntry for
a given entry (e.g. "1m", "2m", "3m") so that if <entry condition>
becomes true after I'm out of "1m" and I get back in, I immediately
exit.

Do I need to track my entries myself or am I missing something?

Thanks in advance for suggestions.

Regards,
Brendan