COSTRUZIONE INDICATORE PER ANALISI CICLICA CON VISUAL TRADER

ValExit = valore di chiusura dell'ultima operazione conclusa.
Questo il comportamento di questa versione con il report e sotto metto il listato.
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
Codice:
[Var: miavar(0), Miacondizione1,Miacondizione2,miacondizione3,Miacondizione4,Miacondizione5,Miacondizione6;
Var: Miacondizione7,Miacondizione8, Miacondizione9,Miacondizione10, Miacondizione11,Miacondizione12, Miacondizione13,Miacondizione14;
Var: Miacondizione15,Miacondizione16,Miacondizione17,miacondizione18,STOP;
Var: Semaforo0910(0), semaforo1010(0), semaforo1110(0), Semaforo1210(0), semaforo1310(0), semaforo1410(0),Semaforo1510(0), semaforo1610(0), semaforo1710(0);
Var: ultimaposizione(0), indzona1(0), valoreritracciamento(0), valore(0), ultimoprezzo(0), barra(0), ope1(0), min1(0), max1(0), clo1(0);
Var: miavel, mio10, vettorestop(0), pippo(0),semaforovettorestop,rientrolong,rientroshort;


//****************************************************************************************************************

if T = 0910 then Miacondizione1 = C+20; Miacondizione2 = C-20; endif;
if T = 1010 then Miacondizione3 = C+20; Miacondizione4 = C-20; endif;
if T = 1110 then Miacondizione5 = C+20; Miacondizione6 = C-20; endif;
if T = 1210 then Miacondizione7 = C+20; Miacondizione8 = C-20; endif;
if T = 1310 then Miacondizione9 = C+20; Miacondizione10= C-20; endif;
if T = 1410 then Miacondizione11= C+20; Miacondizione12= C-20; endif;
if T = 1510 then Miacondizione13 =C+20; Miacondizione14= C-20; endif;
if T = 1610 then Miacondizione15 =C+20; Miacondizione16= C-20; endif;
if T = 1710 then Miacondizione17 =C+20; Miacondizione18= C-20; endif;
//*************************************************************************************************************************

//Non si riesce a capire perche ma se metto il controllo in T = non lo prende, probabilmente perche delle barre potrebbero mancare
//in assenza di contrattazione
if T >=0910 and T <= 1009 then if positiondir =  1 then semaforo0910 = 1; endif; if positiondir = - 1 then semaforo0910 = - 1; endif; endif;
if T >=1010 and T <= 1109 then if positiondir =  1 then semaforo1010 = 1; endif; if positiondir = - 1 then semaforo1010 = - 1; endif; endif;
if T >=1110 and T <= 1209 then if positiondir =  1 then semaforo1110 = 1; endif; if positiondir = - 1 then semaforo1110 = - 1; endif; endif;
if T >=1210 and T <= 1309 then if positiondir =  1 then semaforo1210 = 1; endif; if positiondir = - 1 then semaforo1210 = - 1; endif; endif;
if T >=1310 and T <= 1409 then if positiondir =  1 then semaforo1310 = 1; endif; if positiondir = - 1 then semaforo1310 = - 1; endif; endif;
if T >=1410 and T <= 1509 then if positiondir =  1 then semaforo1410 = 1; endif; if positiondir = - 1 then semaforo1410 = - 1; endif; endif;
if T >=1510 and T <= 1609 then if positiondir =  1 then semaforo1510 = 1; endif; if positiondir = - 1 then semaforo1510 = - 1; endif; endif;
if T >=1610 and T <= 1709 then if positiondir =  1 then semaforo1610 = 1; endif; if positiondir = - 1 then semaforo1610 = - 1; endif; endif;
if T >=1710 and T <= 1730 then if positiondir =  1 then semaforo1710 = 1; endif; if positiondir = - 1 then semaforo1710 = - 1; endif; endif;
//*******************************************************************************************************************************************
//Identifica il livello del ritracciamento
if lastopisstop = false then vettorestop = 0; colorbar(lime);endif; if lastbar = true then semaforovettorestop = 0; endif;
if lastopisstop = true  then vettorestop = 1; colorbar(red); endif;if lastbar = true then semaforovettorestop = 0; endif;
if vettorestop[1] <> vettorestop and  vettorestop = 0 then
//if ultimaposizione = 1 then valoreritracciamento = H[1];
       if ultimaposizione = 1 then valoreritracciamento = valexit;
       if (CompareTime(09, 10, 0) > 0) and (CompareTime(10,09, 0) < 0) then Miacondizione1 = Valexit + 30; semaforo0910 = 0; endif;
       if (CompareTime(10, 10, 0) > 0) and (CompareTime(11,09, 0) < 0) then Miacondizione3 = Valexit + 30; semaforo1010 = 0; endif;
       if (CompareTime(11, 10, 0) > 0) and (CompareTime(12,09, 0) < 0) then Miacondizione5 = Valexit + 30; semaforo1110 = 0; endif;
       if (CompareTime(12, 10, 0) > 0) and (CompareTime(13,09, 0) < 0) then Miacondizione7 = Valexit + 30; semaforo1210 = 0; endif;
       if (CompareTime(13, 10, 0) > 0) and (CompareTime(14,09, 0) < 0) then Miacondizione9 = Valexit + 30; semaforo1310 = 0; endif;
       if (CompareTime(14, 10, 0) > 0) and (CompareTime(15,09, 0) < 0) then Miacondizione11= Valexit + 30; semaforo1410 = 0; endif;
       if (CompareTime(15, 10, 0) > 0) and (CompareTime(16,09, 0) < 0) then Miacondizione13= Valexit + 30; semaforo1510 = 0; endif;
       if (CompareTime(16, 10, 0) > 0) and (CompareTime(17,09, 0) < 0) then Miacondizione15= Valexit + 30; semaforo1610 = 0; endif;
       if (CompareTime(17, 10, 0) > 0) and (CompareTime(17,30, 0) < 0) then Miacondizione17= Valexit + 30; semaforo1710 = 0; endif;
    endif;

    //if ultimaposizione = -1 then valoreritracciamento = valexit-30;
       if (CompareTime(09, 10, 0) > 0) and (CompareTime(10,09, 0) < 0) then Miacondizione2 = Valexit - 30; semaforo0910 = 0; endif;
       if (CompareTime(10, 10, 0) > 0) and (CompareTime(11,09, 0) < 0) then Miacondizione4 = Valexit - 30; semaforo1010 = 0; endif;
       if (CompareTime(11, 10, 0) > 0) and (CompareTime(12,09, 0) < 0) then Miacondizione6 = Valexit - 30; semaforo1110 = 0; endif;
       if (CompareTime(12, 10, 0) > 0) and (CompareTime(13,09, 0) < 0) then Miacondizione8 = Valexit - 30; semaforo1210 = 0; endif;
       if (CompareTime(13, 10, 0) > 0) and (CompareTime(14,09, 0) < 0) then Miacondizione10= Valexit - 30; semaforo1310 = 0; endif;
       if (CompareTime(14, 10, 0) > 0) and (CompareTime(15,09, 0) < 0) then Miacondizione12= Valexit - 30; semaforo1410 = 0; endif;
       if (CompareTime(15, 10, 0) > 0) and (CompareTime(16,09, 0) < 0) then Miacondizione14= Valexit - 30; semaforo1510 = 0; endif;
       if (CompareTime(16, 10, 0) > 0) and (CompareTime(17,09, 0) < 0) then Miacondizione16= Valexit - 30; semaforo1610 = 0; endif;
       if (CompareTime(17, 10, 0) > 0) and (CompareTime(17,30, 0) < 0) then Miacondizione18= Valexit - 30; semaforo1710 = 0; endif;
    endif;
 //endif;
   if lastbar = true then semaforovettorestop = 0; endif;
   if lastbar = true then semaforovettorestop = 0; endif;

if LastOpIsStop = TRUE  and LastOpClosed = 1 then
RIENTROLONG = ValExit +10;endif;
//PlotChart(rientrolong,0,red,solid,2);

if LastOpIsStop = TRUE and LastOpClosed = -1 then
RIENTROSHORT = ValExit - 10;endif;
PlotChart(valexit,0,blue,solid,2);
//**************************************************************************************************************************************************

if (CompareTime(09, 10, 0) > 0) and (CompareTime(10,09, 0) < 0) then
       if C > Miacondizione1  and semaforo0910 <>  1  and C > C[1] then EnterLong(NextBar, AtOpen); semaforo0910 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo0910 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo0910 = 1; ultimaposizione =1; endif;
       if C < Miacondizione2  and semaforo0910 <> -1 and C < C[1]then EnterShort(NextBar,AtOpen); semaforo0910 = -1; ultimaposizione = -1; endif;
        if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo0910 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo0910 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(10, 10, 0) > 0) and(CompareTime(11,09, 0) < 0) then
       if C > Miacondizione3  and semaforo1010 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1010 =  1; ultimaposizione =  1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1010 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1010 = 1; ultimaposizione =1; endif;
       if C < Miacondizione4  and semaforo1010 <> -1  and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1010 = -1; ultimaposizione = -1; endif;
     if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1010 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1010 = -1; ultimaposizione = -1; endif;
       
