Stop&Reverse

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5244 quote
    Flavio
    Participant
    New

    Buongiorno, volevo sapere se è possibile codificare uno stop&reverse in un sistema di trading: praticamente se sono long e mi viene raggiunto lo stop loss, vorrei ribaltare la posizione, cioè aprire una posizione short con nuovo stop loss sopra il max della barra precedente.

    Grazie

    #5275 quote
    Nicolas
    Keymaster
    Master

    Ciao, questo è possibile, ma deve essere in grado di inserire nel codice. Grazie a postare qui, così posso farlo!

    #5293 quote
    Flavio
    Participant
    New

    In allegato il file con il mio codice: sono abbastanza pratico di programmazione, se mi manda il codice per fare lo Stop&Reverse penso di essere in grado di inserirlo.

    Grazie

    #5299 quote
    Nicolas
    Keymaster
    Master

    Prima di tutto dobbiamo creare una variabile che ci dice che tipo era l’ultimo commercio: “buy” (positiontype=1)  o “sell” (positiontype=-1) :

    IF filterL1 and NOT ONMARKET THEN
     ampiezza=((sup-inf)/(1*Ticksize))*var1
     ampiezzaP=((sup-inf)/(1*Ticksize))*var2
     BUY ncontratti CONTRACTS AT sup STOP
     positiontype = 1
    ENDIF

    Quindi verificare se l’ultimo commercio stava perdendo e non vi è alcun commercio nel mercato. E l’invio di un ordine inverso.

    IF NOT ONMARKET THEN
     IF POSITIONPERF(1)<0 AND positiontype=1 THEN
       SELLSHORT ncontratti AT MARKET
     ENDIF
    ENDIF
    

    È che va bene?

    #5300 quote
    Flavio
    Participant
    New

    Ok, appena ho tempo proverò a inserire il codice per vedere se funziona; per intanto La ringrazio.

    Flavio F.

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

Stop&Reverse


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Flavio @ruoston Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Flavio
9 years, 10 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/11/2016
Status: Active
Attachments: No files
Logo Logo
Loading...