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

Re: Buying without selling



PureBytes Links

Trading Reference Links

In-Reply-To: <200110162204.f9GM4DK89022@xxxxxxxxxxxxxxx>
Ah! A most intriguing idea which I have implemented and which works better 
than my original code (although not as well as running the two systems 
concurrently).

Thank you.

Cheers,
Ian

> > Is it possible to issue a Buy order without automatically
> > cancelling a Sell position? 
> 
> I have used code like the following to do this:
> 
> ===
> 
> PosChange = <<whatever>>;  { >0 to go more long, <0 to go more short }
> 
> if MarketPosition >= 0 then begin
>   if PosChange > 0
>     then buy("Add Long") PosChange contracts at <<whatever>>
>     else exitlong("Reduce Long") -PosChange contracts total at 
> <<whatever>>;
>   end;
>   
> if MarketPosition <= 0 then begin
>   if PosChange < 0
>     then sell("Add Short") -PosChange contracts at <<whatever>>
>     else exitshort("Reduce Short") PosChange contracts total at 
> <<whatever>>;
>   end;
> 
> ===
> 
> Thus, if you are long you buy to get longer, but exitlong to get shorter, 
> and vice versa.  Note the magic keyword "total" in the exit statements.
> 
> Gary
>