[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Da nessuna parte senza di te - 4. - pagina 618

 

rigonich

Ho rimosso le staffe per lasciare un numero pari di staffe. Cioè, entrambe le funzioni sono inserite senza parentesi graffe.

Il risultato è il seguente:

int init()
{
    fGet_MineGV();
//... и далее мой код
//...разрыв кода...
if ((SUA==100)&&(zigNN>4.5))
{
BUA=0;
BUA1=0;
}

fSave_MineGV();
//... продолжение моего кода...

Poi dopo tutto il codice EA ho inserito

}
}
}


Comment(fd+f+d);

}
//... тут мой советник закончился


        void fGet_MineGV (string fs_PrefName = "") // префикс имени переменной
     {
        string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
        if (GlobalVariableCheck (ls_Name)) SUA = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
        if (GlobalVariableCheck (ls_Name)) SUA1 = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
        if (GlobalVariableCheck (ls_Name)) BUA = GlobalVariableGet (ls_Name);
        ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
        if (GlobalVariableCheck (ls_Name)) BUA1 = GlobalVariableGet (ls_Name);
     }
               
      void fSave_MineGV (string fs_PrefName = "") // префикс имени переменной
{
 static datetime ldt_NewBar;
 datetime ldaTBeginBar = iTime (Symbol(), 1, 0)
 //---- Сохраняемся в начале каждой минуты
 if (ldt_NewBar == ldaTBeginBar) return;
 ldt_NewBar = ldaTBeginBar;
 //---- Сохраняем поочереди значения каждой переменной
 string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
 GlobalVariableSet (ls_Name, SUA);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
 GlobalVariableSet (ls_Name, SUA1);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
 GlobalVariableSet (ls_Name, BUA);
 ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
  GlobalVariableSet (ls_Name, BUA1);
}

Lo prendo così, dopo l'ultima parentesi graffa, infatti, separatamente dall'EA. È corretto?

Se è giusto, allora questo è ciò che si ottiene dopo la compilazione:

'fGet_MineGV' - function already defined and has a body         K:\TEST\experts\01___AUDUSD.mq4 (1679, 14)
'ls_Name' - variable already defined                            K:\TEST\experts\01___AUDUSD.mq4 (1681, 16)
2 error(s), 0 warning(s)        

Извиняюсь, ошибся, сложно, когда нет кода пнред глазами.Вот так.
Se il codice fosse breve, lo posterei qui e tutti i miei problemi sarebbero risolti rapidamente. MA l'EA ha 1700 linee, più altri 3 indicatori esterni, in cui si fa la maggior parte del calcolo... Quindi solo per posta, ma ovviamente non si fa più gratis.
 
xant:

rigonich

Ho rimosso le staffe per lasciare un numero pari di staffe. Cioè, entrambe le funzioni sono inserite senza parentesi graffe.

Il risultato è il seguente:

Poi dopo tutto il codice EA ho inserito

Lo prendo così, dopo l'ultima parentesi graffa, infatti, separatamente dall'EA. È corretto?

Se è giusto, allora questo è ciò che si ottiene dopo la compilazione:


Questi avvertimenti dicono che la funzione e la variabile nel tuo EA sono già state definite in precedenza. vedi se hai dimenticato di cancellare il codice che hai inserito prima? se no -- mandami il codice del gufo e ci incollo le funzioni per te.
 
lottamer:


Esattamente. Dovete prima prendere il ticket dell'ultima posizione chiusa GetTicketLastPos , e poi usare le funzioni standard per prendere ciò che vi serve da questo ticket.

Grazie.


Accidenti... non esiste una funzione come GetTicketLastPos,

c'èun ticket GetTicketLastPos per l'ultima posizioneaperta...

 
xant:

rigonich

Ho rimosso le staffe per lasciare un numero pari di staffe. Cioè, entrambe le funzioni sono inserite senza parentesi graffe.

Il risultato è il seguente:

Poi dopo tutto il codice EA ho inserito

