[FONT=Times New Roman][SIZE=3][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Var: valore_uscita(999999), incremento(0), maxstop(0.02), posizione;[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//*******************************************************[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//valore_uscita rappresenta il valore a cui il sistema può uscire dal trade:[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//1.alla pari nel caso in cui il sistema almeno una volta è andato in positivo nel trade dopo le 100 barre[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//2.in trailing (vedi considerazioni relative ad incremento)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//3.stop loss (vedi considerazioni relative a maxstop)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//4.999999 (valore di default nel caso in cui non venga raggiunta alcune delle variabili precedenti[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//incremento è la variabile che dovrebbe accogliere un valore fisso e/o determinato con algoritmo //(qui non trattato)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//maxstop è la variabile che dovrebbe accogliere un valore fisso e/o determinato con algoritmo (qui //non trattato[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//posizione è l’array che contiene la posizione del ts nelle varie barre[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//*******************************************************[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//array della posizione del ts[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//nel caso in cui nella barra precedente il sistema era long e nella barra attuale è flat la variabile viene riportata al valore di default (999999)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]posizione = positiondir;[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]if posizione[1] = 1 and posizione = 0 [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]then[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]valore_uscita = constval(999999);[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]endif;[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]// DA INSERIRE DENTRO LA SEZIONE SECTION EXIT_LONG [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]if barsince(positiondir = 1) >= 100 [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]then [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] if valore_uscita <> 999999 [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] then [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] valore_uscita = valore_uscita + incremento;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] endif; [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] if valore_uscita = 999999 [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] then [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] if c> positionvalue [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] valore_uscita = positionvalue;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] endif;[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] if c < positionvalue[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] then [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if ((positionvalue - C)/positionvalue) > maxstop[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]then [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]valore_uscita = C;[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]endif; [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] endif;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] endif; [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//definizione del valore di exit[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//l’exit è sempre definita a livello di stop in maniera tale che puo’ assumere i seguenti valori:[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//1.prezzo di carico[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//2.prezzo di carico + incremento (fisso o algoritmo) in trailing[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//3.stop loss[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]//999999 (praticamente non esce perche il valore dell’indice è inferiore al valore di stop)[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]exitlong(bar, valore_uscita, stop); [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]endif;[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]