jueves, 1 de agosto de 2019

metto il codice del ts 50% modificato

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: contatp1up,contatp1down,meseprec,meseprec8,meseprec51,resarealtime,colore;
Var: rischio,rischioup,rischiodown,contagainlong,contagainshort,meseprec90,condizionedicembre;
Var: indzona1,indzona2,indzona3,indzona4,indzona5;
Var: condizioneoro,condizioneargento,condizionebronzo,filtrorange;

/////////////________ Range da openmese al rialzo ,al ribasso e totale__________///////////
rangeminimi=(((openm-lowm)/openm)*100);
rangemassimi=(((highm-openm)/openm)*100);
percentualemese=rangeminimi+rangemassimi;
filtrorange=abs(rangemassimi-rangeminimi);
//////////////___________calcolo diario 20 % range sviluppo mensile///////////////////////////////////////////////////////////////////////////////
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);
//////////////////////___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;
/////////////////////////__Nuovo Giorno_____////////////////////////////////////////////////////

cambiatogiorno = GetValues(days, 1, prova, prova, prova, prova);
if getmonth<>meseprec18 then contagiornoinessere=0;endif;
if cambiatogiorno then contagiornoinessere=contagiornoinessere+1;endif;
meseprec18=getmonth;
////////////______openmese e 2 livelli 2%______////////////////////////
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, 10, 1+3,Alleft);
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);
////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////__Conteggio operazioni_________////////////////////////////////////////////////////////////////////////

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;


//////////////////______Resa in tempo reale del mese____//////////////////////////////////////////////////////////////////////////
resarealtime=actual+contagain;
///////////////////_______ differenze tra escursione range mese e resa______////////////
//rischio=op(percentualemese,resarealtime,divis);
rischioup=op(rangemassimi,resarealtime,divis);
rischiodown=op(rangeminimi,resarealtime,divis);



if contagiornoinessere>15 and(GetMonth = 12) then condizionedicembre=1;else condizionedicembre=0;endif;
/////////////////////////    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 condizionedicembre=0 and rischioup<10 then enterlong(nextbar,atopen);endif;

if positiondir=1 and contagiornoinessere>18 then exitlong(nextbar,atopen,STOP, 0,"Exit Long 1");endif;
if positiondir=1 and getmonth<>meseprec51 then exitlong(nextbar,atopen,STOP, 0,"Exit Long 2");endif;
if positiondir=1 and actual>4.0  and contaoplong<>1 then exitlong(nextbar,atopen,STOP, 0,"Exit Long 3");endif;
if positiondir=1 and contalg>68 and rischioup>20  then exitlong(nextbar,atopen,STOP, 0,"Exit Long 4");endif;
if positiondir=1 and contagiornoinessere>15 and(GetMonth = 12) then exitlong(nextbar,atopen,STOP, 0,"Exit Long 5");endif;


/////////////////////   Enter & Exit Short   //////////////////////////////////////////////////////////////////////////
if c<prox02   and contagiornoinessere<19 and contaflat>1 and contagain<3 and condizionedicembre=0 and rischiodown<10 then entershort(nextbar,atopen);endif;

if positiondir=-1 and contagiornoinessere>18 then exitshort(nextbar,atopen,STOP, 0,"Exit Short 1");endif;
if positiondir=-1 and getmonth<>meseprec51 then exitshort(nextbar,atopen,STOP, 0,"Exit Short 2");endif;
if positiondir=-1 and actual>4.0  and contaopshort<>1 then exitshort(nextbar,atopen,STOP, 0,"Exit Short 3");endif;
if positiondir=-1  and contash>68 and rischiodown>20  then exitshort(nextbar,atopen,STOP, 0,"Exit Short 4");endif;
if positiondir=-1 and contagiornoinessere>15 and(GetMonth = 12) then exitshort(nextbar,atopen,STOP, 0,"Exit Short 5");endif;

/////////////__________ModifiStopLoss_____________////////////////////////////////////////////
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 filtrorange<1 and contalg>34 then ModifyStopLoss(INPERC,1.50, "SLMODIFY");endif;
if positiondir=-1  and filtrorange<1 and contash>34  then ModifyStopLoss(INPERC,1.50, "SLMODIFY");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 contagain<>contagain[1] and (LastOpClosed = tsEnterLong) then
contagainlong = contagainlong + LastTradeClosedPerc;
endif;
idlastop = IdLastOpClosed;
if contagain<>contagain[1] and (LastOpClosed = tsEntershort) then
contagainshort = contagainshort + LastTradeClosedPerc;
endif;
if getMonth <> meseprec90 then
   contagainlong = 0;
endif;
if getMonth <> meseprec90 then
   contagainshort = 0;
endif;
meseprec90=getmonth;

if resarealtime > 0 then
colore= green;
else
colore= red;
endif;
////////////////////////////   Plottaggi Vari   ////////////////////////////////////////////////////////////////////////

indzona1=Createviewport(200, 0, true);
PlotChart(contagain,indzona1,green,solid,2);
PlotChart(contagainlong,indzona1,green,solid,1);
PlotChart(contagainshort,indzona1,red,solid,1);
PlotChart(resarealtime,indzona1,colore,solid,3);
DrawText(6,indzona1 ,D ,resarealtime , "resa % RT=",resarealtime , red, 10, 2+2,Alleft);

{indzona2=Createviewport(200, 0, true);
PlotChart(contaoplong,indzona2,green,solid,2);
PlotChart(contaopshort,indzona2,red,solid,2);
PlotChart(optotal,indzona2,aqua,solid,3); }

{Indzona3=CreateViewport(50, 0, true);
plotchart(contagiornoinessere, indzona3,green, solid, 1 );
DrawText(5,indzona3 ,D ,contagiornoinessere , "giorni borsistici=",contagiornoinessere , red, 10, 2+2,Alleft);}

indzona4=Createviewport(200, 0, true);
PlotChart(percentualemese,indzona4,green,solid,3);
PlotChart(rangemassimi,indzona4,aqua,solid,2);
PlotChart(rangeminimi,indzona4,red,solid,2);

indzona5=Createviewport(200, 0, true);
PlotChart(rischioup,indzona5,green,solid,2);
PlotChart(rischiodown,indzona5,red,solid,2);

1 comentario:

  1. Grazie Bruno sempre disponibile e generoso.... tieni duro per tutto il resto...vedrai che tornerai in ottima forma. Un saluto.

    ResponderEliminar

 sirtuazione grafica su stellantis da metà  agosto 2026 in fase di rallentamento la discesa un segnale positivo sarebbe lo stazionamento del...