[ARCHIVIO]Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Non posso andare da nessuna parte senza di te - 5. - pagina 227

 

Cari colleghi professionisti, ho bisogno del vostro aiuto (pli-is). Voglio fare una funzione nel mio EA che visualizza una notifica nell'angolo posteriore dello schermo circa il trend corrente su diversi timeframes e l'inversione imminente. Sto usando le mie funzioni LinearRegression e Diverg per questo scopo, ma non ho mai lavorato con la funzioneComment e quindi non riesco a capire dove ho sbagliato. Comunque, come risultato del seguente codice viene visualizzata la scritta "Trend W = Down", ma voglio avere informazioni anche su altri TF.

void UPDN ()
{
if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diver_Per_H1, 0) < 0) Comment("Trend H1 = Up");
if(Diverg(LR_TFr_1,0,Diver_Per_H1)<0) Comment("...!Pivot su H1 = Giù");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) < 0) Comment("Trend H4 = Su");
if(Diverg(LR_TFr_2,0,Diver_Per_H4)<0) Comment("...!Pivot su H4 = Giù");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) < 0) Comment("Trend D1 = Up");
if(Diverg(LR_TFr_3,0,Diver_Per_D1)<0) Comment("..!Pivot su D1 = Giù");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) < 0) Comment("Trend W = Su");
if(Diverg(LR_TFr_4,0,Diver_Per_W)<0) Comment("...!Pivot a W = Down");

if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diver_Per_H1, 0) > 0) Comment("Trend H1 = Down");
if(Diverg(LR_TFr_1,0,Diver_Per_H1)>0) Comment("...!Pivot su H1 = Up");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) > 0) Comment("Trend H4 = Down");
if(Diverg(LR_TFr_2,0,Diver_Per_H4)>0) Comment("...!Pivot su H4 = Up");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) > 0) Comment("Trend D1 = Down");
if(Diverg(LR_TFr_3,0,Diver_Per_D1)>0) Comment("...!Pivot su D1 = Up");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) > 0) Comment("Trend W = Down");
if(Diverg(LR_TFr_4,0,Diver_Per_W)>0) Comment("....W = Up");
return(0);
}

 
Optim:

Cari colleghi-professionisti, ho bisogno del vostro aiuto (pli-is). Voglio fare una funzione nel mio EA che visualizza una notifica nell'angolo posteriore dello schermo circa il trend corrente su diversi timeframes e l'inversione imminente. Sto usando le funzioni LinearRegression e Diverg per questo scopo, ma non ho mai lavorato con la funzione Comment e quindi non riesco a capire dove ho sbagliato. Comunque, il codice qui sotto visualizza solo il messaggio "Trend W = Down" ma voglio che mi informi su altri TF.

void UPDN ()
{
if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diverg_Per_H1, 0) < 0) Comment("Trend H1 = Up")
if(Diverg(LR_TFr_1,0,Diver_Per_H1)<0) Comment("...!Girare in H1 = Giù");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diverg_Per_H4, 0) < 0) Comment("Trend H4 = Up")
se(Diverg(LR_TFr_2,0,Diver_Per_H4)<0) Comment("...!Inversione di tendenza H4 = Down")
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) < 0) Comment("Trend D1 = Up")
if(Diverg(LR_TFr_3,0,Diver_Per_D1)<0) Comment("...!Pivot su D1 = Down");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) < 0) Comment("Trend W = Up");
se(Diverg(LR_TFr_4,0,Diver_Per_W)<0) Comment(";)

if(LinearRegression(Symbol( ), LR_TFr_1, 0, Diverg_Per_H1, 0) > 0) Comment("Trend H1 = Down")
se(Diverg(LR_TFr_1,0,Diver_Per_H1)>0) Comment("...!Inversione tendenza H1 = Su");
if(LinearRegression(Symbol( ), LR_TFr_2, 0, Diver_Per_H4, 0) > 0) Comment("Trend H4 = Down")
se(Diverg(LR_TFr_2,0,Diver_Per_H4)>0) Comment("...!H4 trend reversal = Up");
if(LinearRegression(Symbol( ), LR_TFr_3, 0, Diver_Per_D1, 0) > 0) Comment("Trend D1 = Down")
if(Diverg(LR_TFr_3,0,Diver_Per_D1)>0) Comment("...!Pivot su D1 = Up");
if(LinearRegression(Symbol( ), LR_TFr_4, 0, Diver_Per_W, 0) > 0) Comment("Trend W = Down");
se(Diverg(LR_TFr_4,0,Diver_Per_W)>0) Comment("...!Diverg a W = Up")
ritorno(0);
}


voidComment(...)
La funzione emette un commento definito dall'utente nell'angolo superiore sinistro del grafico. I parametri possono essere di qualsiasi tipo. Il numero di parametri non può superare 64.

