sytem berechnet stoplossabstand unterschiedlich

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #265877 quote
    axmichiaxmichi
    Participant
    Senior

    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)
    
    Tradingsystem-richtig-codieren-.png Tradingsystem-richtig-codieren-.png
    #265883 quote
    Iván GonzálezIván González
    Moderator
    Legend

    hallo, deine Vermutung stimmt. Ein Tief wird im Code erst als Swing-Tief (LL) erkannt, wenn danach cp = 3 Kerzen geschlossen haben: low[cp] muss das tiefste Tief von 7 Kerzen sein, 3 davor und 3 danach. Kommt der Ausbruch über HH schon 1 oder 2 Kerzen nach dem Tief, ist das neue Tief noch nicht bestätigt, und LL enthält noch das Tief davor (das nach der Bestätigung zu LLprec wird). Deshalb wird das Kursziel in diesen Fällen mit dem falschen Tief berechnet.

    3 Tage nach dem HH zu warten löst es nicht, denn die Verzögerung zählt ab dem Tief, nicht ab dem HH.

    Die Lösung: Für den Abstand nimmst du nicht LL, sondern das tiefste Tief seit dem letzten HH. Das ist das echte Tief des Rücksetzers, auch wenn es noch nicht bestätigt ist. Ersetze das Ende deines Codes ab “sp = close” durch:

    pullbackLow = lowest[max(1, barindex - HHbar)](low)
    
    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 - pullbackLow)
    set stop ploss 523
    TP = close + (SL * 4)
    SET TARGET PRICE TP
    LLprec = 0
    ENDIF
    


    Falls du lieber deine Idee umsetzen willst, also nur handeln, wenn das Tief schon bestätigt ist: Füge der Einstiegsbedingung AND lastpoint = -1 hinzu. Dann werden diese schnellen Ausbrüche aber gar nicht gehandelt.

    robertogozzi thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

sytem berechnet stoplossabstand unterschiedlich


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
author-avatar
axmichi @axmichi Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
9 hours, 54 minutes ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 10/28/2026
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...