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

Re: EasyLanguage problem: BUY("A") from entry("B")



PureBytes Links

Trading Reference Links

> Somebody has found a solution to this problem?
> BUY or SELL order automatically closes all open position of 
> the whole strategy. This fact forbid to merge together different 
> signals. 

Instead of doing simple "buy" or "sell" statements, you can use 
"compound buy/sell" logic to enter and exit your positions.

Everywhere that your system says to buy, use logic like this:

if MarketPosition >= 0 
  then buy 1 contract << wherever >>
  else exitshort 1 contract total << wherever >>;

Conversely, use sell logic like this:

if MarketPosition <= 0 
  then sell 1 contract << wherever >>
  else exitlong 1 contract total << wherever >>;

In other words, to "buy," you buy if you're currently flat or long, 
thus adding 1 contract to your position.  If you're short, you do an 
exitshort, to remove 1 contract from your short position.

The following simple system illustrates this.  Be sure to enable 
multiple entries per position if you want to try it.

Gary



vars:  ATR(0);

ATR = AvgTrueRange(20);

{ "buy" logic }
if MarketPosition >= 0 
  then buy 1 contract at High + ATR stop
  else exitshort 1 contract total at High + ATR stop;

{ "sell" logic }
if MarketPosition <= 0 
  then sell 1 contract at Low - ATR stop
  else exitlong 1 contract total at Low - ATR stop;