Scaling Out of Position with EasyLanguage

First Put Multiple Contracts On:

If c > average(c,200) and c = lowest(c,3) then buy("5Large") 5 contracts this bar on close;
Using keyword contracts to put on multiple positions

Here you specify the number of contracts prior to the keyword contracts.

Easylanguage requires you to create a separate order for each exit.  Let’s say you want to get out of the 5 positions at different times and possibly prices.  Here’s how you do it:

If currentContracts = 5 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 4 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 3 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 2 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 1 and c > c[1] then sell 1 contracts this bar on close;
One order for each independent exit

The reserved word currentContracts hold the current position size.  Intuitively this should work but it doesn’t.

{If currentContracts > 0 then sell 1 contract this bar on close;}

You also can’t put order directives in loops.  You can scale out using percentages if you like.

Value1 = 5;

If currentContracts = 5 and c > c[1] then sell 0.2 * Value1 contracts this bar on close;
If currentContracts = 4 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 3 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 2 and c > c[1] then sell 1 contracts this bar on close;
If currentContracts = 1 and c > c[1] then sell 1 contracts this bar on close;
Using a percentage of original order size

 

That’s all there is to scaling out.  Just remember to have an independent exit order for each position you are liquidating.  You could have just two orders:  scale out of 3 and then just 2.

 


Discover more from George Pruitt

Subscribe to get the latest posts sent to your email.

Leave a Reply