PureBytes Links
Trading Reference Links
|
This trading system in Wealth-lab code gives very good and robust
results. Can someone translate it in AFL ?
{$I 'Gaussian'}
var Bar, GaussianKeltnerLong, TuneFactor, SelfTuneEndBar: integer;
var BandFactor, MaxEquity: float;
const ProfitTarget = 12;
const Days = 1;
const KeltnerHiLoPeriod = 30;
const KeltnerAveragePeriod = 9;
const SelfTuneStartBar = 30;
SelfTuneEndBar := BarCount-1;
MaxEquity := -99999999;
function LongFilter: boolean;
begin
Result :=
(PriceOpen(Bar) > @GaussianKeltnerLong[Bar-1]);
end;
procedure Trade(StartBar, EndBar: integer);
begin
for Bar := StartBar to EndBar do
begin
if not LastPositionActive then
begin
if LongFilter then
BuyAtLimit(Bar+1, @GaussianKeltnerLong[Bar], 'Long Entry');
end
else
if PositionLong(LastPosition) then
begin
if not SellAtLimit(Bar+1, PositionEntryPrice(LastPosition) *
(1+ProfitTarget/100), LastPosition, 'ProfitTarget') then
if Bar-PositionEntryBar(LastPosition) = Days-1 then
SellAtClose(Bar+1, LastPosition, 'TimeOut');
end
else
end;
end;
for TuneFactor := 80 to 94 do
begin
GaussianKeltnerLong := MultiplySeriesValue(SubtractSeries
(GaussianSeries(#AverageC, KeltnerAveragePeriod, 4), GaussianSeries
(SubtractSeries(#High, #Low), KeltnerHiLoPeriod, 4)), TuneFactor/100);
Trade(SelfTuneStartBar, SelfTuneEndBar);
if Equity(SelfTuneEndBar) > MaxEquity then
begin
MaxEquity := Equity(SelfTuneEndBar);
BandFactor := TuneFactor/100;
end;
ClearPositions;
end;
GaussianKeltnerLong := MultiplySeriesValue(SubtractSeries
(GaussianSeries(#AverageC, KeltnerAveragePeriod, 4), GaussianSeries
(SubtractSeries(#High, #Low), KeltnerHiLoPeriod, 4)), BandFactor);
Trade(30, BarCount-1);
PlotSeries(OffsetSeries(GaussianKeltnerLong, -1), 0, #Red, 0);
DrawLabel('BandFactor: ' + FloatToStr(BandFactor), 0)
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|