Aiuto con pulsanti EA, per favore

 

Publi

Aiuto con pulsanti EA, per favore

 

Publi

Risultati da 1 a 7 di 7

Discussione: Aiuto con pulsanti EA, per favore

  1. #1
    Ciao a tutti,

    Ho un problema che non sono sicuro di come affrontare o descrivere bene, mi dispiace, ma ci proverò.

    Ho scritto un EA con i pulsanti del grafico per aiutarmi nel mio trading manuale, quando l'EA prima carica sul grafico, tutto va bene, posso fare clic sui pulsanti e aspettarmi di ottenere i risultati che voglio, tuttavia, dopo un po 'di tempo (casuale), i pulsanti che utilizzano l'OBJPROP_STATE falsetrue tornano ai loro valori predefiniti, che è falso anche se sembrano veri (clici) sul grafico stesso.

    Ho preso il codice dei pulsanti da un EA qualcuno è stato pagato per il codice per me, forse non è stato scritto bene, forse non so come usarlo bene, non lo so, ma questo mi sta facendo impazzire durante il debugging , tutto funziona fintanto che lo guardo, vado via per un'ora (alcune volte più lungo o più corto di quello), guardo il grafico e mentre tutto sembra a posto, niente funziona finché non faccio di nuovo clic su tutto il clickable affondatopulsanti non inseriti (mi dispiace, non sono sicuro come si chiama).

    Ecco il codice per i pulsanti



    Grazie.


    Codice inserito/ --------------------------------------------- --------------------- /| Funzione di inizializzazione esperta |/ ----------------------------------------------- ------------------- int OnInit () {ObjectCreate (ChartID (), Longs Disabled, OBJ_BUTTON, 0,0,0); ObjectSet (Longs Disabled, OBJPROP_BGCOLOR, clrRed); ObjectSet (Longs Disabled, OBJPROP_CORNER, 1); ObjectSet (Longs Disabled, OBJPROP_YDISTANCE, 60); ObjectSet (Longs Disabled, OBJPROP_XDISTANCE, 120); ObjectSet (Longs Disabled, OBJPROP_XSIZE, 120); ObjectSet (Longs Disabled, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), Longs Disabled, OBJPROP_TEXT, Longs Disabled); ObjectSet (Longs Disabled, OBJPROP_COLOR, White); ObjectCreate (ChartID (), Shorts Disabled, OBJ_BUTTON, 0,0,0); ObjectSet (Shorts Disabled, OBJPROP_BGCOLOR, clrRed); ObjectSet (Shorts Disabled, OBJPROP_CORNER, 1); ObjectSet (Shorts Disabled, OBJPROP_YDISTANCE, 90); ObjectSet (Shorts Disabled, OBJPROP_XDISTANCE, 120); ObjectSet (Shorts Disabled, OBJPROP_XSIZE, 120); ObjectSet (Shorts Disabled, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), Shorts Disabled, OBJPROP_TEXT, Shorts Disabled); ObjectSet (Shorts Disabled, OBJPROP_COLOR, White); ObjectCreate (ChartID (), Close All, OBJ_BUTTON, 0,0,0); ObjectSet (Chiudi tutto, OBJPROP_BGCOLOR, clrRed); ObjectSet (Close All, OBJPROP_CORNER, 1); ObjectSet (Close All, OBJPROP_YDISTANCE, 120); ObjectSet (Close All, OBJPROP_XDISTANCE, 120); ObjectSet (Close All, OBJPROP_XSIZE, 120); ObjectSet (Close All, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), Close All, OBJPROP_TEXT, Close All); ObjectSet (Chiudi tutto, OBJPROP_COLOR, Bianco); ObjectCreate (ChartID (), portatori di handicap, OBJ_BUTTON, 0,0,0); ObjectSet (disabili, OBJPROP_BGCOLOR, clrRed); ObjectSet (disabili, OBJPROP_CORNER, 1); ObjectSet (disabili, OBJPROP_YDISTANCE, 150); ObjectSet (disabili, OBJPROP_XDISTANCE, 120); ObjectSet (disabili, OBJPROP_XSIZE, 120); ObjectSet (disabili, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), portatori di handicap, OBJPROP_TEXT, disabili); ObjectSet (disabili, OBJPROP_COLOR, Bianco); ObjectCreate (ChartID (), Compro, OBJ_BUTTON, 0,0,0); ObjectSet (Buy, OBJPROP_BGCOLOR, clrGreen); ObjectSet (Buy, OBJPROP_CORNER, 1); ObjectSet (Buy, OBJPROP_YDISTANCE, 180); ObjectSet (Buy, OBJPROP_XDISTANCE, 120); ObjectSet (Buy, OBJPROP_XSIZE, 120); ObjectSet (Buy, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), Compro, OBJPROP_TEXT, Buy); ObjectSet (Buy, OBJPROP_COLOR, Bianco); ObjectCreate (ChartID (), Cina, OBJ_BUTTON, 0,0,0); ObjectSet (Vendita, OBJPROP_BGCOLOR, clrGreen); ObjectSet (Sell, OBJPROP_CORNER, 1); ObjectSet (Sell, OBJPROP_YDISTANCE, 210); ObjectSet (Sell, OBJPROP_XDISTANCE, 120); ObjectSet (Sell, OBJPROP_XSIZE, 120); ObjectSet (Sell, OBJPROP_YSIZE, 30); ObjectSetString (ChartID (), Cina, OBJPROP_TEXT, Cina); ObjectSet (Vendita, OBJPROP_COLOR, Bianco); ritorno (INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- / -------------------------- ---------------------------------------- /| Funzione ChartEvent|/ ----------------------------------------------- ------------------- void OnChartEvent (const int id, const long lparam, const double dparam, const string sparam) {if (id == CHARTEVENT_OBJECT_CLICK) {if ( sparam == Longs Disabled) {if (AllowLongs) {AllowLongs = false; ObjectSetInteger (ChartID (), Longs Disabled, OBJPROP_STATE, false); ObjectSetInteger (ChartID (), Longs Disabled, OBJPROP_BGCOLOR, clrRed); ObjectSetString (ChartID (), Longs Disabled, OBJPROP_TEXT, Longs Disabled); } else {AllowLongs = true; ObjectSetInteger (ChartID (), Longs Disabled, OBJPROP_STATE, true); ObjectSetInteger (ChartID (), Longs Disabled, OBJPROP_BGCOLOR, clrGreen); ObjectSetString (ChartID (), Longs Disabled, OBJPROP_TEXT, Longs Enabled); }} if (sparam == Shorts Disabled) {if (AllowShorts) {AllowShorts = false; ObjectSetInteger (ChartID (), Shorts Disabled, OBJPROP_STATE, false); ObjectSetInteger (ChartID (), Shorts Disabled, OBJPROP_BGCOLOR, clrRed); ObjectSetString (ChartID (), Shorts Disabled, OBJPROP_TEXT, Shorts Disabled); } else {AllowShorts = true; ObjectSetInteger (ChartID (), Shorts Disabled, OBJPROP_STATE, true); ObjectSetInteger (ChartID (), Shorts Disabled, OBJPROP_BGCOLOR, clrGreen); ObjectSetString (ChartID (), Shorts Disabled, OBJPROP_TEXT, Shorts abilitato); }} if (sparam == Chiudi tutto) {CloseAll (); ObjectSetInteger (ChartID (), Close All, OBJPROP_STATE, false); } if (sparam == Disabled) {if (NotDisabled) {NotDisabled = false; ObjectSetInteger (ChartID (), Disabled, OBJPROP_STATE, false); ObjectSetInteger (ChartID (), Disabled, OBJPROP_BGCOLOR, clrRed); ObjectSetString (ChartID (), Disabled, OBJPROP_TEXT, Disabled); } else {NotDisabled = true; ObjectSetInteger (ChartID (), Disabled, OBJPROP_STATE, true); ObjectSetInteger (ChartID (), Disabled, OBJPROP_BGCOLOR, clrGreen); ObjectSetString (ChartID (), Disabled, OBJPROP_TEXT, Enabled); }} if (sparam == Buy) {if (NotDisabled) {UpCycle (); } ObjectSetInteger (ChartID (), Buy, OBJPROP_STATE, false); } if (sparam == Sell) {if (NotDisabled) {DownCycle (); } ObjectSetInteger (ChartID (), Sell, OBJPROP_STATE, false); }}}/ -------------------------------------------- ----------------------

  2. #2

    Citazione Originariamente Scritto da ;
    Controlla lo stato dell'oggetto - non assumere lo stato e poi funzionerà
    Grazie per la risposta. Non sei sicuro di cosa intendi con questo. ?? un pulsante, o si fa clic o no, no? Mi sto perdendo qualcosa qui?

  3. #3

    Citazione Originariamente Scritto da ;
    {quote} Grazie per aver risposto. Non sei sicuro di cosa intendi con questo. ?? un pulsante, o si fa clic o no, no? Mi sto perdendo qualcosa qui?
    Sì. Non stai controllando lo stato del pulsante, ma stai solo controllando che un evento sia stato regio con il nome del pulsante. Hai bisogno di qualcosa come ... Codice inserito ... if (sparam == button.Name () button.State ()) ...

  4. #4

    Citazione Originariamente Scritto da ;
    {quote} Sì. Non stai controllando lo stato del pulsante, ma stai solo controllando che un evento sia stato regio con il nome del pulsante. Hai bisogno di qualcosa come ... ... se (sparam == button.Nome () button.State ()) ...
    Grazie per l'esempio, lo cercherò e lo aggiungerò al mio codice. Ma come è collegato al fatto che clicco sul pulsante, succede qualcosa (permettendo l'apertura automatizzata di lunghi scambi, f.e.) e dopo un po 'vedo che il pulsante è ancora clico, ma la funzione ad essa legata non è in esecuzione. Fare nuovamente clic sul pulsante on e off riavvia il ciclo. Quello che mi piacerebbe risolvere è che se è clico dovrebbe rimanere clico e non mostrare se stesso come clico.

  5. #5
    Citazione Originariamente Scritto da ;
    {quote} Grazie per l'esempio, cercherò di aggiungerlo al mio codice. Ma come è collegato al fatto che clicco sul pulsante, succede qualcosa (permettendo l'apertura automatizzata di lunghi scambi, f.e.) e dopo un po 'vedo che il pulsante è ancora clico, ma la funzione ad essa legata non è in esecuzione. Fare nuovamente clic sul pulsante on e off riavvia il ciclo. Quello che mi piacerebbe risolvere è che se è clico dovrebbe rimanere clico e non mostrare se stesso come clico.
    Segui i consigli dei tuoi anziani e controlla lo stato del maledetto pulsante!
    Inoltre, è necessario ripristinare lo stato del pulsante su false al termine della funzione. Codice inserito se (sparam == button.Name () button.State ()) {some_func (); button.State (false); }

  6. #6
    Citazione Originariamente Scritto da ;
    {quote} Segui i consigli dei tuoi anziani e controlla lo stato del maledetto pulsante!
    Inoltre, è necessario ripristinare lo stato del pulsante su false al termine della funzione. if (sparam == button.Name () button.State ()) {some_func (); button.State (false); }
    Sono quindi il codice ora sembra qualcosa del genere, sto già impostando lo stato nel codice, quindi ho appena aggiunto la funzione ButtonState () che restituisce true o false in base allo stato del pulsante, devo aver fatto qualcosa di sbagliato o non ha fatto t capisco perché ora devo cliccare 2-3 volte fino a quando il pulsante ha il testo e lo stato corretti. Perché è così difficile? Ho controllato il mio codice originale e restituisce TrueFalse di conseguenza quando si fa clic, cosa può rendere lo stato di un pulsante diverso da quello moo sullo schermo? Grazie
    Codice inserito bool ButtonState (stringa ButtonName) {if (ObjectGetInteger (0, ButtonName, OBJPROP_STATE) == true) {return true; } else {return false; }} void OnChartEvent (const int id, const long lparam, const double dparam, const string sparam) {if (id == CHARTEVENT_OBJECT_CLICK) {if (sparam == Longs ButtonState (Longs)) {if (AllowLongs) {AllowLongs = false ; ObjectSetInteger (ChartID (), Longs, OBJPROP_STATE, false); ObjectSetInteger (ChartID (), Longs, OBJPROP_BGCOLOR, clrRed); ObjectSetString (ChartID (), Longs, OBJPROP_TEXT, Longs Disabled); } else {AllowLongs = true; ObjectSetInteger (ChartID (), Longs, OBJPROP_STATE, true); ObjectSetInteger (ChartID (), Longs, OBJPROP_BGCOLOR, clrGreen); ObjectSetString (ChartID (), Longs, OBJPROP_TEXT, Longs Enabled); } ..........

  7. #7
    Se questo è il caso, hai sicuramente un problema a monte con qualunque logica stia impostando il bool di AllowLongs. Inoltre è possibile semplificare la funzione di controllo dello stato solo per: Codice inserito bool buttonState (stringa button_name) {return ObjectGetInteger (0, button_name, OBJPROP_STATE); }

Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •  
Il sito di forexmad utilizza cookie
Il sito di forexmad utilizza cookie, alcuni dei quali già installati. Per avere maggiori informazioni sui nostri cookie ti preghiamo di cliccare qui. Ti preghiamo di cliccare sul bottone a destra per accettare i nostri cookie. Se continui a navigare sul sito di forexmad assumeremo che sei d'accordo ad utilizzarli.