From 908d0e9187d906c515a05453f421ee16331b4a15 Mon Sep 17 00:00:00 2001 From: Pietro Giacobazzi Date: Tue, 16 Jun 2026 20:22:24 +0000 Subject: [PATCH 1/2] PaPP v2 export: scarta i valori EMPTY (DBL_MAX) di warmup; esporta solo barre con tutte le 7 MA valide Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- PaPP v2/PaPP_CrossExport.mq5 | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/PaPP v2/PaPP_CrossExport.mq5 b/PaPP v2/PaPP_CrossExport.mq5 index 1171fe2..92432d8 100644 --- a/PaPP v2/PaPP_CrossExport.mq5 +++ b/PaPP v2/PaPP_CrossExport.mq5 @@ -39,10 +39,14 @@ int TimeToBarsD1(string sym,int d) } //+------------------------------------------------------------------+ -double Median7(double &v[]) // mediana dei valori >0 in v[0..6] +// valore valido = positivo e finito (MT5 usa EMPTY_VALUE=DBL_MAX nei warmup) +bool IsVal(double v) { return (v>0.0 && v<1.0e12); } + +//+------------------------------------------------------------------+ +double Median7(double &v[]) // mediana dei valori validi in v[0..6] { double a[]; int c=0; ArrayResize(a,7); - for(int m=0;m<7;m++) if(v[m]>0) { a[c]=v[m]; c++; } + for(int m=0;m<7;m++) if(IsVal(v[m])) { a[c]=v[m]; c++; } if(c==0) return 0; ArrayResize(a,c); ArraySort(a); if((c&1)==1) return a[c/2]; @@ -138,20 +142,26 @@ void OnStart() for(int i=iStart;i<=iEnd;i++) { if(i0)?(price-med)/med*100.0:0; + double dist_med = (price-med)/med*100.0; double cmax=-1, cmin=1e18; - for(int k=2;k0){ if(v>cmax)cmax=v; if(v0 && price>0)?(cmax-cmin)/price*100.0:0; + for(int k=2;kcmax)cmax=v; if(v0){ if(v>cmaxP)cmaxP=v; if(v0)?(cmaxP-cminP)/S[i-KSLOPE][0]*100.0:0; + for(int k=2;kcmaxP)cmaxP=v; if(vma365 && ma365>0)?1:-1; - double atr_pct = (price>0)?atr[i]/price*100.0:0; + int trend = (price>ma365)?1:-1; + double atr_pct = atr[i]/price*100.0; MqlDateTime dt; TimeToStruct(tm[i],dt); //--- esito globale: ritorno alla Mediana entro MAXH @@ -160,7 +170,7 @@ void OnStart() int jmax = MathMin(i+MAXH,n-1); for(int j=i+1;j<=jmax;j++) { - if(S[j][0]<=0 || S[j][1]<=0) continue; + if(!IsVal(S[j][0]) || !IsVal(S[j][1])) continue; int sj=(S[j][0]>S[j][1])?1:-1; if(b2rev<0 && sj!=side) b2rev=j-i; double d=(S[j][0]-S[j][1])/S[j][1]*100.0; @@ -171,15 +181,14 @@ void OnStart() for(int a=0;a0) dir=1; else if(d0>=0 && d1<0) dir=-1; if(dir==0) continue; - double slope_a = (S[i-KSLOPE][a]>0)?(S[i][a]-S[i-KSLOPE][a])/S[i-KSLOPE][a]*100.0:0; - double slope_b = (S[i-KSLOPE][b]>0)?(S[i][b]-S[i-KSLOPE][b])/S[i-KSLOPE][b]*100.0:0; + double slope_a = (S[i][a]-S[i-KSLOPE][a])/S[i-KSLOPE][a]*100.0; + double slope_b = (S[i][b]-S[i-KSLOPE][b])/S[i-KSLOPE][b]*100.0; double thr = 0.25*atr_pct; string row = StringFormat("%s,%s,%sx%s,%s,%s,%d,", From f930e8859206763a5bf935bb5e7587d59a130b7c Mon Sep 17 00:00:00 2001 From: Pietro Giacobazzi Date: Wed, 17 Jun 2026 06:26:03 +0000 Subject: [PATCH 2/2] PaPP v2 export: aggiunta traiettoria forward bar-by-bar (cret_1..20) per studiare lo sviluppo dopo l'incrocio Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- PaPP v2/PaPP_CrossExport.mq5 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PaPP v2/PaPP_CrossExport.mq5 b/PaPP v2/PaPP_CrossExport.mq5 index 92432d8..fe95235 100644 --- a/PaPP v2/PaPP_CrossExport.mq5 +++ b/PaPP v2/PaPP_CrossExport.mq5 @@ -134,6 +134,7 @@ void OnStart() string s=IntegerToString(gHor[hh]); head += ",ret_"+s+",mfe_"+s+",mae_"+s+",dir_"+s+",rev_"+s; } + for(int b=1;b<=MAXH;b++) head += ",cret_"+IntegerToString(b); // traiettoria forward bar-by-bar head += ",bars_to_revert,disc_max_pct"; FileWriteString(fh,head+"\r\n"); @@ -216,6 +217,13 @@ void OnStart() row += ","+DoubleToString(ret,5)+","+DoubleToString(mfe,5)+"," +DoubleToString(mae,5)+","+IntegerToString(dlab)+","+IntegerToString(rev); } + //--- traiettoria: rendimento cumulato a +1..+MAXH barre + for(int b=1;b<=MAXH;b++) + { + int iB=i+b; + if(iB>n-1) { row += ","; continue; } + row += ","+DoubleToString((cl[iB]-cl[i])/cl[i]*100.0,5); + } row += ","+(b2rev>0?IntegerToString(b2rev):"")+","+DoubleToString(discMax,5); FileWriteString(fh,row+"\r\n"); rows++;