Merge pull request #7 from pietro1991-dot/devin/1781638592-line-end-tags

Co-authored-by: Pietro Giacobazzi <giacobazzipietro@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
pietro1991-dot
2026-06-16 21:37:32 +02:00
committed by GitHub
co-authored by Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
+55 -4
View File
@@ -23,7 +23,8 @@ int gDays[7] = {365,182,121,30,14,7,3};
color gCol[7] = {clrDodgerBlue,clrDeepSkyBlue,clrTurquoise,clrLimeGreen,clrOrange,clrTomato,clrRed}; color gCol[7] = {clrDodgerBlue,clrDeepSkyBlue,clrTurquoise,clrLimeGreen,clrOrange,clrTomato,clrRed};
int hMA[7]; int hMA[7];
int bars[7]; int bars[7];
string _pfx = "PM_"; string _pfx = "PM_"; // oggetti pannello
string _pfx2 = "PME_"; // etichette a fine linea
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
// scrive il valore nel buffer della MA m // scrive il valore nel buffer della MA m
@@ -41,6 +42,23 @@ void SetBuf(int m,int idx,double v)
} }
} }
//+------------------------------------------------------------------+
// legge il valore corrente (barra 0) del buffer della MA m
double GetBuf(int m)
{
switch(m)
{
case 0: return B0[0];
case 1: return B1[0];
case 2: return B2[0];
case 3: return B3[0];
case 4: return B4[0];
case 5: return B5[0];
case 6: return B6[0];
}
return 0;
}
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
int TimeToBars(int d) int TimeToBars(int d)
{ {
@@ -103,6 +121,7 @@ void OnDeinit(const int reason)
{ {
for(int i=0;i<7;i++) if(hMA[i]!=INVALID_HANDLE) IndicatorRelease(hMA[i]); for(int i=0;i<7;i++) if(hMA[i]!=INVALID_HANDLE) IndicatorRelease(hMA[i]);
ObjectsDeleteAll(0,_pfx); ObjectsDeleteAll(0,_pfx);
ObjectsDeleteAll(0,_pfx2);
} }
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
@@ -256,6 +275,7 @@ int OnCalculate(const int rates_total,
} }
DrawInfo(); DrawInfo();
DrawTags(time[0]);
return rates_total; return rates_total;
} }
@@ -284,20 +304,51 @@ void DrawInfo()
double vol = (dc>0)?ds/dc:0; double vol = (dc>0)?ds/dc:0;
Lbl("V","Cluster +/-"+DoubleToString(vol,3)+"%",x,y,FontSize,clrGray,false); y+=lh+2; Lbl("V","Cluster +/-"+DoubleToString(vol,3)+"%",x,y,FontSize,clrGray,false); y+=lh+2;
//--- Valori delle 7 MA (giorni : valore) //--- Valori delle 7 MA (giorni : valore) con colore = linea
for(int m=0;m<7;m++) for(int m=0;m<7;m++)
{ {
double v=GetMA(m,1); double v=GetMA(m,1);
color cma = (v>median)?clrSalmon:clrLightGreen;
Lbl("a"+IntegerToString(m), Lbl("a"+IntegerToString(m),
StringFormat("MA %3dg: %s",gDays[m],DoubleToString(v,_Digits)), StringFormat("MA %3dg: %s",gDays[m],DoubleToString(v,_Digits)),
x,y,FontSize-1,(v>0)?cma:clrGray,false); x,y,FontSize-1,(v>0)?gCol[m]:clrGray,false);
y+=lh-2; y+=lh-2;
} }
y+=2; y+=2;
Lbl("H","Sopra=SELL | Sotto=BUY",x,y,FontSize-1,clrGray,false); Lbl("H","Sopra=SELL | Sotto=BUY",x,y,FontSize-1,clrGray,false);
} }
//+------------------------------------------------------------------+
// etichetta di testo ancorata a (t,price); se price<=0 la rimuove
void Tag(string n,datetime t,double price,string txt,color c)
{
string o=_pfx2+n;
if(price<=0) { ObjectDelete(0,o); return; }
if(ObjectFind(0,o)<0) ObjectCreate(0,o,OBJ_TEXT,0,0,0);
ObjectSetInteger(0,o,OBJPROP_TIME,t);
ObjectSetDouble(0,o,OBJPROP_PRICE,price);
ObjectSetString(0,o,OBJPROP_TEXT," "+txt);
ObjectSetString(0,o,OBJPROP_FONT,"Consolas");
ObjectSetInteger(0,o,OBJPROP_FONTSIZE,FontSize);
ObjectSetInteger(0,o,OBJPROP_COLOR,c);
ObjectSetInteger(0,o,OBJPROP_ANCHOR,ANCHOR_LEFT);
ObjectSetInteger(0,o,OBJPROP_BACK,false);
ObjectSetInteger(0,o,OBJPROP_SELECTABLE,false);
ObjectSetInteger(0,o,OBJPROP_HIDDEN,true);
}
//+------------------------------------------------------------------+
// etichette a fine linea, nel margine vuoto a destra
void DrawTags(datetime tlast)
{
datetime tfut = tlast + 2*PeriodSeconds(_Period);
Tag("med",tfut,Buff_Median[0],"Mediana",clrGold);
for(int m=0;m<7;m++)
{
double p = ShowMA ? GetBuf(m) : 0.0;
Tag(IntegerToString(m),tfut,p,IntegerToString(gDays[m])+"g",gCol[m]);
}
}
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
void Lbl(string n,string t,int x,int y,int fs,color c,bool b) void Lbl(string n,string t,int x,int y,int fs,color c,bool b)
{ {