endif;
if (CompareTime(11, 10, 0) > 0) and (CompareTime(12,09, 0) < 0) then
       if C > Miacondizione5  and semaforo1110 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1110 =  1; ultimaposizione =  1; endif;
        if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1110 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1110 = 1; ultimaposizione =1; endif;
       if C < Miacondizione6  and semaforo1110 <> -1   and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1110 = -1; ultimaposizione = -1; endif;
        if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1110 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1110 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(12, 10, 0) > 0) and (CompareTime(13,09, 0) < 0) then
       if C > Miacondizione7  and semaforo1210 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1210 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1210 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1210 = 1; ultimaposizione =1; endif;
       if C < Miacondizione8  and semaforo1210 <> -1   and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1210 = -1; ultimaposizione = -1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1210 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1210 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(13, 10, 0) > 0) and (CompareTime(14,09, 0) < 0) then
       if C > Miacondizione9  and semaforo1310 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1310 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1310 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1310 = 1; ultimaposizione =1; endif;
       if C < Miacondizione10 and semaforo1310 <> -1   and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1310 = -1; ultimaposizione = -1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1310 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1310 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(14, 10, 0) > 0) and (CompareTime(15,09, 0) < 0) then
       if C > Miacondizione11 and semaforo1410 <>  1 and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1410 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1410 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1410 = 1; ultimaposizione =1; endif;
       if C < Miacondizione12 and semaforo1410 <> -1   and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1410 = -1; ultimaposizione = -1; endif;
      if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1410 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1410 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(15, 10, 0) > 0) and (CompareTime(16,09, 0) < 0) then
       if C > Miacondizione13 and semaforo1510 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1510 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1510 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1510 = 1; ultimaposizione =1; endif;
       if C < Miacondizione14 and semaforo1510 <> -1   and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1510 = -1; ultimaposizione = -1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1510 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1510 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(16, 10, 0) > 0) and (CompareTime(17,09, 0) < 0) then
       if C > Miacondizione15 and semaforo1610 <>  1   and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1610 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1610 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1610 = 1; ultimaposizione =1; endif;
       if C < Miacondizione16 and semaforo1610 <> -1  and C < C[1]then EnterShort(NextBar,AtOpen); semaforo1610 = -1; ultimaposizione = -1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1610 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1610 = -1; ultimaposizione = -1; endif;
