jueves, 9 de noviembre de 2017

qui il codice ...controllato ed ordinato

//__________________________Tecnica 50% con modifystoploss________________________// 9-novembre-2017

Var: openday,rangeminimi,rangemassimi,percentualemese;
Var: formulaprimariaup,formulaprimariadown,codiceup,codiceup1,dayafter,tp1up,tp1down;
Var: formulaprimariaup1,formulaprimariadown1,codiceup2,codiceup3,tp1up1,tp1down1;
Var: contatp1up,contatp1down,input1,input2;
Var: newday(false), mioopen(0), miomin(0), miomax(0), mioclose(0),dvmed;
Var: wmax,wmin,wmed,DMAX,DMIN;
Var: fflat,lg,sh,contalg,contash,contaflat;
Var: contanuoviminimia,contanuovimassimia;
Var: cambiatogiorno,prova,contagiornoinessere;
Var: Pr_Ingr(0), Max_Gain(0), Max_Gain_perc(0), Gain(0),condizioneA,condizioneB;
Var: vp1,vp2,vp3;
Var: meseprec,meseprec8,meseprec9;

/////////////////////////////////////////////////////////////////////////////////////////////////////
if isfirstbarday then openday=open;endif;
///////////////////////////////////////////////////////////////////////////////////////////////////
rangeminimi=(((openm-lowm)/openm)*100);
rangemassimi=(((highm-openm)/openm)*100);
percentualemese=rangeminimi+rangemassimi;
//////////////////////////////////////////////////////////////////////////////////////////////////
formulaPrimariaup=openm+(openm/100)*20;
formulaPrimariadown=openm-(openm/100)*20;
codiceup=op(formulaprimariaup,openm,sub);
codiceup1=op(codiceup,22,divis);

formulaPrimariaup1=openm+(openm/100)*10;
formulaPrimariadown1=openm-(openm/100)*10;
codiceup2=op(formulaprimariaup1,openm,sub);
codiceup3=op(codiceup2,22,divis);

if  getday<>dayafter and IsFirstBarDay then tp1up=tp1up+codiceup1;endif;
if  getday<>dayafter and IsFirstBarDay then tp1down=tp1down-codiceup1;endif;
if getmonth<>meseprec then tp1up=openm;endif;
if getmonth<>meseprec then tp1down=openm;endif;
/////////////////////////////////////////////////////////////////////////////////////////////////////
if  getday<>dayafter and IsFirstBarDay then tp1up1=tp1up1+codiceup3;endif;
if  getday<>dayafter and IsFirstBarDay then tp1down1=tp1down1-codiceup3;endif;
dayafter=getday;

if getmonth<>meseprec then tp1up1=openm;endif;
if getmonth<>meseprec then tp1down1=openm;endif;
meseprec=getmonth;

if c>tp1up1 then contatp1up=contatp1up+1;endif;
if c<tp1down1 then contatp1down=contatp1down+1;endif;
if getmonth<>meseprec8 then contatp1up=0;endif;
if getmonth<>meseprec8 then contatp1down=0;endif;
meseprec8=getmonth;
/////////////////////////////////////////////////////////////////////////////////////////////////////
if IsFirstBarDay then input1=H;endif;
if IsFirstBarDay then input2=L;endif;
plotchart(input1, 0 , green, solid, 2);
plotchart(input2, 0 , red, solid, 2);
/////////////////////////////////////////////////////////////////////////////////////////////////////
newday=GetValues(days,1,mioopen,miomin,miomax,mioclose);
dvmed= miomin+(50*(miomax-miomin))/100;
if isfirstbarday then
   WMAX=H;
   WMIN=L;
   else
   WMAX=iif(H>=WMAX[1],H,WMAX[1]);
   WMIN=iif(L<=WMIN[1],L,WMIN[1]);
   WMED=wmax-(wmax-wmin)*0.5;
endif;

PlotChart(WMED,0, gray, dot, 1);
Plotchart(dvmed,0,blue,solid,1);
DrawText(NEWOGG,0 , D,wmed , "50% intraday",wmed , red, 12, 2+2,Alright);
DrawText(NEWOGG,0 , D,dvmed , "50% ieri",dvmed , white, 14, 3+2,Alleft);

