En daar is-tie dan. Ut was ff zoeken, blijkbaar had mijn virusscanner het spul in quarantaine geplaatst omdat-tie dacht dat Vesticode een virus is
Voorbeeld staat hieronder dus en loopt op een 1-minuut grafiekje. Mijn uitlijning van de code is helemaal op zijn kop gezet door het forumspul, maar een edit copy/past doet wonderen...
Suc6 ermee,
Marco.
value function zSysDemo (value pxBars = 14, value pxThresholdOpen = 80, value pxThresholdClose = 20,
? ? ? ? ? ? ? ? ? ? ? ? value pxProfit = 10, value pxStopLoss = 10)
begin
?value xUp[], xDown[];
?value xProfitLevel, xStopLevel;
?value xThisDate = 0;
?value xBlockSignals = 0;
?value xWaitForCrossing = 0;
?xUp ? ?:= zFnctUp ?(Close, pxBars);
?xDown ?:= zFnctDown(Close, pxBars);
?{---- Check for no-trading zones first
? ? ? ?Tests have shown, and been confirmed by S&P traders that losses can be reduced
? ? ? ?if lunch-time-trading and opening is blocked and positions are closed during that time
? ? ? ?Furthermore, positions are closed at the end of the day ----}
?if (Time = 2158) or (Time = 1200) then begin
? ?ExitLong;
? ?ExitShort;
? ?xBlockSignals := 1;
? ?xThisDate ? ? := Date;
?end;
?if xBlockSignals = 1 then begin
? ?if (Date <> xThisDate) and (Time > 900 + pxBars) then xBlockSignals := 0;
? ?if (Time = 1400) then xBlockSignals := 0;
?end;
?{---- Check for signals
? ? ? ?Signals might be blocked during some trading hours. Furthermore, although signals might
? ? ? ?NOT be blocked, the system awaits a crossing of the up and down indicators ----}
?if xBlockSignals = 0 then
?begin
? ?if xWaitForCrossing = 1 then
? ?begin
? ? ?if vCrosses(xUp, xDown) then xWaitForCrossing := 0;
? ?end;
? ?if xWaitForCrossing = 0 then
? ?begin
? ? ?if (xUp ? > xDown) and (xUp ? > pxThresholdOpen) then Buy else
? ? ?if (xDown > xUp) ? and (xDown > pxThresholdOpen) then Sell;
? ?end;
?end;
?{---- Handle the long side ----}
?if MarketPosition = 1 then
?begin
? ?xProfitLevel := EntryPrice + pxProfit;
? ?xStopLevel ? := EntryPrice - pxStopLoss;
? ?if ((Close > xProfitLevel) or (Close < xStopLevel)) or
? ? ? ((xUp < pxThresholdClose) and (xDown > pxThresholdClose)) then
? ?begin
? ? ?ExitLong;
? ? ?xWaitForCrossing := 1;
? ?end;
?end;
?{---- Handle the short side ----}
?if MarketPosition = -1 then
?begin
? ?xProfitLevel := EntryPrice - pxProfit;
? ?xStopLevel ? := EntryPrice + pxStopLoss;
? ?if ((Close < xProfitLevel) or (Close > xStopLevel)) or
? ? ? ((xDown < pxThresholdClose) and (xUp > pxThresholdClose)) then
? ?begin
? ? ?ExitShort;
? ? ?xWaitForCrossing := 1;
? ?end;
?end;
end;