lunes, 7 de enero de 2019

x Corrado
questo il ts openmese migliore ( se il copiaincolla fa errore te lo invio per email)

//_________________________Openmese_______________novembre 2018______________//


Var: fflat,lg,sh,contalg,contash,contaflat;  // monitoraggio situazione flat / long / short
Var: Pr_Ingr(0), Max_Gain(0), Max_Gain_perc(0), actual(0); ///_____Actual=Gain
var: meseprec18,meseprec9,cambiatogiorno,contagiornoinessere,prova;
var: prox01,prox02;
Var: idlastop,contagain;
Var: contaoplong,contaopshort,meseprec66,optotal;
Var: rangeminimi,rangemassimi,percentualemese;
Var: formulaprimariaup,formulaprimariadown,codiceup,codiceup1,dayafter,tp1up,tp1down;
Var: formulaprimariaup1,formulaprimariadown1,codiceup2,codiceup3,tp1up1,tp1down1;
Var: meseprec,meseprec51,resarealtime,colore;
Var: indzona1,indzona2,indzona3,indzona4,indzona5;
Var: contaprimaup,contaprimadown;
Var: rangediscesa,rangesalita,max_rangediscesa,max_rangesalita,meseprecAA,meseprecBB,filtrotrend,vp1,vp2,vp3,annoprec,ivp2;
Var: openday,contagainlong,contagainshort,contagainAnno,idlastopA,idlastopB,contagainA;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if isfirstbarday then openday=open;endif;

rangediscesa=(((highm-l)/highm)*100);
rangesalita=(((h-lowm)/lowm)*100);
if getmonth<>meseprecAA then rangediscesa=0;endif;
if getmonth<>meseprecAA then rangesalita=0;endif;
meseprecAA=getmonth;
if (rangediscesa>max_rangediscesa) then max_rangediscesa=rangediscesa;endif;
if (rangesalita>max_rangesalita) then max_rangesalita=rangesalita;endif;
if getmonth<>meseprecBB then max_rangediscesa=0;endif;
if getmonth<>meseprecBB then max_rangesalita=0;endif;
meseprecBB=getmonth;
filtrotrend=abs(rangesalita-rangediscesa);
/////////////////////////////////////////////////////////////////////////////////////////////////
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;

