sorgente del ts 50%
lo stoploss è al 3% ma anche mettendolo al 2 o al 1.5% il report non peggiora di molto
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//_____________________________Ts 50%_______________________gennaio 2019____//
Var: 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: cambiatogiorno,prova,contagiornoinessere;
Var: Pr_Ingr(0), Max_Gain(0), Max_Gain_perc(0), Gain(0),condizioneA,condizioneB;
Var: vp1,vp2,vp3,vp4,vp5;
Var: meseprec,meseprec8,meseprec9,contagain;
Var: condizionenolungo,condizionenocorto{,condiztrimestrale};
Var: contaoplong,contaopshort,meseprec48;
Var: contagainlong,contagainshort,idlastop,meseprec99,resamedialong,resamediashort;
Var: condizionelgno,condizioneshno;
///////////////////////////////////////////////////////////////////////////////////////////////////
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, 14, 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 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;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if contagiornoinessere>15 and c<tp1up1 then condizionenolungo=1;else condizionenolungo=0;endif;
if contagiornoinessere>15 and c>tp1down1 then condizionenocorto=1;else condizionenocorto=0;endif;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if positiondir=1 and contalg=1 then contaoplong=contaoplong+1;endif;
if getmonth<>meseprec48 then contaoplong=0;endif;
if positiondir=-1 and contash=1 then contaopshort=contaopshort+1;endif;
if getmonth<>meseprec48 then contaopshort=0;endif;
meseprec48=getmonth;
resamedialong= OP (contagainlong,contaoplong,divis);
resamediashort= OP (contagainshort,contaopshort,divis);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if contagiornoinessere>10 and resamediashort>2 then condizionelgno=1;else condizionelgno=0;endif;
if contagiornoinessere>10 and resamedialong>2 then condizioneshno=1;else condizioneshno=0;endif;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
installstoploss(inperc,3.00,"Stop");
plotchartNoZero(getstoploss, 0, red, solid, 2);
DrawText(NEWOGG,0 , D,getstoploss , "sl",getstoploss , red, 25, 1+4,Alright);
//////////////////////////////////////////____________LONG___________________/////////////////////////////////////////////////////////
if c>highd(1) and condizionelgno=0//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%
and rangemassimi<10
then enterlong( nextbar,atopen,STOP, 0,"Enter Lg 1");endif;
///////////////////// Exit Long ///////////////////////////////////////////////////////////////////////////////////////////
if positiondir=1 and contalg>20 and gain<1.00 and c<wmed {intraday} then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 1");endif;
if positiondir=1 and condizionenolungo=1 and gain>0.40 then exitlong(nextbar,atopen,STOP,0,"Exit Lg 2");endif;
//if positiondir=1 and c<dvmed {ieri} then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 3");endif;
//////////////////////////////////////////____________SHORT___________________/////////////////////////////////////////////////////////
if c<lowd(1) and condizioneshno=0 //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%
and rangeminimi<10 //entra solo se il range mese è inferiore a 21
then entershort(nextbar,atopen,STOP, 0,"Enter Sh 1" );endif;
//////////////////// Exit Short ////////////////////////////////////////////////////////////////////////////////////////////
if positiondir=-1 and contash>20 and gain<1.00 and c>wmed {intraday} then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 1");endif;
if positiondir=-1 and condizionenocorto=1 and gain>0.40 then exitshort(nextbar,atopen,STOP,0,"Exit Sh 2");endif;
//if positiondir=-1 and c>dvmed {ieri} then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 3");endif;
//////////////////////// EQUITY MENSILE/////////////////////////////////
if getMonth <> meseprec then
contagain = 0;
endif;
if IdLastOpClosed > idlastop then
contagain = contagain + LastTradeClosedPerc;
endif;
idlastop = IdLastOpClosed;
////////////////////////equity long e short/////////////////////////////////////
if contagain<>contagain[1] and (LastOpClosed = tsEnterLong) then
contagainlong = contagainlong + LastTradeClosedPerc;
endif;
if contagain<>contagain[1] and (LastOpClosed = tsEntershort) then
contagainshort = contagainshort + LastTradeClosedPerc;
endif;
if getMonth <> meseprec99 then
contagainlong = 0;
endif;
if getMonth <> meseprec99 then
contagainshort = 0;
endif;
meseprec99=getmonth;
//_________Plottaggi__________//
vp1 = Createviewport(250);
Plotchart(contaoplong,vp1,green,solid,2);
Plotchart(contaopshort,vp1,red,solid,2);
vp2=Createviewport(200);
Plotchart(contagainlong,vp2,green,solid,2);
Plotchart(contagainshort,vp2,red,solid,2);
vp3=Createviewport(200);
Plotchart(resamedialong,vp3,green,solid,2);
Plotchart(resamediashort,vp3,red,solid,2);
lo stoploss è al 3% ma anche mettendolo al 2 o al 1.5% il report non peggiora di molto
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//_____________________________Ts 50%_______________________gennaio 2019____//
Var: 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: cambiatogiorno,prova,contagiornoinessere;
Var: Pr_Ingr(0), Max_Gain(0), Max_Gain_perc(0), Gain(0),condizioneA,condizioneB;
Var: vp1,vp2,vp3,vp4,vp5;
Var: meseprec,meseprec8,meseprec9,contagain;
Var: condizionenolungo,condizionenocorto{,condiztrimestrale};
Var: contaoplong,contaopshort,meseprec48;
Var: contagainlong,contagainshort,idlastop,meseprec99,resamedialong,resamediashort;
Var: condizionelgno,condizioneshno;
///////////////////////////////////////////////////////////////////////////////////////////////////
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, 14, 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 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;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if contagiornoinessere>15 and c<tp1up1 then condizionenolungo=1;else condizionenolungo=0;endif;
if contagiornoinessere>15 and c>tp1down1 then condizionenocorto=1;else condizionenocorto=0;endif;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if positiondir=1 and contalg=1 then contaoplong=contaoplong+1;endif;
if getmonth<>meseprec48 then contaoplong=0;endif;
if positiondir=-1 and contash=1 then contaopshort=contaopshort+1;endif;
if getmonth<>meseprec48 then contaopshort=0;endif;
meseprec48=getmonth;
resamedialong= OP (contagainlong,contaoplong,divis);
resamediashort= OP (contagainshort,contaopshort,divis);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if contagiornoinessere>10 and resamediashort>2 then condizionelgno=1;else condizionelgno=0;endif;
if contagiornoinessere>10 and resamedialong>2 then condizioneshno=1;else condizioneshno=0;endif;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
installstoploss(inperc,3.00,"Stop");
plotchartNoZero(getstoploss, 0, red, solid, 2);
DrawText(NEWOGG,0 , D,getstoploss , "sl",getstoploss , red, 25, 1+4,Alright);
//////////////////////////////////////////____________LONG___________________/////////////////////////////////////////////////////////
if c>highd(1) and condizionelgno=0//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%
and rangemassimi<10
then enterlong( nextbar,atopen,STOP, 0,"Enter Lg 1");endif;
///////////////////// Exit Long ///////////////////////////////////////////////////////////////////////////////////////////
if positiondir=1 and contalg>20 and gain<1.00 and c<wmed {intraday} then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 1");endif;
if positiondir=1 and condizionenolungo=1 and gain>0.40 then exitlong(nextbar,atopen,STOP,0,"Exit Lg 2");endif;
//if positiondir=1 and c<dvmed {ieri} then exitlong(nextbar,atopen,STOP, 0,"Exit Lg 3");endif;
//////////////////////////////////////////____________SHORT___________________/////////////////////////////////////////////////////////
if c<lowd(1) and condizioneshno=0 //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%
and rangeminimi<10 //entra solo se il range mese è inferiore a 21
then entershort(nextbar,atopen,STOP, 0,"Enter Sh 1" );endif;
//////////////////// Exit Short ////////////////////////////////////////////////////////////////////////////////////////////
if positiondir=-1 and contash>20 and gain<1.00 and c>wmed {intraday} then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 1");endif;
if positiondir=-1 and condizionenocorto=1 and gain>0.40 then exitshort(nextbar,atopen,STOP,0,"Exit Sh 2");endif;
//if positiondir=-1 and c>dvmed {ieri} then exitshort(nextbar,atopen,STOP, 0,"Exit Sh 3");endif;
//////////////////////// EQUITY MENSILE/////////////////////////////////
if getMonth <> meseprec then
contagain = 0;
endif;
if IdLastOpClosed > idlastop then
contagain = contagain + LastTradeClosedPerc;
endif;
idlastop = IdLastOpClosed;
////////////////////////equity long e short/////////////////////////////////////
if contagain<>contagain[1] and (LastOpClosed = tsEnterLong) then
contagainlong = contagainlong + LastTradeClosedPerc;
endif;
if contagain<>contagain[1] and (LastOpClosed = tsEntershort) then
contagainshort = contagainshort + LastTradeClosedPerc;
endif;
if getMonth <> meseprec99 then
contagainlong = 0;
endif;
if getMonth <> meseprec99 then
contagainshort = 0;
endif;
meseprec99=getmonth;
//_________Plottaggi__________//
vp1 = Createviewport(250);
Plotchart(contaoplong,vp1,green,solid,2);
Plotchart(contaopshort,vp1,red,solid,2);
vp2=Createviewport(200);
Plotchart(contagainlong,vp2,green,solid,2);
Plotchart(contagainshort,vp2,red,solid,2);
vp3=Createviewport(200);
Plotchart(resamedialong,vp3,green,solid,2);
Plotchart(resamediashort,vp3,red,solid,2);
No hay comentarios:
Publicar un comentario