//////////////////////___CONTA_Situazione___///////////////////////////////////////////////

if positiondir=0 then fflat=1;endif; if positiondir<>0 then fflat=0;contaflat=0;endif; if fflat=1 and fflat[1]=1 then contaflat=(contaflat[1]+1);endif;

if positiondir=1 then lg=1;endif; if positiondir<>1 then lg=0;contalg=0;endif; if lg=1 and lg[1]=1 then contalg=(contalg[1]+1);endif;

if positiondir=-1 then sh=1;endif; if positiondir<>-1 then sh=0;contash=0;endif; if sh=1 and sh[1]=1 then contash=(contash[1]+1);endif;

//////////////////////////////////////////////////////////////////////////////////////////////
if t=0915 then contanuovimassimia=1;endif;
if t=0915 then contanuoviminimia=1;endif;
if wmax>wmax[1]  then contanuovimassimia=contanuovimassimia+1;endif;
if wmin<wmin[1]  then contanuoviminimia=contanuoviminimia+1;endif;
if t=1715 then contanuovimassimia=0;endif;
if t=1715 then contanuoviminimia=0;endif;
//////////////////////////////////////////////////////////////////////////////////////////////
if getmonth<>meseprec9 then contagiornoinessere=0;endif;
meseprec9=getmonth;
cambiatogiorno = GetValues(days, 1, prova, prova, prova, prova);
if cambiatogiorno then contagiornoinessere=contagiornoinessere+1;endif;
/////////////////////////////////// Gain /////////////////////////////////////////////////////
if Positionvalue<>0 then
   Pr_Ingr = positionValue;
   if Positiondir=1 then
      if (C>Max_Gain) or (Max_Gain=0) then
         Max_Gain = C;
Max_Gain_perc = ((Max_Gain-Pr_ingr)*100)/Pr_Ingr;
      endif;
      Gain = ((C-Pr_ingr)*100)/Pr_Ingr;
   else
      if (C<Max_Gain) or (Max_Gain=0) then
Max_Gain = C;
Max_Gain_perc = ((Pr_ingr-Max_Gain)*100)/Pr_Ingr;
       endif;
       Gain = ((Pr_ingr-C)*100)/Pr_Ingr;
   endif;
else
    Pr_ingr = 0;
Max_Gain = 0;
Gain = 0;
endif;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (LastTradeClosedPerc > 3.00) and contaflat<90  and lastopclosed=1 then condizioneA=1;else condizioneA=0;endif;
if (LastTradeClosedPerc > 3.00) and contaflat<90  and lastopclosed=3 then condizioneB=1;else condizioneB=0;endif;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
installstoploss(inperc,3.00,"SL", STARTNEXTBAR);
plotchartNoZero(getstoploss, 0, red, solid, 2);
DrawText(NEWOGG,0 , D,getstoploss , "sl",getstoploss , red, 25, 1+4,Alright);
//////////////////////////////////////////____________LONG___________________/////////////////////////////////////////////////////////
if c>highd(1) //close sopra massimi di ieri
and GetNumOpEnterLongToday=0 // solo un long al giorno
and c>input1 //close sopra massimi prima candela a 15 minuti
and condizioneB=0 // non entra long per 90 candele se ultimo gain short maggiore del 3%
then enterlong( nextbar,atopen,STOP, 0,"Enter Lg 1");endif;
/////////////////////  Exit Long  ///////////////////////////////////////////////////////////////////////////////////////////
if positiondir=1 and c<dvmed then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 1");endif;
if positiondir=1 and contalg>20 and gain<1.00 and c<wmed  then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 2");endif;
if positiondir=1 and gain>1 and c>tp1up and contagiornoinessere>3 then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 3");endif;


