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

Re: Buying without selling



PureBytes Links

Trading Reference Links

> 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