endif;
if (CompareTime(17, 10, 0) > 0) and (CompareTime(17,30, 0) < 0) then
       if C > Miacondizione17 and semaforo1710 <>  1  and C > C[1]then EnterLong(NextBar, AtOpen); semaforo1710 =  1; ultimaposizione =  1; endif;
         if LastOpIsStop = TRUE  and LastOpClosed = 1 and semaforo1710 <> 1 and C > RIENTROLONG and C > C[1]then Enterlong(Nextbar,atopen); semaforo1710 = 1; ultimaposizione =1; endif;
       if C < Miacondizione18 and semaforo1710 <> -1   and C < C[1]then EnterShort(NextBar, AtOpen);semaforo1710 = -1; ultimaposizione = -1; endif;
       if LastOpIsStop = TRUE  and LastOpClosed = -1 and semaforo1710 <> -1 and C < RIENTROSHORT and C < C[1]then Entershort(Nextbar,atopen); semaforo1710 = -1; ultimaposizione = -1; endif;
endif;

//******************************************************************************************************************************************************
if t>=1732 then
if positiondir=1 then
exitlong(bar,atclose);
endif;
if positiondir=-1 then
exitshort(bar,atclose);
endif;
endif;
if lastbar = true then
Semaforo0910 = 0;
Semaforo1010 = 0;
semaforo1110 = 0;
Semaforo1210 = 0;
semaforo1310 = 0;
semaforo1410 = 0;
Semaforo1510 = 0;
semaforo1610 = 0;
semaforo1710 = 0;
endif;