Gli array non possono essere passati a Comment(). Gli array devono essere stampati elemento per elemento.

I dati di tipo doppio vengono emessi con 4 cifre decimali dopo il punto. Per stampare numeri con maggiore precisione, usate la funzioneDoubleToStr().
I tipi bool, datetime e colore saranno stampati come numeri.
Per emettere dati datetime come una stringa, usate la funzioneTimeToStr().

Per dividere l'output in più righe, puoi usare il carattere di avanzamento di riga "\n" o "\r\n".
Vedere ancheAlert() ePrint().
Parametri:
...-Qualsiasi valore, separato da virgole.
Esempio:
 double free=AccountFreeMargin(); Comment("Il margine libero del conto è ",DoubleToStr(free,2),"\n", "L'ora corrente è ",TimeToStr(TimeCurrent());
 
Almeno leggete la documentazione prima di fare domande. Metà delle risposte sono già lì
 

Grazie, ho capito. Ho bisogno di inserire le variabili secondo i risultati delle funzioni LinearRegression e Diverg per ogni TF e poi emetterle con un commento, può essere in più righe.

 
Optim:

Grazie, ho capito. Ho bisogno di inserire le variabili secondo i risultati delle funzioni LinearRegression e Diverg per ogni TF e poi emetterle con un commento, può essere in più righe.


C'è solo una limitazione in termini di lunghezza delle linee. Puoi usare la funzione di Alexander Pak. Se non riesci a trovarlo, lo cercherò io stesso
 

Cari signori!

Ho una domanda sul passaggio di un array per riferimento.

Lo schema dell'algoritmo è il seguente:

Passiamo un array per riferimento da una libreria all'altra.

Lo copiamo lì usando la funzione integrata:

ArrayCopy.

Poi, l'array passato per riferimento viene usato

nel primo modulo.

Ma per qualche motivo, si verifica un errore, e non sempre.

Cioè, a volte l'array viene copiato, a volte no.

Qual è la ragione?

La voce di registro è la seguente:

21:07:12 openHistory CADCHF,H1:

2 gamme di array per la funzione ArrayCopy (0 e 4)

Collegare il modulo

Copia

 
Roger:
Questo perché hai copiato male il mio esempio. Guardate attentamente dove è la i e dove è la k.

Corretto il codice secondo il vostro.
Durante i test, quattro ordini hanno chiuso nell'ordine in cui sono stati impostati sul primo tick, il quinto ha chiuso sul tick successivo. Probabilmente qui c'è qualcos'altro che non va, dato che l'ho testato molte volte.
Vi sto fornendo il codice del programma e i log del tester.
Sinceramente. Shurkin

Код программы.
//+------------------------------------------------------------------+
//|                                                     Poligon1.mq4 |
//|                                            21 февраля 2013 года. |
//|Тестирование оператора цикла for.                                 |
//+------------------------------------------------------------------+
#property copyright "21 февраля 2013 года."
#property link      ""
//+------------------------------------------------------------------+
//|Объявленные переменные                                            |
//+------------------------------------------------------------------+
int Mn=357;//Magic number
int i;//Показатель счётчика итераций
double PriTP;//TP серии
int Tick;//Счётчик тиков
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----Установка серии ордеров
OrderSend(Symbol(),OP_BUY,0.5,Ask,0,NormalizeDouble(Bid-35*Point,Digits),
NormalizeDouble(Ask+35*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,1,Ask,0,NormalizeDouble(Bid-25*Point,Digits),
NormalizeDouble(Ask+25*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,1.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,2.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUY,3.5,Ask,0,NormalizeDouble(Bid-15*Point,Digits),
NormalizeDouble(Ask+15*Point,Digits),NULL,Mn,0,CLR_NONE);//OP_BUY
OrderSend(Symbol(),OP_BUYLIMIT,1,NormalizeDouble(Ask-15*Point,Digits),0,
NormalizeDouble(Bid-40*Point,Digits),NormalizeDouble(Ask+25*Point,Digits),
NULL,Mn,0,CLR_NONE);//OP_BUYLIMIT
OrderSend(Symbol(),OP_SELLSTOP,3,NormalizeDouble(Ask-30*Point,Digits),0,
NormalizeDouble(Bid+15*Point,Digits),NormalizeDouble(Ask-75*Point,Digits),
NULL,Mn,0,CLR_NONE);//OP_SELLSTOP
//----
   PriTP=Bid;//PriTP
   Print("Кс0:"," OrdersTotal=",OrdersTotal());//Сообщение
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   Tick++;//Tick
//   Print("Кс0:"," Tick=",Tick);//Сообщение
//----
//   for(i=0;i<OrdersTotal();i++)//Инициализация цикла
//   for(i=OrdersTotal()-1; i>=0; i--)//
   for(i=0, int k=0; i<OrdersTotal();i++,k++)//
   {
   Print("Кс1:"," Tick=",Tick," i=",i," k=",k);//Сообщение
   if(OrderSelect(k,SELECT_BY_POS,MODE_TRADES)==true)//Выбор ордера k
    {
   if(OrderSymbol()==Symbol())//Символ
     {
   if(OrderMagicNumber()==Mn)//Идентификационное число
      {
   if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)//Тип операции текущего выбранного ордера
       {
   OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);//Закрытие позиции
   k--;//?
       }//Закрыто if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)
      }//Закрыто if(OrderMagicNumber()==Mn)
     }//Закрыто if(OrderSymbol()==Symbol()
    }//Закрыто if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
   }//Закрыто for(i=0, int k=0; i<OrdersTotal();i++,k++)
/*   
   for(i=0, int k=0; i<OrdersTotal();i++,k++)//
   {
   Print("Кс1:"," Tick=",Tick," i=",i," k=",k);//Сообщение
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)//Выбор ордера i
    {
   if(OrderSymbol()==Symbol())//Символ
     {
   if(OrderMagicNumber()==Mn)//Идентификационное число
      {
   if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)//Тип операции текущего выбранного ордера
       {
   OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);//Закрытие позиции
   k--;//Зачем сначала прибавлять и тут же убавлять ???
       }//Закрыто if(OrderType()==OP_BUY && OrderTakeProfit()>PriTP)
      }//Закрыто if(OrderMagicNumber()==Mn)
     }//Закрыто if(OrderSymbol()==Symbol()
    }//Закрыто if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
   }//Закрыто for(i=0;i<OrdersTotal();i++)
*/   
//----
   return(0);
  }
