Sistema per definire la perdita massima

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #49266 quote
    Max
    Participant
    Average

    Qui di seguito una domanda inviata a ProRealTime:

    Buongiorno,

    avrei bisogno del codice per chiudere la posizione quando la perdita supera un valore prestabilito.

    Per esempio entro long con un incrocio di medie mobili (media breve crosses over media lunga) e rimango long finché le medie non s’incrociano nuovamente al ribasso.

    quello che vorrei aggiungere è che quando la curva dell’equity perde un certo valore dall’ultimo massimo raggiunto il sistema esca dalla posizione.

    grazie mille

    E un esempio di risposta:

    Perte=50 //in the currency of the stock
    
    EMAbreve = Average[21](close)
    EMAlunga = Average[90](close)
    
    
    Long = (EMAbreve Crosses Over EMAlunga)
    Short = (EMAbreve Crosses Under EMAlunga)
    
    // Condizioni per entrare su posizioni long
    IF NOT LongOnMarket AND Long THEN
    BUY 1 CONTRACTS AT MARKET
    maxlong=strategyprofit
    ENDIF
    
    
    // Condizioni per entrare su posizioni short
    IF NOT ShortOnMarket AND Short THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    maxshort=strategyprofit
    ENDIF
    
    
    if longonmarket then
    maxlong=max(maxlong,strategyprofit+((close -tradeprice)*COUNTOFLONGSHARES/POINTSIZE))
    if strategyprofit+((close -tradeprice)*COUNTOFLONGSHARES/POINTSIZE) < maxlong-perte then
    sell at market
    endif
    elsif shortonmarket then
    maxshort=max(maxshort,strategyprofit+((tradeprice -close)*COUNTOFSHORTSHARES/POINTSIZE))
    if strategyprofit+((tradeprice -close)*COUNTOFSHORTSHARES/POINTSIZE) <maxshort - perte then
    exitshort at  market
    endif
    endif
    #50066 quote
    papero76
    Participant
    Senior

    un traing profit dai massimi?

    te la butta la velocemente

    calcola highest di close

    piualto= highest[20](close)

    poi calcoli il prezzo di uscita  di highest di close

    prezzouscita= piualto/1.005 // se 0.5% di perdita

    if long onmarket then

    sell at prezzouscita limit

    endif

     

    messa molto velocemente

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

Sistema per definire la perdita massima


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Max @max Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by papero76
8 years, 3 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/13/2017
Status: Active
Attachments: No files
Logo Logo
Loading...