installtrailingprofit (inperc,0.8,0.1,trailing);
//PlotChart(rientrolong,0,red,solid,2);
//PlotChart(rientroshort,0,blue,solid,2);CODE]

[ATTACH=full]3126[/ATTACH]

[ATTACH=full]3127[/ATTACH]
 

Allegati

  • ScreenHunter_03 Jan. 06 18.47.gif
    ScreenHunter_03 Jan. 06 18.47.gif
    81,2 KB · Visite: 221
  • ScreenHunter_01 Jan. 06 18.46.gif
    ScreenHunter_01 Jan. 06 18.46.gif
    27,2 KB · Visite: 310
Ultima modifica:
Secondo me vedendo il listato non va bene; prova a plottare valexit, rientrolong e rientroshort per vedere il valore di ritracciamento.
dovrebbe essere sufficiente utilizzare il listato di pagina 168 e nella routine del valore di ritracciamento mettere invece di 30 il valore 10 se vuoi nel caso di trailing entrare con il valore di uscita +/-10 direttamente nella routine perche è quest'ultima che cambia direttamente il valore a miacondizione (chiaramente occorre modificare da +30 a +20 i livelli).
Ho fatto la routine che gestisce piu' stop in trailing in successione che lastopisstop non puo' gestire.
 
Secondo me vedendo il listato non va bene; prova a plottare valexit, rientrolong e rientroshort per vedere il valore di ritracciamento.
dovrebbe essere sufficiente utilizzare il listato di pagina 168 e nella routine del valore di ritracciamento mettere invece di 30 il valore 10 se vuoi nel caso di trailing entrare con il valore di uscita +/-10 direttamente nella routine perche è quest'ultima che cambia direttamente il valore a miacondizione (chiaramente occorre modificare da +30 a +20 i livelli).
Ho fatto la routine che gestisce piu' stop in trailing in successione che lastopisstop non puo' gestire.

Se plotto i due RIENTRI mi schiaccia il grafico. ValExit è corretto.

ScreenHunter_04 Jan. 06 20.02.gif
 
Questo il report corretto dell'ultimo listato:up::up::up:
******************************************************
******************************************************
******************************************************

ScreenHunter_05 Jan. 06 20.09.gif
 
c'è qualcosa che non va in rientro short; tu comunque vuoi che il valore di rientro sia con il valore di uscita + 10 e che la condizione del compare lo confronti con quel valore li giusto? adesso devo lavorare dopo ci guardo la risposta e ti invio un'altra cosa.
 
c'è qualcosa che non va in rientro short; tu comunque vuoi che il valore di rientro sia con il valore di uscita + 10 e che la condizione del compare lo confronti con quel valore li giusto? adesso devo lavorare dopo ci guardo la risposta e ti invio un'altra cosa.
RIENTROLONG = ValExit+10
RIENTROSHORT = ValExit-10
E grazie ancora
 
Ultima modifica:
Quello che vorrei facesse il ts è questo.
Se esce in trailing e solo in questo caso per rientrare nella stessa direzione il livello di rientro deve essere RIENTROLONG = ValExit+10. Inoltre se esce in trailing deve togliere il comando a C > Miacondizionex , mentre deve continuare a mantenere la sua validità per le entrate in senso contrario. Questo fino allo step successivo dove tutto torna come prima.
 

Users who are viewing this thread

Back
Alto