Here is the code from the ELD posted by Zapisy
_highestAtr
type: function
[LegacyColorValue = true];
{
Returns the highest ATR value from a short ATR and a longer ATR.
MAR 27 2004 : Holden Glova : Created
}
inputs:
shortATRLength(numericSimple), longATRLength(numericSimple);
vars:
shortATRValue(0), longATRValue(0);
shortATRValue = AvgTrueRange(shortATRLength);
longATRValue = AvgTrueRange(longATRLength);
if shortATRValue > longATRValue then begin
_highestATR = shortATRValue;
end
else begin
_highestATR = longATRValue;
end;
_AtrRatchetLX
type: strategy
[LegacyColorValue = true];
input: atrMultiplier (0.05);
input: shortAtrLength (4);
input: longAtrLength (20);
input: numLowsBack (5);
input: numAtrsToStartRatchet (4);
input: ______________________ (0);
input: www.linetrol.com (0);
vars:
stopPrice(0), atrValue(0), ratchetingBarCnt(0),
hasStarted(false);
if marketPosition = 1 then begin
atrValue = _highestAtr(shortAtrLength, longAtrLength);
if C > (entryPrice(0) + (atrValue * numAtrsToStartRatchet)) and hasStarted = false then begin
hasStarted = true;
stopPrice = entryPrice(0);
end;
if hasStarted then begin
if ratchetingBarCnt > 0 then begin
if stopPrice < Lowest(L, numLowsBack) then stopPrice = Lowest(L, numLowsBack);
stopPrice = stopPrice + (atrValue * (atrMultiplier * ratchetingBarCnt));
end;
sell("Ratchet_LX") next bar at stopPrice stop;
end;
ratchetingBarCnt = ratchetingBarCnt + 1;
end;
if marketPosition <> 1 then begin
hasStarted = false;
ratchetingBarCnt = 0;
end;
_AtrRatchetSX
type:strategy
[LegacyColorValue = true];
input: atrMultiplier (0.05);
input: shortAtrLength (4);
input: longAtrLength (20);
input: numHighsBack (5);
input: numAtrsToStartRatchet (4);
input: ______________________ (0);
input: www.linetrol.com (0);
vars:
stopPrice(0), atrValue(0), ratchetingBarCnt(0),
hasStarted(false);
if marketPosition = -1 then begin
atrValue = _highestAtr(shortAtrLength, longAtrLength);
if C < (entryPrice(0) - (atrValue * numAtrsToStartRatchet)) and hasStarted = false then begin
hasStarted = true;
stopPrice = entryPrice(0);
end;
if hasStarted then begin
if ratchetingBarCnt > 0 then begin
if stopPrice > Highest(H, numHighsBack) then stopPrice = Highest(H, numHighsBack);
stopPrice = stopPrice - (atrValue * (atrMultiplier * ratchetingBarCnt));
end;
buy to cover("Ratchet_SX") next bar at stopPrice stop;
end;
ratchetingBarCnt = ratchetingBarCnt + 1;
end;
if marketPosition <> -1 then begin
hasStarted = false;
ratchetingBarCnt = 0;
end;