Automatischer Break even

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #160334 quote
    Moritz
    Participant
    New

    Hallo,
    ich habe zwei Fragen und zwar ist es möglich einen automatischen SL zu programmieren, welcher bei erreichen von dem Risiko auf Break even gezogen wird? Also beispielsweise habe ich ein Trade mit 5€ Risiko und sobald mein Trade mit 5€ im Gewinn liegt wird automatisch der stop auf Break even gezogen.
    Meine andere Frage wäre ob man ein ähnliches System programmieren kann welches beim erreichen des Risikos nicht nur den SL auf Break even zieht sondern auch 25% aus dem Trade nimmt.
    Ich hoffe sie verstehen meine Fragen.;)
    Mit freundlichen Grüßen

    #160361 quote
    Nicolas
    Keymaster
    Master

    Im Folgenden finden Sie ein Beispiel, wie Sie eine Bestellung auf Breakeven setzen und gleichzeitig einen Teil der Bestellung schließen können. Dies geht aus der Diskussion in diesem anderen Thema hervor: prorealcode.com/topic/bollinger-band-coding-help-please/#post-80959

    defparam cumulateorders=false
    
    // --- settings
    amount = 2 //amount of contract/lot/shares to open for each order
    takeprofit = 30 //takeprofit in points 
    stoploss = 60 //stoploss in points 
    BreakevenAt = 25 //percent achieved of target to move stop to entry (breakeven)
    PointsToKeep = 1 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    Lot2Close = 1 //amount of contract/lot/shares quantity to close when breakeven occurs
    // --- end of settings
    
    upper = BollingerUp[20](close)
    lower = BollingerDown[20](close)
    
    //strategy 
    if high crosses over upper then 
    sellshort amount contract at market 
    endif 
    if low crosses under lower then 
    buy amount contract at market 
    endif 
    set target pprofit takeprofit
    set stop ploss stoploss
    
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    
    startBreakeven =  takeprofit*(BreakevenAt/100)//how much pips/points in gain to activate the breakeven function?
    // --- BUY SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    
    //place the new stop orders on market at breakevenLevel
    IF LONGONMARKET AND breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    if countoflongshares=amount then 
    sell Lot2Close contract at market
    endif 
    ENDIF
    // --- end of BUY SIDE ---
    
    // --- SELL SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF SHORTONMARKET AND tradeprice(1)-close>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    
    //place the new stop orders on market at breakevenLevel
    IF SHORTONMARKET AND breakevenLevel>0 THEN
    EXITSHORT AT breakevenLevel STOP
    if countofshortshares=amount then
    exitshort Lot2Close contract at market
    endif
    ENDIF
    // --- end of SELL SIDE ---
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Automatischer Break even


Allgemeines Trading: Marktanalyse & Manuelles Trading

New Reply
Author
author-avatar
Moritz @moritz Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
5 years, 1 month ago.

Topic Details
Forum: Allgemeines Trading: Marktanalyse & Manuelles Trading
Language: German
Started: 02/04/2021
Status: Active
Attachments: No files
Logo Logo
Loading...