# Using Strings in EL for multi-step System

This little strategy uses EasyLanguage’s string manipulation to keep track of a multi-step, mutli-criteria, multi-state trade entry. You don’t buy until the buyString is equal to “BUY”. The sell side is just the opposite. When you program a multi-step entry you also need to build a reset situation. In the case of this system you reset the string to null(“”) when the price dips back down below the 9 day moving average. After resetting the process starts over again.

``````
{Use curly brackets for mult-line

This system needs three criteria to be met
Buy Criteria 1:  C > 9 day movAvg - trend Up
Buy Criteria 2:  H = HighestHigh 10 days - break Out
Buy Criteria 3:  C < C - retracement }

if marketPosition = 0 then {If flat then reset strings}
begin
sellString = "";
end;

if c >= average(c,9) then buyString = "B";  //First criteria met
if c < average(c,9) then buyString = "";

if c > average(c,9) then sellString = "";
if c <= average(c,9) then sellString = "S";

begin
if h > highest(h,10) then buyString = buyString + "U"; //Second Criteria met
end;

begin
if c < c then buyString = buyString + "Y"; //Third criteria met
end;

if sellString = "S" then
begin
if l > lowest(l,10) then sellString = sellString + "E";
end;

if sellString = "SE" then
begin
if c > c then sellString = sellString + "LL";
end;

if sellSTring = "SELL" then sellShort ("sellString") next bar at open;
setStopLoss(1000);

SetPercentTrailing(1000, 30);  ``````
``` ```

# Pyramaniac

Code to pyramid up to N contracts on a day trade basis.

```input: maxSize(5),startTime(1000),endTime(1555);
var: stb(0),sts(0),tpAmt(0),lprft(0),sprft(0);

stb = High + minMove/priceScale;
sts = Low - minMove/priceScale;

print(date," ",time," ",stb," ",sts," ",currentShares);

if (time > startTime and time < endTime ) then
begin
tpAmt = average(range,10);
if(high>high) then lprft = highD(0)+1*tpAmt;
if(low < low) then sprft = lowD(0) -1*tpAmt;
if(currentShares < maxSize and c < average(c,9) and low < low and close < close) then buy("pyrabuy")next bar at sts limit;
if(currentShares < maxSize and c < average(c,9) and high >high and close > close) then sellShort("pyrasell") next bar at stb limit;

end;

//if(currentShares >= maxSize and marketPosition = 1) then sell("longmaxliq") next bar sts stop;
//if(currentShares >= maxSize and marketPosition =-1) then buyToCover("shortmaxliq") next bar stb stop;
if(marketPosition = 1) then sell("longProf") next bar lprft limit;
if(marketPosition =-1) then buytoCover("shortProf") next bar at sprft limit;
setexitonclose;```