//////////////////////////////////////////____________SHORT___________________/////////////////////////////////////////////////////////
if   c<lowd(1) //minimi di ieri
and GetNumOpEntershortToday=0 //solo uno short al giorno
and c<input2 //close sotto i minimi prima candela a 15 minuti
and condizioneA=0 //non entra short per 90 candele se ultimo gain long maggiore del 3%
then entershort(nextbar,atopen,STOP, 0,"Enter Sh 1" );endif;
////////////////////  Exit Short  ////////////////////////////////////////////////////////////////////////////////////////////
if positiondir=-1 and c>dvmed then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 1");endif;
if positiondir=-1 and contash>20 and gain<1.00 and c>wmed then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 2");endif;
if positiondir=-1 and gain>1.0 and c<tp1down and contagiornoinessere>3 then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 3");endif;

//////////////////////////______________________ModifyStopLoss_______________________/////////////////////////////////////////

if positiondir=1 and t>1000 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,1.00);endif;
if positiondir=1 and t>1100 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,0.50);endif;
if positiondir=1 and t>1200 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,0.10);endif;
if positiondir=1 and t>1300 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,-0.50);endif;
if positiondir=1 and t>1400 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,-1.00);endif;
if positiondir=1 and t>1500 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,-1.50);endif;
if positiondir=1 and t>1600 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,-2.00);endif;
if positiondir=1 and t>1700 and contanuovimassimia<2 and contanuoviminimia>1 then ModifyStopLoss(INPERC,-2.50);endif;


if positiondir=-1 and t>1000 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,1.00);endif;
if positiondir=-1 and t>1100 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,0.50);endif;
if positiondir=-1 and t>1200 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,0.10);endif;
if positiondir=-1 and t>1300 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,-0.50);endif;
if positiondir=-1 and t>1400 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,-1.00);endif;
if positiondir=-1 and t>1500 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,-1.50);endif;
if positiondir=-1 and t>1600 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,-2.00);endif;
if positiondir=-1 and t>1700 and contanuoviminimia<2 and contanuovimassimia>1 then ModifyStopLoss(INPERC,-2.50);endif;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
vp1 = Createviewport(150);
Plotchart(Max_Gain_perc,vp1,red,solid,2);
Plotchart(Gain,vp1,green,solid,2);

vp2=Createviewport(100);
PlotChart(contagiornoinessere,vp2,green,solid,2);

vp3=Createviewport(200);
Plotchart(contanuoviminimia,vp3,red,solid,2);
Plotchart(contanuovimassimia,vp3,green,solid,2);




9 comentarios:

  1. grandissimo Maestro, domani lo seziono al lavoro e nel fine settimana ci lavoro per fonderlo colla mia parte short attuale (mi dà soddisfazioni, per ora la tengo)...
    benissimo
    grazie ancora, buona serata !
    solo per togliermi la curiosità, quale era la versione del ts successiva a quella che ti dicevo io ?

    ResponderEliminar
    Respuestas
    1. credimi...sono andato in tilt con le versioni.....nel fine settimana se riesco faccio una lista ma la semplicita dell'ultimo mi fa venir voglia di eliminar le altre

      Eliminar
  2. Ciao, quindi le condizioni di modifica dello stop loss si aggiungono a quelle della versione precedente(verifica zona eccesso prezzo)?
    angelo

    grazie per la condivisione del lavoro

    ResponderEliminar
  3. si Bruno l'hai alleggerito (e performato anche)....complimenti...e grazie per condividerlo...lo studio un pò nel frattempo buona serata

    ResponderEliminar
  4. Salve a tutti, Questo TS e anche gli altri si possono inserire su un grafico nel cloud? Faccio questa domanda perché non ho il tempo per stare sempre davanti al pc di casa ma ho un tablet dove potrei connettermi al cloud quando sono fuori. Grazie.
    Emanuele.

    ResponderEliminar
    Respuestas
    1. a regola si ma senti Michelangelo che lui ne capisce di + ...io trado ancora in manuale

      Eliminar
    2. Si, devi farti una macchina virtuale, installarci VT, fare girare in automatico il ts, e poi di tanto in tanto accedi da remoto da tablet o da telefono come vuoi
      ma controlla ogni una/due ore che funzioni tutto bene

      Eliminar
  5. Bruno grazie come sempre per la condivisione di tutto... Grazie mille...

    ResponderEliminar

 era dal 26 marzo che i sistemi non si posizionavano long...oggi lo han fatto...area 21.90 posizionano il 1º take profit