Simple Wealthlab Coding Help

Can someone PM or post how to code this simple system w/ wealthlab

Basically buy breakout on 50 day high and exit on 5 day low. Also Max % loss per a trade is 10%.

For short.. just the opposite.. 50 day low for entry and 5 day high for exit. Also 10% stop loss.

Stock price needs to be greater than 15 also.
 
Something like this? (Remove comments for shorts and add comments to longs to do the short trades. I like to see each side, to determine if shorting is worth it. It usually isn't)

FWIW, a close stop like 10% always kills profits IMHO...


{$NO_AUTO_EXECUTE}

var Bar: integer;
var CloseToday: float;

InstallStopLoss(10);

for Bar := 50 to BarCount - 1 do
begin
ApplyAutoStops(Bar);

CloseToday := PriceClose(Bar);


if Not LastPositionActive then
begin
if SMA(Bar, #Volume, 20) > 350000 then
if CloseToday > 15.0 then
if CloseToday >= Highest(Bar - 1, #High, 50) then
BuyAtMarket(Bar + 1, 'Buy 50 day High');
end
else
begin
if CloseToday <= Lowest(Bar - 1, #Low, 5) then
SellAtMarket(Bar + 1, LastPosition, 'Close Long');
end;


{Remove comments for short trades
if Not LastPositionActive then
begin
if SMA(Bar, #Volume, 20) > 350000 then
if CloseToday > 15.0 then
if CloseToday <= Lowest(Bar - 1, #Low, 50) then
ShortAtMarket(Bar + 1, 'Short 50 day Low');
end
else
begin
if CloseToday >= Highest(Bar - 1, #High, 5) then
CoverAtMarket(Bar + 1, LastPosition, 'Close Short');
end;
}

end;
 
Back
Top