jueves, 15 de marzo de 2018

x Matteo
ti metto il codice sorgente sulle tue indicazioni di ieri
entrata a mercato con le due condizioni(superamento massimi/minimi di ieri,superamento massimi/minimi 1ª candela 15 min.)
sl del 3%
niente spostamento stoploss
inserimenti filtro del 5% ( ma per ora solo visivo...non nelle stringhe)
report a 14 anni

//__________________________Matteo 13 marzo 2018________________________//

Var: input1,input2;
Var: newday(false), mioopen(0), miomin(0), miomax(0), mioclose(0),metaieri;
Var: wmax,wmin,metaoggi,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: meseprec9;
Var: condizionelong,condizioneshort,contalong,contashort,numerogiornilong,numerogiornishort,contalungo,contacorto,entratalong,entratashort;
Var: primadiff,secondiff,terzadiff,totaldiff,totaldiff1,vp1;

/////////////////////////////////////////////////////////////////////////////////////////////////////
if IsFirstBarDay then input1=H;endif;
if IsFirstBarDay then input2=L;endif;
{plotchart(input1, 0 , green, dot, 1);
plotchart(input2, 0 , red, dot, 1); }
/////////////////////////////////////////////////////////////////////////////////////////////////////
newday=GetValues(days,1,mioopen,miomin,miomax,mioclose);
metaieri= 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]);
   metaoggi=wmax-(wmax-wmin)*0.5;
endif;

{PlotChart(metaoggi,0, gray, dot, 1);
Plotchart(metaieri,0,blue,solid,1);
DrawText(NEWOGG,0 , D,metaoggi , "50% intraday",metaoggi , red, 12, 2+2,Alright);
DrawText(NEWOGG,0 , D,metaieri , "50% ieri",metaieri , 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 c>highd(1)  and c>input1 then condizionelong=1;endif;
if  c<lowd(1)  and c<input2 then condizionelong=0;contalong=0;endif;
if c<lowd(1)   and c<input2 then condizioneshort=1;endif;
if c>highd(1)  and c>input1 then condizioneshort=0;contashort=0;endif;
if condizionelong=1 then contalong=contalong+1;endif;
numerogiornilong=op(contalong,34,divis);
if condizioneshort=1 then contashort=contashort+1;endif;
numerogiornishort=op(contashort,34,divis);
////////////////////////////////////////////////////////////////////////////////////////////////
                                                                                              //
if condizionelong=1   then entratalong=o;endif;                                               //
if condizioneshort=1  then entratashort=o;endif;                                              //
if Condizionelong=1 and contalungo>1 then entratalong=entratalong[1];endif;                   //
if CondizioneShort=1 and contacorto>1 then entratashort=entratashort[1];endif;                //  tenuta in memoria ultime 2 entrate ( short e long )
If Condizionelong=1 and contalungo=1 then DrawVline (NEWOGG, 0, getdate, green, 1, 0);endif;  //
If Condizioneshort=1 and contacorto=1 then DrawVline (NEWOGG, 0, getdate, red, 1, 0);endif;   //
                                                                                              //
////////////////////////////////////////////////////////////////////////////////////////////////

if condizionelong=1 then contalungo=contalungo+1;endif;                                        //
if condizioneshort=1 then contacorto=contacorto+1;endif;                                       //
if condizionelong=1 then contacorto=0;endif;                                                   //
if condizioneshort=1 then contalungo=0;endif;                                                  //
plotchart(entratalong, 0 , green, solid, 1);                                                   //
plotchart(entratashort, 0 , red, solid, 1);                                                    //
DrawText(NEWOGG,0 , D,entratalong , "last price lg",entratalong, green, 12, 1+4,Alleft);       //
DrawText(NEWOGG,0 , D,entratashort , "last price sh",entratashort , red, 12, 1+4,Alleft);      //
/////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
primadiff=abs(entratashort-entratalong);
secondiff=abs(entratashort-c);
totaldiff=abs(((primadiff+secondiff)/entratalong)*100);
terzadiff=abs(c-entratalong);
totaldiff1=abs(((primadiff+terzadiff)/entratashort)*100);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
installstoploss(inperc,3.00,"SL", STARTNEXTBAR);
plotchartNoZero(getstoploss, 0, red, solid, 2);
DrawText(NEWOGG,0 , D,getstoploss , "sl",getstoploss , red, 15, 1+4,Alright);


//////////////////////////////////////////____________LONG___________________/////////////////////////////////////////////////////////
if condizionelong=1   then EnterLong(nextbar,atopen);endif;

if condizioneshort=1  then Entershort(nextbar,atopen);endif;

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

vp1 = Createviewport(550);
Plotchart(totaldiff,VP1,GREEN,solid,2);
DrawHLine (NEWOGG, vp1, 5, red, 2, 0);



3 comentarios:

  1. Grazie per l'aggiornamento Bruno. Per solo visivo intendi che è comunque considerato nella generazione dei valori presenti nel report a 14 anni. Dico brne?
    Ciao e buona giornata

    Matteo

    ResponderEliminar
  2. intendo che viene plottato nella parte inferiore del grafico ma non è inserito come condizione nelle stringhe...se lo si inserisce i risultati rispetto al report sopra sono= resa assoluta totale 594%..operazioni 702...positive 253...negative 447...consecutive pos. 4..consecutive neg.11..tempo a mercato 87%...profitto medio 0.85%...praticamente toglie 300 negative..rimane un 13% meno a mercato e la resa scende di un 200%

    ResponderEliminar
  3. prevedevo un calo della resa e delle operazioni, ma mi aspettavo più del 13% di tempo non a mercato. non penso sia la soluzione migliore. comunque grazie. Matteo

    ResponderEliminar

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