//+------------------------------------------------------------------+
Записи в журнале тестера.
2013.03.18 13:58:21     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=4 i=1 k=1
2013.03.18 13:58:21     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=4 i=0 k=0
2013.03.18 13:57:57     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=3 i=1 k=1
2013.03.18 13:57:57     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=3 i=0 k=0
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=2 i=1 k=0
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: close #5 buy 3.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3394
2013.03.18 13:57:33     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=2 i=0 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #4 buy 2.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=3 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #3 buy 1.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=2 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #2 buy 1.00 EURUSD at 1.3397 sl: 1.3370 tp: 1.3422 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=1 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: close #1 buy 0.50 EURUSD at 1.3397 sl: 1.3360 tp: 1.3432 at price 1.3395
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ1: Tick=1 i=0 k=0
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: Êñ0: OrdersTotal=7
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #7 sell stop 3.00 EURUSD at 1.3367 sl: 1.3410 tp: 1.3322 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #6 buy limit 1.00 EURUSD at 1.3382 sl: 1.3355 tp: 1.3422 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #5 buy 3.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #4 buy 2.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #3 buy 1.50 EURUSD at 1.3397 sl: 1.3380 tp: 1.3412 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #2 buy 1.00 EURUSD at 1.3397 sl: 1.3370 tp: 1.3422 ok
2013.03.18 13:57:09     2013.02.11 12:15  Poligon1 EURUSD,M15: open #1 buy 0.50 EURUSD at 1.3397 sl: 1.3360 tp: 1.3432 ok
2013.03.18 13:57:09     Poligon1 test started
2013.03.18 13:57:02     Poligon1 EURUSD,M15: loaded successfully
 
Dove è il posto migliore per dichiarare un tipo di variabile (int, double, ecc.) in termini di riduzione del consumo di risorse dell'esecuzione del programma. Per esempio, int i può essere dichiarato globalmente o in int start() ... for (int i=OrdersTotal()-1; i>=0; i--) ... Ho la sensazione che dichiararlo ad ogni tick sia più costoso che dichiararlo una volta a livello globale, subito dopo i parametri extern. O la differenza di intensità di risorse è la stessa?
 
Zhunko:
Dovete fare il loop dell'inizio. Lavorare all'interno dell'anello. Lì si può fare di tutto.

Questo è un po' diverso. quando la connessione viene persa, il log dice "Ping failed". significa che ci sono dei fi uti, ma non sono documentati per qualche motivo.
Quanto del carico sulla CPU e sulla memoria è aumentato dal looping?

 
Dimka-novitsek:

Buona sera! Scusatemi, vorrei ritornare su un problema irrisolto.

'Buy' - tipi incompatibili D:\TeleTRADE\experts\cleaner.mq4 (102, 53)

'Sell' - tipi incompatibili D:\TeleTRADE\experts\clearlist.mq4 (102, 79)


if (!Pishem&&PozyProstavleny){SaveArray(FileBuy, Buy); SaveArray(FileSell, Sell); Pishem=1;}

Questa linea non si compila.
Motivazione: