Hallo,
bei diesem Code soll ja der Take Profit berechnet werden, indem der kurs des letzten Low (im code LL genannt) vom Kufkurs abgezigen wird und und auf dem Kaufkurs hinzu gerechnet wird. Das funktionert auch, aber leider nicht immer, unter bestimmten Situationen wird für die Berechnung nicht der LL sondern das Tief davor (im CodeLLprec genannt) hinzu gezogen.
Dies geschieht, so glaube ich, wenn der Ausbruch aus dem Trend zu schnell nach dem letzten LL kommt. Wie kann man das im code verändern.
Vieleicht kann man den code so ändern, dass ein ll, dass nach einem HH entsteht, erst 3 Tage nach dem HH genommen werden darf??
Wenn es so bleibt werden die Kursziele halt öfter falsch berechnet.
Danke für die Hlfe!!
//defparam calculateonlastbars=30000
ONCE HH = 0
ONCE HHprec = 0
ONCE LL = 0
ONCE LLprec = 0
if Not OnMarket Then
UseST = 0
ENDIF
// if NOT LongOnMarket then
//
//cp=3
//
//
//
//LLbar=BOTx
//
//EndIf
cp = 3
IF TradePrice = 0 THEN
PositionSize1 = 1
ELSE
PositionSize1 = 1000 / sp //Compute PositionSize
ENDIF
once lastpoint = 0
if high[cp] >= highest[2*cp+1](high) then
PEAK = 1
else
PEAK = 0
endif
if low[cp] <= lowest[2*cp+1](low) then
TROUGH = -1
else
TROUGH = 0
endif
if PEAK = 1 then
TOPy = high[cp]
TOPx = barindex[cp]
endif
if TROUGH = -1 then
BOTy = low[cp]
BOTx = barindex[cp]
endif
if PEAK>0 and (lastpoint=-1 or lastpoint=0) then
//DRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(127,255,0,1000)
//DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,10) coloured(200,0,0,255)
lastpoint = 1
lastX = TOPx
lastY = TOPy
HHprec= HH
HH = TOPy
HHbar = TOPx
endif
if TROUGH<0 and (lastpoint=1 or lastpoint=0) then
//DRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(255,0,0,255)
//DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,10) coloured(0,200,0,255)
lastpoint = -1
lastX = BOTx
lastY = BOTy
LLprec= LL
LL = BOTy
LLbar = BOTx
endif
//TREND ATTEMPT
atr=AverageTrueRange[14](close)
if TOPy > TOPy[1] and topy<>lasttop then
//drawarrowup(barindex,low-atr/2) coloured(0,200,0)
lasttop=topy
trendup = 1
else
trendup = 0
endif
//RETURN TOPy as "TOPy", BOTY as "BOTy", trendup as "trendup"
sp = close
// Long
IF not longonmarket and (close crosses over HH) AND (HH > 0) AND (LL > LLprec) AND (LLprec > 0)and (HH > HHprec) and (HH > LL) and (HHprec > LLprec) THEN //
BUY Positionsize1 Contract at Market
SL = abs(close - LL)
//SET TARGET %PROFIT 100
set stop ploss 523
TP = close + (SL * 4)
SET TARGET PRICE TP
LLprec = 0
ENDIF
graphonprice LL COLOURED(255,0,0,255)
graphonprice tp COLOURED(255,0,202,255)