ich habe mal auf Basis des BETrailStop einen Schwellwert Stop gebaut, der auf dem Eröffnungskurs der Eröffnungsperiode aufsetzt und bei erreichen eines gewissen "Gewinns" einen StopLoss auf Einstand + x zieht. Die Tests sahen ganz gut aus, aber vllt entdeckt ja noch jemand einen Fehler.
Ich benutze es für Forex, deswegen sind die Werte so hoch.
Code: Select all
Express Stop TresholdStop
vars
input $InitialRiskInTicks(0, 10000, 5000);
input $ProfitTriggerInTicks(0, 2000, 200); //if hit, stop gets its first adjustment
input $InitialProfitOffsetInTicks(0, 30, 15); //ofset from entryprice
numeric entryPrice, tickSize;
numeric breakEven;
calculation
if true then
begin
SetIntraPeriodUpdate(); //If this function appears _anywhere_ in the code the stop is calculated at every tick.
entryPrice = open[BarsSinceEntry()];
tickSize = TickSize();
end
if MarketPosition() = 1 then //Long position
begin
breakEven = entryPrice + $ProfitTriggerInTicks * tickSize;
if Highest(high, BarsSinceEntry()) >= breakEven then
begin
SetStopPrice (entryPrice + $InitialProfitOffsetInTicks * tickSize);
end
else
begin
SetStopPrice(entryPrice - $InitialRiskInTicks * tickSize);
end
end
else if MarketPosition() = -1 then //Short position
begin
breakEven = entryPrice - $ProfitTriggerInTicks * tickSize;
if Lowest (low, BarsSinceEntry()) <= breakEven then
begin
SetStopPrice (entryPrice - $InitialProfitOffsetInTicks * tickSize);
end
else
begin
SetStopPrice(entryPrice + $InitialRiskInTicks * tickSize);
end