Positionsgröße in Long und Short

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #236529 quote
    axmichi
    Participant
    Senior

    Hallo,

     

    danke das ist gut.

     

    Ich habe noch eine Bitte

    Kannst Du den Code so ändern dass der Trade bei einem Take Profit (CRV) von 3 mal dem Risiko geschlossen wird??

    Kannst Du den Stop Loss mit einem kleinen Strich kennzeichnen und die Differenz zwischen Einstieg und SL als Zahl anzeigen?

     

    Vielen Dank für die Hilfe

    #236565 quote
    robertogozzi
    Moderator
    Master

    Strategien können nicht über Diagrammanweisungen (die nur von Indikatoren verwendet werden können) auf dem Diagramm gedruckt werden.
    Deshalb habe ich GraphOnPrice verwendet, um die Stop-Loss-Linie auf dem Diagramm zu drucken, und Graph, um die Differenz zwischen dem Einstiegspreis und dem Stop-Loss im Variablenfenster anzuzeigen, das von ProBackTest geöffnet wird.

    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    ONCE CRVmult = 3.0
    ONCE Capital = 10000
    MyEquity     = Capital + StrategyProfit
    Risk         = MyEquity * 0.03
    //
    indicator1 = MACDSignal[12,26,9](close)
    indicator2 = RSI[4](close)
    //
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (indicator1 > 0)
    c2 = (indicator2 CROSSES OVER 30)
    IF c1 AND c2 AND Not OnMarket THEN
       SLprice = lowest[5](low)
       SL      = close - SLprice
       Size    = Risk / SL
       CRV     = Risk * CRVmult
       SET STOP   PRICE   SLprice
       SET TARGET $PROFIT CRV
       BUY Size SHARES AT MARKET
    ENDIF
    //
    // Bedingungen zum Einstieg in Short-Positionen
    c3 = (indicator1 < 0)
    c4 = (indicator2 CROSSES UNDER 70)
    IF c3 AND c4 AND Not OnMarket THEN
       SLprice = highest[5](high)
       SL      = SLprice - close
       Size    = Risk / SL
       CRV     = Risk * CRVmult
       SET STOP   PRICE   SLprice
       SET TARGET $PROFIT CRV
       SELLSHORT Size SHARES AT MARKET
    ENDIF
    //
    IF OnMarket THEN
       Difference = abs(TradePrice - SLprice) / PipSize
       IF (BarIndex - TradeIndex) = 20 THEN
          SELL      AT MARKET
          EXITSHORT AT MARKET
       ENDIF
    ENDIF
    //
    GraphOnPrice SL         AS "Stop Loss"  coloured("Red")
    Graph        Difference AS "Difference" coloured("Blue")
    #236615 quote
    axmichi
    Participant
    Senior

    Hallo Roberto,

     

    danke schön,

     

    Kannst Du bitte ändern, dass der SL (Rote linie) auf der Höhe des SL angezeigt wird, direkt unter dem Tief….

    Ich hade es so probiert: GraphOnPrice Positionprice – SL AS “Stop Loss” coloured(“Red”)

    Das funktioniert leider nicht???

    #236618 quote
    robertogozzi
    Moderator
    Master

    Ersetzen Sie Zeile 44 durch Folgendes:

    GraphOnPrice SLprice    AS "Stop Loss"  coloured("Red")
    #237314 quote
    axmichi
    Participant
    Senior

    Hallo Roberto,

     

    bitte schau mal. Ich habe den Fehler für die Berechnung der Anzahl der Aktien  gefunden. 🙂

     

    In Zeile 16 und Zeile 29 steht, Size = Risk / SL

    Das berechnet aber falsch!!! Richtig muss stehen: Size = Risk / Difference!!! Dann berechnet sich die richtige Stückzahl. Leider funktioniert der Code dann bei mir nicht mehr???

     

    LG

    #237324 quote
    robertogozzi
    Moderator
    Master

    Fügen Sie nach Zeile 1 Folgendes hinzu:

    ONCE Difference = 1
    #237469 quote
    axmichi
    Participant
    Senior

    Hallo, der Code funktioniert sehr gut.

    Hier ist die Anweisung für Einstieg, Stopp loss und Ausstieg.

    Leider schließt der Code den Trade beim SLPrice der mit läuft??!!

    Ich möchte das erst der SLPrice der Stopp Loss ist und wenn der Supertrend > ist als der SLPrice dann soll der Supertrend der Stopp loss sein…

    Wie im code unten steht…

    IF c1 AND c2 and c3 and c4 and c5 and c6 AND Not OnMarket THEN
    SLprice = lowest[3](low)
    SL = close – SLprice
    Size = Risk / SL
    CRV = SL
    SET STOP PRICE SLprice
    SET TARGET PROFIT CRV * 2
    BUY Size SHARES AT MARKET
    ENDIF

    if longonmarket and low < Supertrend[3,10] THEN
    sell at market
    endif

     

    Vielen Dank!!

    #237470 quote
    robertogozzi
    Moderator
    Master

    Da ist er:

    IF c1 AND c2 and c3 and c4 and c5 and c6 AND Not OnMarket THEN
       SLprice = lowest[3](low)
       SL = close - SLprice
       Size = Risk / SL
       CRV = SL
       SET STOP PRICE SLprice
       SET TARGET PROFIT CRV * 2
       BUY Size SHARES AT MARKET
    ENDIF
    myATR = Supertrend[3,10]
    if longonmarket and myATR > SLprice THEN
       SLprice = myATR
       SET STOP PRICE SLprice
    endif
    #237471 quote
    axmichi
    Participant
    Senior

    Danke das ist super!!!

Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.

Positionsgröße in Long und Short


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
author-avatar
axmichi @axmichi Participant
Summary

This topic contains 23 replies,
has 3 voices, and was last updated by axmichi
1 year, 5 months ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 04/10/2024
Status: Active
Attachments: 2 files
Logo Logo
Loading...