door walter » vr 10 okt 2003, 15:12
Hierbij een handelssysteem dat handelt op basis van de stochast:
value function zStochast (value xStochBars=30, value xSlowKBars=5, value xSlowDBars=5, value xProfit=50, value xStopLoss=30) begin
value xOverSold=20, xOverBought=80;
value xFastK[], xSlowK[], xSlowD[], xTrend[], xStopLevel, xProfitLevel;
xFastK := FastK( Close );
xSlowK := vEMA( xFastK, xSlowKBars );
xSlowD := vEMA( xSlowK, xSlowDBars );
{---- check for signals ----}
if xSlowK > xSlowD and xSlowK < xOverSold and xSlowD < xOverSold then begin
{if Close > xTrend then} Buy; {else ExitShort;}
end;
if xSlowK < xSlowD and xSlowK < xOverBought and xSlowD > xOverBought then begin
{if Close < xTrend then} Sell; {else ExitLong;}
end;
if MarketPosition=1 then begin
xProfitLevel := EntryPrice(0) + xProfit;
xStopLevel ? := EntryPrice(0) - xStopLoss;
if Close > xProfitLevel or Close < xStopLevel then ExitLong;
end;
if MarketPosition=-1 then begin
xProfitLevel := EntryPrice(0) - xProfit;
xStopLevel ? := EntryPrice(0) + xStopLoss;
if Close < xProfitLevel or Close > xStopLevel then ExitShort;
end;
plot1( xSlowK, '%K' + NumToStr(xSlowKBars) );
plot2( xSlowD, '%D' + NumToStr(xSlowDBars) );
end;