Sto cercando di fare il pulsante di reset del lotto, ma ho bisogno di ottenere un risultatomoltomigliore di questo, ma non posso. (Non mi piacciono tutti i miei ea e gli indicatori Button object perché sono tutti molto brutti come questo. )
Ho bisogno di due cose da voi ragazzi che potete aiutarmi e darmi un buon consiglio, per favore ho davvero bisogno del vostro aiuto. Ho speso un sacco di tempo e non riesco a capire quale sia il problema del mio codice.
Grazie in anticipo.
//--- seconda volta modificata - mentre scrivo questo commento forse stavo dormendo...
ObjectCreate ( 0, "button lot reset", OBJ_BUTTON , 0, 0, 0 ); ObjectSetString ( 0, "button lot reset", OBJPROP_TEXT , "x" ); ObjectSetString ( 0, "button lot reset", OBJPROP_FONT , "Verdana" ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_FONTSIZE , 14 ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_XDISTANCE , 16 ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_YDISTANCE , 16 ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_XSIZE , 18 ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_YSIZE , 18 ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_CORNER , CORNER_LEFT_UPPER ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_COLOR , White ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_BGCOLOR , Black ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_BORDER_COLOR , Black ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_STATE , false ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_BACK , false ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTABLE , false ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTED , false ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_HIDDEN , true ); ObjectSetInteger ( 0, "button lot reset", OBJPROP_ZORDER , true );
//+------------------------------------------------------------------+ //| Create the button | //+------------------------------------------------------------------+ bool ButtonCreate(constlong chart_ID=0, // chart's ID conststring name="Button", // button name constint sub_window=0, // subwindow index constint x=0, // X coordinate constint y=0, // Y coordinate constint width=50, // button width constint height=18, // button height constENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // chart corner for anchoring conststring text="Button", // text conststring font="Arial", // font constint font_size=10, // font size constcolor clr=clrBlack, // text color constcolor back_clr=C'236,233,216', // background color constcolor border_clr=clrNONE, // border color constbool state=false, // pressed/released constbool back=false, // in the background constbool selection=false, // highlight to move constbool hidden=true, // hidden in the object list constlong z_order=0) // priority for mouse click { //--- reset the error value ResetLastError(); //--- create the button if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0)) { Print(__FUNCTION__, ": failed to create the button! Error code = ",GetLastError()); return(false); } //--- set button coordinates ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); //--- set button size ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width); ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height); //--- 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 text color ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); //--- set background color ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr); //--- set border color ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr); //--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); //--- set button state ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state); //--- enable (true) or disable (false) the mode of moving the button 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); } //+------------------------------------------------------------------+
Per favore, potete usare la funzione dalla documentazione 'così com'è' per creare i pulsanti, basta aggiungerla in fondo al vostro codice e potete chiamare la funzione e passare i parametri.
Così poi puoi semplicemente chiamare:
ButtonCreate(...
Anche
whroeder1:
Se è nascosto, come puoi vederlo e cliccarci sopra?
ZORDER non è booleano, è un int 0...
Nascosto è semplicemente nascosto nella lista degli oggetti.
Se è nascosto, come puoi vederlo e cliccarci sopra?
ZORDER non è booleano, è un int 0...
Grazie l'ho aggiustato, era solo un errore. --------------------------------------------
Marco vd Heijden:
Per favore, puoi usare la funzione dalla documentazione 'così com'è' per creare i pulsanti, basta aggiungerla in fondo al tuo codice e puoi chiamare la funzione e passare i parametri.
Quindi puoi semplicemente chiamare:
ButtonCreate(...)
Grazie Marco che mi aiuterà molto, e i codici del mio EA sembrano puliti. Inoltre ho bisogno di chiedere del codice sottostante, cos'è, come funziona?(anche io ho letto qualcosa a riguardo, ma non capisco più chiaramente)
Per favore spiegalo un po' di più, grazie in anticipo.
ObjectSetString ( 0, name, OBJPROP_TOOLTIP , tip );
----------------------------------------
Inoltre ho bisogno di usare void invece di bool come il codice sottostante, quindiquale va bene?
La funzione restituisce true o false a seconda che la creazione del pulsante abbia avuto successo o meno, quindi dipende da voi se volete verificare che il pulsante sia stato effettivamente creato.
Per la seconda domanda il tooltip è ciò che diventa visibile quando passi il mouse sopra l'oggetto sul grafico.
La funzione restituisce true o false a seconda che la creazione del pulsante abbia avuto successo o meno, quindi dipende da voi se volete verificare che il pulsante sia stato effettivamente creato.
Per la seconda domanda il tooltip è ciò che diventa visibile quando passi il mouse sopra l'oggetto sul grafico.
Ho bisogno di usare il formato di file .PNG nel mio codice EA, per l'icona LotSize. Ma ho trovato solo il formato di file .BMP, quindi qualcuno può aiutarmi/consigliarmi?
Se qualsiasi commento potrebbe rapidamente molto apprezzato, solo io sono fretta un po 'di più. Grazie in anticipo.
Provo a se lotsize meglio allora lotvalue 'State true' altrimenti 'State false'. (quando clicco su 'Reset' l'oggetto diventa 'State false' e dopo aver aumentato la dimensione del lotto lo stato non diventa true)
Il codice qui sotto è sbagliato?
//| Lot Reset if ( sparam == _namelotRset ) { if ( _lotSize > _lotValue ) { ObjectSetInteger( 0, sparam, OBJPROP_STATE, true ); } //---if Close else { ObjectSetInteger( 0, sparam, OBJPROP_STATE, false ); } //---if Close _lotSize = _lotValue * _lotMin;
_infoUpdate(); return; } //---if Close
Grazie!
//--- seconda volta modificato
Provo a fare girare'ON OFF' con il seguente codice.
Standard Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_BITMAP - Reference on algorithmic/automated trading language for MetaTrader 5
Sto cercando di fare il pulsante di reset del lotto, ma ho bisogno di ottenere un risultatomoltomigliore di questo, ma non posso.
(Non mi piacciono tutti i miei ea e gli indicatori Button object perché sono tutti molto brutti come questo. )
Ho bisogno di due cose da voi ragazzi che potete aiutarmi e darmi un buon consiglio, per favore ho davvero bisogno del vostro aiuto.
Ho speso un sacco di tempo e non riesco a capire quale sia il problema del mio codice.
Grazie in anticipo.
//--- seconda volta modificata - mentre scrivo questo commento forse stavo dormendo...
ObjectSetString ( 0, "button lot reset", OBJPROP_TEXT , "x" );
ObjectSetString ( 0, "button lot reset", OBJPROP_FONT , "Verdana" );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_FONTSIZE , 14 );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_XDISTANCE , 16 );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_YDISTANCE , 16 );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_XSIZE , 18 );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_YSIZE , 18 );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_CORNER , CORNER_LEFT_UPPER );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_COLOR , White );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BGCOLOR , Black );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BORDER_COLOR , Black );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_STATE , false );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_BACK , false );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTABLE , false );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_SELECTED , false );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_HIDDEN , true );
ObjectSetInteger ( 0, "button lot reset", OBJPROP_ZORDER , true );
//| Create the button |
//+------------------------------------------------------------------+
bool ButtonCreate(const long chart_ID=0, // chart's ID
const string name="Button", // button name
const int sub_window=0, // subwindow index
const int x=0, // X coordinate
const int y=0, // Y coordinate
const int width=50, // button width
const int height=18, // button height
const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // chart corner for anchoring
const string text="Button", // text
const string font="Arial", // font
const int font_size=10, // font size
const color clr=clrBlack, // text color
const color back_clr=C'236,233,216', // background color
const color border_clr=clrNONE, // border color
const bool state=false, // pressed/released
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 the button
if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0))
{
Print(__FUNCTION__,
": failed to create the button! Error code = ",GetLastError());
return(false);
}
//--- set button coordinates
ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
//--- set button size
ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);
ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);
//--- 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 text color
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set background color
ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);
//--- set border color
ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- set button state
ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);
//--- enable (true) or disable (false) the mode of moving the button 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);
}
//+------------------------------------------------------------------+
Per favore, potete usare la funzione dalla documentazione 'così com'è' per creare i pulsanti, basta aggiungerla in fondo al vostro codice e potete chiamare la funzione e passare i parametri.
Così poi puoi semplicemente chiamare:
Anche
Grazie l'ho aggiustato, era solo un errore.
--------------------------------------------
Per favore, puoi usare la funzione dalla documentazione 'così com'è' per creare i pulsanti, basta aggiungerla in fondo al tuo codice e puoi chiamare la funzione e passare i parametri.
Quindi puoi semplicemente chiamare:
Grazie Marco che mi aiuterà molto, e i codici del mio EA sembrano puliti.
Inoltre ho bisogno di chiedere del codice sottostante, cos'è, come funziona? (anche io ho letto qualcosa a riguardo, ma non capisco più chiaramente)
Per favore spiegalo un po' di più, grazie in anticipo.
----------------------------------------
Inoltre ho bisogno di usare void invece di bool come il codice sottostante, quindiquale va bene?
// or
void ButtonCreate(...)
La funzione restituisce true o false a seconda che la creazione del pulsante abbia avuto successo o meno, quindi dipende da voi se volete verificare che il pulsante sia stato effettivamente creato.
Per la seconda domanda il tooltip è ciò che diventa visibile quando passi il mouse sopra l'oggetto sul grafico.
Il modo in cui stai lavorando ora ha dei limiti.
Se vuoi approfondire leggi i seguenti articoli:
https://www.mql5.com/en/search#!keyword=graphical%20interfaces&module=mql5_module_articles
La funzione restituisce true o false a seconda che la creazione del pulsante abbia avuto successo o meno, quindi dipende da voi se volete verificare che il pulsante sia stato effettivamente creato.
Per la seconda domanda il tooltip è ciò che diventa visibile quando passi il mouse sopra l'oggetto sul grafico.
Il modo in cui stai lavorando ora ha dei limiti.
Se vuoi approfondire leggi i seguenti articoli:
https://www.mql5.com/en/search#!keyword=graphical%20interfaces&module=mql5_module_articles
Un enorme grazie.
WOW, amico, tu sarai il mio uomo, signor Marco.
( dal tuo primo commento - mi hai aiutato molto - cerchi sempre di capire le mie preoccupazioni - ancora una volta un enorme grazie )
Ho bisogno di usare il formato di file .PNG nel mio codice EA, per l'icona LotSize.
Ma ho trovato solo il formato di file .BMP, quindi qualcuno può aiutarmi/consigliarmi?
Se qualsiasi commento potrebbe rapidamente molto apprezzato, solo io sono fretta un po 'di più.
Grazie in anticipo.
Provo a se lotsize meglio allora lotvalue 'State true' altrimenti 'State false'.
(quando clicco su 'Reset' l'oggetto diventa 'State false' e dopo aver aumentato la dimensione del lotto lo stato non diventa true)
Il codice qui sotto è sbagliato?
if ( sparam == _namelotRset )
{
if ( _lotSize > _lotValue )
{
ObjectSetInteger( 0, sparam, OBJPROP_STATE, true );
} //---if Close
else
{
ObjectSetInteger( 0, sparam, OBJPROP_STATE, false );
} //---if Close
_lotSize = _lotValue * _lotMin;
_infoUpdate();
return;
} //---if Close
Grazie!
//--- seconda volta modificato
Provo a fare girare'ON OFF' con il seguente codice.
Si prega di vedere:
https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_bitmap
Per il problema della bitmap.
E per l'altro problema puoi dividerlo in parti separate per impostare lo stato al di fuori di sparam.