Indicatore Domande varie - pagina 11

 
Puoi vedere il mio codice di esempio in questo commento #99
 

Oh ok quel codice.

ObjectCreate() ha bisogno anche dell'ID del grafico:

bool  ObjectCreate(
   long         chart_id,      // chart identifier
   string       name,          // object name
   ENUM_OBJECT  type,          // object type
   sub_window   nwin,          // window index
   datetime     time1,         // time of the first anchor point
   double       price1,        // price of the first anchor point
   ...
   datetime     timeN=0,       // time of the N-th anchor point
   double       priceN=0,      // price of the N-th anchor point
   ...
   datetime     time30=0,      // time of the 30th anchor point
   double       price30=0      // price of the 30th anchor point
   );

Come primo parametro.

int OnInit()
  {
   Print("Outside");

   ObjectCreate("Object Outside",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Object Outside",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Object Outside",OBJPROP_YDISTANCE,20);
   ObjectSetString(0,"Object Outside",OBJPROP_TEXT,"Outside");

   if(DayOfWeek()==5)
     {
      Print("Inside");

      ObjectCreate("Object Inside",OBJ_LABEL,0,0,0);
      ObjectSetInteger(0,"Object Inside",OBJPROP_XDISTANCE,20);
      ObjectSetInteger(0,"Object Inside",OBJPROP_YDISTANCE,40);
      ObjectSetString(0,"Object Inside",OBJPROP_TEXT,"Inside");
     }
  }

Ma si inizia con il nome dell'oggetto.

Inoltre puoi specificare un angolo base/punto di ancoraggio.

Si prega di vedere: https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_label

//+------------------------------------------------------------------+
//| Create a text label                                              |
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=0,               // chart's ID
                 const string            name="Label",             // label name
                 const int               sub_window=0,             // subwindow index
                 const int               x=0,                      // X coordinate
                 const int               y=0,                      // Y coordinate
                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring
                 const string            text="Label",             // text
                 const string            font="Arial",             // font
                 const int               font_size=10,             // font size
                 const color             clr=clrRed,               // color
                 const double            angle=0.0,                // text slope
                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor type
                 const bool              back=false,               // in the background
                 const bool              selection=false,          // highlight to move
                 const bool              hidden=true,              // hidden in the object list
                 const long              z_order=0)                // priority for mouse click
  {
//--- reset the error value
   ResetLastError();
//--- create a text label
   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": failed to create text label! Error code = ",GetLastError());
      return(false);
     }
//--- set label coordinates
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- set the chart's corner, relative to which point coordinates are defined
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
//--- set the text
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- set text font
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- set font size
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- set the slope angle of the text
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- set anchor type
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the label by mouse
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution
   return(true);
  }
//+------------------------------------------------------------------+

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_LABEL - Reference on algorithmic/automated trading language for MetaTrader 5
 

Sono solo preoccupato di non essere riuscito a spiegare il mio problema e voglio chiedervi se avete provato, per favore? Allora puoi sapere qual è il mio problema con quel codice.

Ho provato così - 1. Ho aggiunto il mio file di esempio al grafico e poi ho chiuso MT4. 2. Aprire MT4 - poi non vedo il mio oggetto Inside Label.

Questo è quello che cerco di trovare la soluzione al mio problema. : /


Forse sarò sicuro lunedì.

( quando penso che questo è così facile spendo un sacco di tempo per quelle cose facili - quando penso che questo è così difficile che li ho fatti così facilmente... - Quasi tutto quello che voglio fare. prima cerco di leggere la documentazione... )

 

Ho provato e ci sono due oggetti mostrati.

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
      Print("Outside");

   ObjectCreate(0,"Object Outside",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Object Outside",OBJPROP_XDISTANCE,20);
   ObjectSetInteger(0,"Object Outside",OBJPROP_YDISTANCE,20);
   ObjectSetString(0,"Object Outside",OBJPROP_TEXT,"Outside");

   if(DayOfWeek()==5)
     {
      Print("Inside");

      ObjectCreate(0,"Object Inside",OBJ_LABEL,0,0,0);
      ObjectSetInteger(0,"Object Inside",OBJPROP_XDISTANCE,20);
      ObjectSetInteger(0,"Object Inside",OBJPROP_YDISTANCE,40);
      ObjectSetString(0,"Object Inside",OBJPROP_TEXT,"Inside");
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+


 

Fico!

Guarda il mio screenshot, per favore.

c'è un problema

Grazie mille per il suo tempo signor Marco

 

Non mi importa se quella parte di codice mi darà un risultato diverso in Indicatore : /
Provo quella parte di codice nel mio file Indicatore.

(Ho deciso che scriverò del codice nei file degli indicatori, ma non nel mio file Trade Panel. )


2a volta modificato

Ho già usato il tuo metodo - ora funziona senza problemi, spero che funzioni.

Grazie mille signor Marco


#Non Lunedì - Chiuso
 

#Refresh - Aperto

Una volta che ho risolto il mio problema - il mio indicatore funziona bene nella mia piattaforma MT4 principale - ma io uso la seconda piattaforma MT4 che è il mio indicatore ha bisogno di rinfrescare quando avvio la piattaforma MT4.
Non ho idea da dove viene questo problema... che chiedo qualcosa esattamente su questo.

D: Qualcuno può dirmi qualcosa su questa strana situazione, per favore?

Grazie in anticipo.

 

Vuoi dire che sei testimone di un comportamento diverso tra due piattaforme?

Sono la stessa build?

 
Marco vd Heijden:

Vuoi dire che sei testimone di un comportamento diverso tra due piattaforme?

Sono la stessa build?

Sì, assolutamente un comportamento diverso...

Inoltre sì, entrambe le build 1065

 

Forse ho trovato da dove vengono quegli strani problemi...

Qual è il segreto del modello di carico?
C'è qualcosa di mistico, che mi sta distruggendo... che mi sta davvero facendo arrabbiare... - Ho già fatto cose enormi per i miei EA e indicatori che non ho mai speso un sacco di tempo come sto spendendo alcuni problemi minori...

Come? Semplice!

Dopo che ho deciso di non mettere alcuni script nei miei file EA - allora mi trovo continuamente di fronte a problemi minori che non riesco a trovare una soluzione nel SEO. (in realtà a volte trovo facilmente la soluzione ai miei enormi problemi di EA sul SEO - ma questi problemi minori. )

---

Ho messo questo semplice codice nel mio file indicatore di esempio.

int OnInit()
{
  Print( "This Year", Year() );
  return(INIT_SUCCEEDED);
}

Quando provo a caricare questo file di esempio sul mio grafico. Non funziona correttamente finché non cambio TimeFrame.
( è possibile che io sia già stanco oggi )
( so anche che posso risolvere questo problema se metto quel codice in OnCalculate(...) - ma ho solo bisogno di mettere quel codice in OnInit() )

Per favore, ho solo bisogno di una spiegazione più chiara per questo problema. Ne ho davvero bisogno, perché alcuni miei indicatori hanno gli stessi problemi irrilevanti. ( che se metto questo nei file del mio EA funzionerà correttamente )

Grazie in anticipo.
Buon fine settimana.

Motivazione: