Stop Loss funktioniert nicht?

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #223517 quote
    axmichi
    Participant
    Senior
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])
    
    IF c1 AND c2 THEN
    BUY 1 SHARES AT MARKET
    c17 = close-(Lowest[5](low))
    
    
    set stop loss c17
    Endif
    

    Hallo, kann mir jemand sagen warum der Stop Loss mal funktioniert und mal nicht funktioniert?

    Der Code sagt das der Stop loss an dem tiefsten Tief der letzten 5 Kerzen liegt und da bleibt er auch liegen.

     

    Wie im Bild zu sehen funktioniert das im ersten Trade. Aber im nächsten Trade greift der Stop loss nicht mehr und wird später beendet??

    Warum ist das so?

    Muss im Code für den stop loss vielleicht  etwas wie “Price” stehen, damit er erkennt wo der Stop loss liegen soll?

    Vielen Dank

    #223520 quote
    GraHal
    Participant
    Master

    Versuche dies …

    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])
    
    IF NOT Longonmarket AND c1 AND c2 THEN
    BUY 1 SHARES AT MARKET
    c17 = close-(Lowest[5](low))
    set stop loss c17
    Endif
    robertogozzi thanked this post
    #223527 quote
    robertogozzi
    Moderator
    Master

    GraHal hat recht.

    Da Sie die Eintrittsbedingungen geschrieben hatten, wurde die SL oft dann geändert, wenn ein Betrieb bereits eröffnet war.

    GraHal thanked this post
    #223564 quote
    axmichi
    Participant
    Senior

    Vielen Dank!!!

    #223565 quote
    axmichi
    Participant
    Senior

    gibt es einem Möglichkeit den Stop loss im chart sichtbar zu machen, das man sehen kann wo er liegt??

    Mit einem kurzen strich oder linie am tiefsten Tief

    #223615 quote
    robertogozzi
    Moderator
    Master

    Sie müssen GRAPHONPRICE am Ende des Codes hinzufügen, um es im Diagramm anzuzeigen.

    Als:

    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
     
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])
     
    IF NOT Longonmarket AND c1 AND c2 THEN
       BUY 1 SHARES AT MARKET
       SL = Lowest[5](low)
       c17 = close-(Lowest[5](low))
       set stop loss c17
    Endif
    GraphOnPrice SL AS "Stop Loss" coloured("Red",255)
    #223617 quote
    axmichi
    Participant
    Senior

    Hallo und Danke.

    es ist so das meine Positionsgröße leider nicht richtig berechnet wird. Entry Price – Abstand Stop Loss

    Es sollen so viele Aktien gekauft werden, dass nur immer 1 % von 10 000 riskiert wird. Leider scheint die berechnung nicht zu stimmen, es wird immer zu wenig gekauft??

     

     
    Capital  = 10000                             //initial Capital
    Equity   = Capital + StrategyProfit          //current Equity
    PerCent  = 1                                 //1%  risk
    RiskSize = (Equity * PerCent / 100)          //max. Money at risk
    MinSize  = 0.5                               //0.5 lots minimum
    Menge = close - c17       //Difference
    PositionSize = RiskSize / Menge //Compute PositionSize, no less than MinSize
    
    
    
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])
     
    IF NOT Longonmarket AND c1 AND c2 THEN
    BUY PositionSize SHARES AT MARKET
    SL = Lowest[5](low)
    c17 = close-(Lowest[5](low))
    set stop loss c17
    set target profit c17*2
    Endif
    GraphOnPrice SL AS "Stop Loss" coloured("Red",255)
    #223633 quote
    axmichi
    Participant
    Senior

    habe es gefunden, ich muss positionsize / c17

    #223634 quote
    axmichi
    Participant
    Senior
    Capital  = 10000                             //initial Capital
    Equity   = Capital + StrategyProfit          //current Equity
    PerCent  = 1                                 //1%  risk
    RiskSize = (Equity * PerCent / 100)          //max. Money at risk
    MinSize  = 0.5                               //0.5 lots minimum
    //Difference
    PositionSize = RiskSize / sl //Compute PositionSize, no less than MinSize
    
    
    
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])
     
    IF NOT onmarket AND c1 AND c2 THEN
    sellshort PositionSize SHARES AT MARKET
    SL = highest[5](high)
    c17 = (highest[5](high))-close
    set stop loss c17
    //set target profit c17*2
    Endif
    GraphOnPrice SL AS "Stop Loss" coloured("Red",255)
    

    Bei den shortpositionen im code wird die Positionsize nicht richtig berechnet? was mach ich falsch??

    #223669 quote
    robertogozzi
    Moderator
    Master

    Bitte posten Sie die ITF-Datei.

    #223684 quote
    axmichi
    Participant
    Senior

     

    Die Anzahl der Aktien die gekauft werden sollen, berechnet sich aus 1 % Capital + Strategieprofit und dem Abstand vom Entry zum Stop Loss:

    Vielen Dank!!!!!

    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert

    Capital = 10000 //initial Capital
    Equity = Capital + StrategyProfit //current Equity
    PerCent = 1 //1% risk
    RiskSize = (Equity * PerCent / 100) //max. Money at risk
    //MinSize = 0.5 //0.5 lots minimum
    //Difference
    PositionSize = RiskSize / c17 or c18//Compute PositionSize, no less than MinSize

    //——————————————————————————
    // Bedingungen zum Einstieg in Long-Positionen
    c1 = (close > high[1])
    c2 = (close > high[2])

    IF NOT onmarket AND c1 AND c2 THEN
    Buy PositionSize SHARES AT MARKET

    SL = Lowest[5](Low)

    c17 = close- (Lowest[5](Low))
    set stop loss c17

    Endif
    X = 20
    if onmarket and BarIndex – TradeIndex = x Then
    sell at market
    endif
    //

    //——————————————————————————
    // Bedingungen zum Einstieg in Short-Positionen
    c3 = (close < low[1])
    c4 = (close < low[2])

    IF NOT onmarket AND c3 AND c4 THEN
    sellshort PositionSize SHARES AT MARKET
    SL1 = highest[5](high)

    c18 = (highest[5](high))-close
    set stop loss SL1

    Endif
    Y = 21
    if onmarket and BarIndex – TradeIndex = y Then
    exitshort at market
    endif

    //GraphOnPrice c17 AS “Stop Loss” coloured(“Red”,255)

    #224731 quote
    robertogozzi
    Moderator
    Master

    Sie haben vergessen, die ITF-Datei anzuhängen.

    #224800 quote
    axmichi
    Participant
    Senior

    ich hoffe die Datei ist jetzt drin??!!

    #224802 quote
    axmichi
    Participant
    Senior

    Es geht darum, dass die Anzahl der Aktien die gekauft werden soll nicht richtig berechnet wird??

    #225695 quote
    robertogozzi
    Moderator
    Master

    Erstens ist diese Zeile nicht gut:

    PositionSize = RiskSize / c17 or c18//Compute PositionSize, no less than MinSize

    Sie müssen zwei separate Berechnungen für Long und Short verwenden.

    Da die Berechnung von c17 und c18 außerdem NACH der Verwendung von PositionSize durchgeführt wird, muss ein Anfangswert von PositionSize festgelegt werden (vor der ersten Operation, also wenn TradePrice = 0).

    Dies ist die richtige Version:

    DEFPARAM CumulateOrders = False // Cumulating positions disabled
    
    Capital = 10000 //initial Capital
    Equity = Capital + StrategyProfit //current Equity
    PerCent = 1 //1% risk
    RiskSize = (Equity * PerCent / 100) //max. Money at risk
    //MinSize = 0.5 //0.5 lots minimum
    //Difference
    IF TradePrice = 0 THEN
    PositionSize17 = 1
    PositionSize18 = 1
    ELSE
    PositionSize17 = RiskSize / c17 //Compute PositionSize, no less than MinSize
    PositionSize18 = RiskSize / c18 //Compute PositionSize, no less than MinSize
    ENDIF
    //————————————————————————————
    // Conditions for entering long positions
    c1 = (close > high[1])
    c2 = ( close > high[2])
    
    IF NOT onmarket AND c1 AND c2 THEN
    Buy PositionSize17 SHARES AT MARKET
    
    SL = Lowest[5](Low)
    
    c17 = close- (Lowest[5](Low))
    set stop loss c17
    
    Endif
    X = 20
    if onmarket and BarIndex - TradeIndex = x Then
    sell at market
    endif
    //
    
    //————————————————————————————
    // Conditions for entering short positions
    c3 = (close < low[1])
    c4 = ( close < low[2])
    
    IF NOT onmarket AND c3 AND c4 THEN
    sellshort PositionSize18 SHARES AT MARKET
    SL1 = highest[5](high)
    
    c18 = (highest[5](high))-close
    set stop loss SL1
    
    Endif
    Y = 21
    if onmarket and BarIndex - TradeIndex = y Then
    exitshort at market
    endif
    
    //GraphOnPrice sl1 AS "Stop Loss" coloured("Red",255)
    //graph PositionSize17
    //graph PositionSize18
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Stop Loss funktioniert nicht?


ProOrder: Automatischer Handel & Backtesting

New Reply
Author
author-avatar
axmichi @axmichi Participant
Summary

This topic contains 16 replies,
has 3 voices, and was last updated by axmichi
2 years, 1 month ago.

Topic Details
Forum: ProOrder: Automatischer Handel & Backtesting
Language: German
Started: 11/11/2023
Status: Active
Attachments: 4 files
Logo Logo
Loading...