Perche' non funziona???????

In linguaggio visual trader si vuole codificare la stringa:

se sono long da 100 barre e sono in perdita esci dalla posizione

if barsince(positiondir=1)>=100 and c<positionvalue then exitlong(nextbar,atopen);
endif;

Peccato che non funziona,qualcuno puo' aiutarmi?
Grazie
 
ciao, magari dico una cosa ovvia, sei sicuro che si verifica la condizione applicando il ts?
Nella stesura del ts hai utilizzato le sezioni section_enterlong ed exilong oppure hai fatto una stesura libera?
 
Ciao robom,ho usato la maschera da default di vt,con le varie sezioni e questa è stata inserita nel box exitlong.
Mi manda in palla il sistema,non esegue cio' che si intendeva fare.
 
Ciao robom,ho usato la maschera da default di vt,con le varie sezioni e questa è stata inserita nel box exitlong.
Mi manda in palla il sistema,non esegue cio' che si intendeva fare.

Ciao, occorre metterle al di fuori delle varie sezioni, perche il barsince deve essere sempre verificato e non solo per l'enterlong / exitlong.
 
Grazie robom,hai ragione fuori dal sistema lavora egreggiamente!
Ancora grazie.
Sai per caso qual'e' la condizione che riporta il prezzo di carico per portare lo stop in pari? cioe' se sono long da tot barre e sono in guadagno porta lo stop in pari(prezzo di entrata a mercato)-
 
Non ho fatto le verifiche e l'ho scritto su un foglio di word; deve essere visto piu' che altro per degli spunti e/o riflessioni ciao.

Codice:
[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]
 

Users who are viewing this thread

Back
Alto