Lo prendo così, dopo l'ultima parentesi graffa, infatti, separatamente dall'EA. È corretto?

Se è giusto, allora questo è ciò che si ottiene dopo la compilazione:

Se il codice fosse stato breve, l'avrei postato qui e tutti i miei problemi sarebbero stati risolti rapidamente. MA l'EA ha 1700 linee, più altri 3 indicatori esterni, in cui si fa la maggior parte del calcolo... Quindi solo per posta, ma ovviamente non si fa più gratis.

Penso che questo abbia più senso:

//+------------------------------------------------------------------+
//|                                                       Priner.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


double Var1, Var2, Var3, Var4;// 4-ре переменных для сохранения (у Вас они свои !!!)
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   fGet_MineGV();
//----
//Здесь ваш код
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   //Здесь ваш код
//----
   fSave_MineGV();
   return(0);
  }
//+------------------------------------------------------------------+
void fSave_MineGV (string fs_PrefName = "")     // префикс имени переменной
  {
    static datetime ldt_NewBar;
    datetime ldaTBeginBar = iTime (Symbol(), 1, 0);
//----
    //---- Сохраняемся в начале каждой минуты
    if (ldt_NewBar == ldaTBeginBar) return;
    ldt_NewBar = ldaTBeginBar;
    //---- Сохраняем поочереди значения каждой переменной
    string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
    GlobalVariableSet (ls_Name, Var1);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
    GlobalVariableSet (ls_Name, Var2);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
    GlobalVariableSet (ls_Name, Var3);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
    GlobalVariableSet (ls_Name, Var4);
//----
  }
void fGet_MineGV (string fs_PrefName = "")     // префикс имени переменной
  {
    string ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_1");
//----
    //---- Восстанавливаем значения переменных
    if (GlobalVariableCheck (ls_Name)) Var1 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_2");
    if (GlobalVariableCheck (ls_Name)) Var2 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_3");
    if (GlobalVariableCheck (ls_Name)) Var3 = GlobalVariableGet (ls_Name);
    ls_Name = StringConcatenate (fs_PrefName, Symbol(), "_N_4");
    if (GlobalVariableCheck (ls_Name)) Var4 = GlobalVariableGet (ls_Name);
  }  
//----
 
lottamer:


merda... non esiste una funzione comeun biglietto per l'ultima posizione chiusa,

c'èun ticket GetTicketLastPos per l'ultima posizione aperta...


il biglietto dell'ultima posizione chiusa è nella storia.
 
не забыли ли вы удалить код, который вставляли раньше? если нет -- пришлите мне код сова и я вам вставлю в него функции.

Forse ne è rimasto davvero uno da qualche parte.

L'ho inserito in un altro EA pulito, che non aveva i miei esperimenti, e ha dato altri errori:

'if' - too complex expression     K:\test2\experts\02___AUDUSD.mq4 (1664, 2)
'=' - assignment expected         K:\test2\experts\02___AUDUSD.mq4 (1662, 24)
'if' - semicolon expected         K:\test2\experts\02___AUDUSD.mq4 (1664, 2)
3 error(s), 0 warning(s)        

Comunque, ho inviato un'e-mail a

 

Sto guardando attentamente - ho fatto esattamente come hai scritto.

Ma non ho nessun ritorno o deinit nel mio EA. Va tutto bene? Ricevo ancora errori.

 
xant:

Sto guardando attentamente - ho fatto esattamente come hai scritto.

Ma non ho nessun ritorno o deinit nel mio EA. Va tutto bene? Ricevo ancora errori.

TarasBY ha risposto, ma c'è un piccolo errore nel suo codice, ecco perché il compilatore se ne lamenta.

Nel mio post non ci sono parolacce.
 
rigonich:

l'ultimo biglietto chiuso è nella storia.


Puoi insegnarmi come accedere alla storia?

come faccio a far uscire l'ultimo biglietto?

 

r772ra

Sì! Il compilatore è passato senza errori.

Rispetto!

Motivazione: