Pagina 1 van 1

StopLoss in punten i.p.v. percentage - StopLoss in punten i.

BerichtGeplaatst: ma 03 jan 2005, 20:02
door cdjansen
Onderstaand de code van de standaard Vestics function StopLoss.

Ik wil deze function graag ombouwen naar punten i.p.v. percentage.
Ik niets kunnen vinden over 'BigPointValue', maar ik neem aan dat dat een afrondings function is
om uit te komen op hele punten.
Er moet echter ook op 0.001 punt worden gesignaleerd.

Het lijkt mij dat alleen de regel:
?xLoss := -100*OpenPositionProfit/(AbsValue(CurrentContracts)*AbsValue(AvgEntryPrice)*BigPointValue);
, moet worden aangepast, maar ik weet niet hoe. Wie kan mij helpen?

Vr. Gr. Cor

-----------------------------------------------------------------------

value function StopLoss (value xStopLoss=5,value xBreakEven=0,
?value xTrailingStop=0,value xProfitStop=0) begin

?{--- caluculate current loss and profit ---}
?value xLoss,xProfit,xBest,xPrevPosition=0;
?xLoss := -100*OpenPositionProfit/(AbsValue(CurrentContracts)*AbsValue(AvgEntryPrice)*BigPointValue);
?xProfit := -xLoss;

?{--- keep track of best profit in trade ---}
?value xMarketPosition;
?xMarketPosition := MarketPosition;
?if xMarketPosition<>xPrevPosition then xBest := 0;
?if xProfit>xBest then xBest := xProfit;

?{--- check for stops ---}
?value xStopNow;
?xStopNow = false;
?if xStopLoss<>0 and xLoss>xStopLoss then xStopNow := true;
?if xBreakEven<>0 and xBest>xBreakEven and xLoss>0 then xStopNow := true;
?if xTrailingStop<>0 and xBest-xProfit>xTrailingStop then xStopNow := true;
?if xProfitStop<>0 and xProfit>xProfitStop then xStopNow := true;

?{--- exit trade if any stop is hit ---}
?if xStopNow=true then begin
? ?if xMarketPosition=1 then ExitLong;
? ?if xMarketPosition=-1 then ExitShort;
? ?end;

?{--- keep track of position ---}
?xPrevPosition := xMarketPosition;
?end;

StopLoss in punten i.p.v. percentage

BerichtGeplaatst: za 08 jan 2005, 17:06
door Paul M
Hoi Cor,

Inputs: xStopLoss(2), xBreakEven(0),
?xTrailingStop(0), xProfitStop(0) ;

?{--- caluculate current loss and profit ---}
?vars: xLoss(0),xProfit(0),xBest(0),xPrevPosition(0);
?xLoss := -OpenPositionProfit/(AbsValue(CurrentContracts)*BigPointValue);
?xProfit := -xLoss;

?{--- keep track of best profit in trade ---}
?var: xMarketPosition(0);
?xMarketPosition := MarketPosition;
?if xMarketPosition<>xPrevPosition then xBest := 0;
?if xProfit>xBest then xBest := xProfit;

?{--- check for stops ---}
?var: xStopNow(0);
?xStopNow = false;
?if xStopLoss<>0 and xLoss>xStopLoss then xStopNow := true;
?if xBreakEven<>0 and xBest>xBreakEven and xLoss>0 then xStopNow := true;
?if xTrailingStop<>0 and xBest-xProfit>xTrailingStop then xStopNow := true;
?if xProfitStop<>0 and xProfit>xProfitStop then xStopNow := true;

?{--- exit trade if any stop is hit ---}
?if xStopNow=true then begin
? ?if xMarketPosition=1 then ExitLong;
? ?if xMarketPosition=-1 then ExitShort;
? ?end;

?{--- keep track of position ---}
?xPrevPosition := xMarketPosition;

Groeten Paul.