Info TrailingStop MFE con percentuali

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #153232 quote
    MauroPro
    Participant
    Veteran

    Salve, stò studiando un trailingstop trovato nel blog di prorealcode (“Trailing stop with the Max Favorable Excursion MFE”) ed ho visto che si utilizzano nell’esempio i punti:

    1 //trailing stop

    2 trailingstop =20

    22 if MAXPRICE-tradeprice(1) >=trailingstop x pointsize then

    La domanda è: posso utilizzare nella riga 2 una percentuale (es. 0.5% al posto dei punti e come si scrive, semplicemente: 0.5% ?)

    E poi, nella riga 22, al posto di “pointsize” cosa di scrive?

     

    trailingstop = 20
     
    //resetting variables when no trades are on market
    if not onmarket then
     MAXPRICE = 0
     MINPRICE = close
     priceexit = 0
    endif
     
    //case SHORT order
    if shortonmarket then
     MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
     if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then  
      priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
     endif
    endif
     
    //case LONG order
    if longonmarket then
     MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
     if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
      priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
     endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
     EXITSHORT AT priceexit STOP
     SELL AT priceexit STOP
    endif

     

    GRAZIE

    #153238 quote

    Questa è una funzione completa in percentuale con il trailing stop e il trailling step differenziate tra le operazioni long e quelle short.

    Ciao

    percentagelong  = 1
    percentageshort  = 1
    percentagesteplong = 0.50
    percentagestepshort  = 0.50
    TGL = (close/100)*percentagelong
    TGS = (close/100)*percentageshort
    STPL = (close/100)*percentagesteplong
    STPS = (close/100)*percentagestepshort
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    PREZZOUSCITA = 0
    ENDIF
    
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close)
    if MAXPRICE-tradeprice(1)>=TGL then
    PREZZOUSCITA = MAXPRICE-STPL
    ENDIF
    ENDIF
    
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    if tradeprice(1)-MINPRICE>=TGS then
    PREZZOUSCITA = MINPRICE+STPS
    ENDIF
    ENDIF
    
    if onmarket and PREZZOUSCITA>0 then
    EXITSHORT AT PREZZOUSCITA STOP
    SELL AT PREZZOUSCITA STOP
    ENDIF
    robertogozzi and alessiopippo thanked this post
    #153241 quote
    MauroPro
    Participant
    Veteran

    Grazie, lo provo!

    #153245 quote
    robertogozzi
    Moderator
    New

    Ottimo l’esempio di Mauro, ad ogni modo, per non stare a modificare il codice completamente basta convertire la percentuale in pips alla riga 1:

    trailingstop = (close * 0.5 / 100) / pipsize                //0.5% del prezzo
    trailingstop = round(((close * 0.5 / 100) / pipsize) - 0.5) //0.5% del prezzo, arrotondati all'unità inferiore

    sono due forme, la prima non arrotondata, quindi se vengono, ad esempio, 47.3 pips restano invariati (non è obbligatorio che siano numeri interi), mentre con la seconda vengono sempre arrotondati all’unità inferiore, nell’esempio fatto 47.

    Se preferisci, invece, arrotondare sempre all’unità superiore puoi sostituire – 0.5 con + 0.4.

    alessiopippo thanked this post
    #153247 quote
    MauroPro
    Participant
    Veteran

    Grazie Roberto, ti chiedo una cosa banale: a volte vedo nei listati di strategie su prorealcode che si usa POINTSIZE altre volte PIPSIZE.

    In generale nei mercati si usa il tick nel future ed il pip nel forex. Non mi sembra che su PRT si utilizzino i due termini per i differenti mercati, quindi ti chiedo: sono interscambiabili oppure c’è qualche differenza tecnica? (nel tuo esempio sopra, posso anche usare pointsize?)

    GRAZIE

    #153258 quote
    robertogozzi
    Moderator
    New

    Sono interscambiabili, significano la stessa cosa.

    Puoi usare tranquillamente PointSize al posto di PipSize.

    Sono interscambiabili anche PipValue e PointValue (restituiscono il valore di 1 pip/punto, ad esempio 1 sul Dax 1€, 5 sul Dax 5€, 25 sul Dax 25€, 10 su EurUsd standard, ecc…).

    #153262 quote
    MauroPro
    Participant
    Veteran

    ok grazie

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

Info TrailingStop MFE con percentuali


Supporto ProOrder

New Reply
Author
author-avatar
MauroPro @mauropro Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by MauroPro
5 years, 1 month ago.

Topic Details
Forum: Supporto ProOrder
Language: Italian
Started: 12/10/2020
Status: Active
Attachments: No files
Logo Logo
Loading...