plotchart(tp1up, 0 , green, solid, 2);
plotchart(tp1up1, 0 , green, dot, 1);
plotchart(tp1down, 0 , red, solid, 2);
plotchart(tp1down1, 0 , red, dot, 1);
{if positiondir=1 then tp1down=openm;endif;
if positiondir=1 then tp1down1=openm;endif;
if positiondir=-1 then tp1up=openm;endif;
if positiondir=-1 then tp1up1=openm;endif;}
//////////////////////___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;
//////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////// ACTUAL /////////////////////////////////////////////////////
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;
         Actual = ((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;
         Actual = ((Pr_ingr-C)*100)/Pr_Ingr;endif;
else  Pr_ingr = 0;Max_Gain = 0; Actual = 0;endif;
/////////////////////////////////////////////////////////////////////////////

cambiatogiorno = GetValues(days, 1, prova, prova, prova, prova);
if getmonth<>meseprec18 then contagiornoinessere=0;endif;
if cambiatogiorno then contagiornoinessere=contagiornoinessere+1;endif;
meseprec18=getmonth;

prox01=addperc(openm,2);
prox02=addperc(openm,-2);


PlotChart(openM,0, gray, solid, 1);
PlotChart(prox01,0, aqua, dot, 1);
PlotChart(prox02,0, red, dot, 1);

DrawText(5,0 ,D ,openm , "OpenMese=",openm , red, 11, 1+3,Alright);
DrawText(2,0 ,D ,prox01 , "2 % sup.=",prox01 , aqua, 9, 1+3,Alright);
DrawText(3,0 ,D ,prox02 , "2 % inf.=",prox02 , aqua, 9, 1+3,Alright);

////////////////////////////////////////////////////////////////////////////////////////////////

if positiondir=1 and contalg=1 then contaoplong=contaoplong+1;endif;
if positiondir=-1 and contash=1 then contaopshort=contaopshort+1;endif;
if getmonth<>meseprec66 then contaoplong=0;endif;
if getmonth<>meseprec66 then contaopshort=0;endif;
meseprec66=getmonth;
optotal=contaoplong+contaopshort;

////////////////////////////////////////////////////////////////////////////////////////////
resarealtime=actual+contagain;
/////////////////////////    Stop Loss    //////////////////////////////////////////////////////////////////////////////
InstallStopLoss(INPERC, 3.00, "Stop");
plotchartNoZero(getstoploss, 0, red, solid, 2);
DrawText(4,0 , D,getstoploss , "sl",getstoploss , red, 15, 1+4,Alright);
//////////////////////   Enter & Exit Long   ///////////////////////////////////////////////////////////////////////////
if c>prox01  and contagiornoinessere<19 and contaflat>1 and contagain<3 {and (GetYear = 2014)} then enterlong(nextbar,atopen);endif;
if positiondir=1 and contagiornoinessere>18 then exitlong(nextbar,atopen);endif;
if positiondir=1 and getmonth<>meseprec51 then exitlong(nextbar,atopen);endif;
if positiondir=1 and actual>4.0  and contaoplong<>1 then exitlong(nextbar,atopen);endif;


//////////////////////  Enter &  Exit Short   //////////////////////////////////////////////////////////////////////////
if c<prox02   and contagiornoinessere<19 and contaflat>1 and contagain<3 {and (GetYear = 2014)} then entershort(nextbar,atopen);endif;
if positiondir=-1 and contagiornoinessere>18 then exitshort(nextbar,atopen);endif;
if positiondir=-1 and getmonth<>meseprec51 then exitshort(nextbar,atopen);endif;
if positiondir=-1 and actual>4.0  and contaopshort<>1 then exitshort(nextbar,atopen);endif;


if positiondir=1  and Max_Gain_perc<3 and contalg>102 then ModifyStopLoss(INPERC,1.50);endif;
if positiondir=-1  and Max_Gain_perc<3 and contash>102  then ModifyStopLoss(INPERC,1.50);endif;

if positiondir=1  and c<tp1up1 and contalg>102 then ModifyStopLoss(INPERC,1.50);endif;
if positiondir=-1  and c>tp1down1 and contash>102  then ModifyStopLoss(INPERC,1.50);endif;
if positiondir=1  and Max_Gain_perc>7 and filtrotrend<10  and contalg>102 then ModifyStopLoss(INPERC,-8.50);endif;
if positiondir=-1  and Max_Gain_perc>7 and filtrotrend<10 and contash>102 then ModifyStopLoss(INPERC,-8.50);endif;

////////////////////////////////   Gain Mensile  /////////////////////////////////////////////////////////////////////
meseprec51=getmonth;
if getMonth <> meseprec9 then
   contagain = 0;
endif;
if IdLastOpClosed > idlastop then
   contagain = contagain + LastTradeClosedPerc;
endif;
idlastop = IdLastOpClosed;
meseprec9=getmonth;

if resarealtime > 0 then
colore= green;
else
colore= red;
endif;
/////////////////////////////////////////////////////////////////////////////////
////////////////////////equity Annuale long e short/////////////////////////////////////
if getyear <> annoprec then
   contagainlong = 0;
endif;
if getyear <> annoprec then
   contagainshort = 0;
endif;
if IdLastOpClosed > idlastopA  and (LastOpClosed = tsEnterLong) then
contagainlong = contagainlong + LastTradeClosedPerc;
endif;
idlastop = IdLastOpClosed;
if IdLastOpClosed > idlastopA  and (LastOpClosed = tsEntershort) then
contagainshort = contagainshort + LastTradeClosedPerc;
//idlastop = IdLastOpClosed;
endif;


//////////////////////// EQUITY Annuale/////////////////////////////////
if getyear <> annoprec then
   contagainAnno = 0;
endif;
if IdLastOpClosed > idlastopA then
   contagainAnno = contagainAnno + LastTradeClosedPerc;
endif;
idlastopA = IdLastOpClosed;
ivp2 = Createviewport(200);
plotchart(contagain, ivp2, COLUPDOWNZERO);
/////////////////////////////////////////////////////////////////////////////////

annoprec=getyear;

////////////////////////////   Plottaggi Vari   ////////////////////////////////////////////////////////////////////////
{Vp1=Createviewport(800);
PlotChart(rangediscesa,Vp1,red,solid,2);
DrawText(1,Vp1, D,rangediscesa , "% ",rangediscesa, red, 12, 2+2,Alright);
PlotChart(rangesalita,Vp1,green,solid,2);
DrawText(2,Vp1 , D,rangesalita , "% ",rangesalita , green, 12, 2+2,Alright);

Vp2=Createviewport(300);
PlotChart(max_rangediscesa,Vp2,red,solid,1);
DrawText(3,Vp2, D,max_rangediscesa , "% max discesa ",max_rangediscesa, red, 12, 2+2,Alleft);
PlotChart(max_rangesalita,Vp2,green,solid,1);
DrawText(4,Vp2 , D,max_rangesalita , "% max salita ",max_rangesalita , green, 12, 2+2,Alleft);

Vp3=Createviewport(300);
PlotChart(filtrotrend,Vp3,red,solid,1);
DrawText(5,Vp3 , D,filtrotrend , "% tendenza ",filtrotrend , green, 10, 1+1,Alright);}

//indzona1=Createviewport(100, 0, true);
{PlotChart(tr_max*(1-TrS_perc_trail/100),0,aqua,solid,1);
PlotChart(tr_min*(1+TrS_perc_trail/100),0,red,solid,1);   }

{indzona2=Createviewport(100, 0, true);
PlotChart(contagain,indzona2,green,solid,2); }

indzona3=Createviewport(200, 0, true);
PlotChart(contagainlong,indzona3,green,solid,2);
PlotChart(contagainshort,indzona3,red,solid,2);
//PlotChart(optotal,indzona3,aqua,solid,3);  }

Indzona4=CreateViewport(200, 0, true);
plotchart(contagainAnno, indzona4,red, solid, 3 );
//DrawText(6,indzona4 ,D ,contagiornoinessere , "giorni borsistici=",contagiornoinessere , red, 10, 2+2,Alleft); }

{indzona5=Createviewport(200, 0, true);
PlotChart(resarealtime,indzona5,colore,solid,3);
DrawText(7,indzona5 ,D ,resarealtime , "resa % RT=",resarealtime , red, 10, 2+2,Alleft); }

No hay comentarios:

Publicar un comentario

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