[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate. Non posso andare da nessuna parte senza di te. - pagina 160
Ti stai perdendo delle opportunità di trading:
- App di trading gratuite
- Oltre 8.000 segnali per il copy trading
- Notizie economiche per esplorare i mercati finanziari
Registrazione
Accedi
Accetti la politica del sito e le condizioni d’uso
Se non hai un account, registrati
Se durante il test visivo dell'EA 1.mq4 (allegato) metto su un grafico l'indicatore 3-cci-h3 (allegato), allora, come sembrerebbe, con esattamente gli stessi parametri di segnali cci calcolati dell'indicatore e il cci reale (oggetto testo in alto a destra) non coincidono.
PERCHE'?
Perché gli avvisi non funzionano in questo indicatore?
Codice Expert Advisor:
Codice indicatore:
//+------------------------------------------------------------------+
//| i-3CCI-h.mq4 |
//| johnfantom & kimIV |
//| http://www.kimiv.ru |
//| |
//| 02.01.2006 CCI con 3 TF in una bottiglia.
//+------------------------------------------------------------------+
#proprietà copyright "johnfantom & KimIV"
#proprietà link "http://www.kimiv.ru"
#proprietà indicator_separate_window
#proprietà indicator_buffers 1
#property indicator_color1 DodgerBlue
#proprietà indicator_maximum 1.4
#proprietà indicatore_livello1 0
#proprietà indicatore_minimo -1,2
//------- Parametri dell'indicatore esterno -------------------------------
extern int CCI_Period_0 = 14; // periodo CCI per il timeframe corrente
extern int Level_0 = 100; // Livello CCI per il TF corrente
extern int TF_1 = 60; // Numero di minuti nel primo intervallo di tempo
extern int CCI_Period_1 = 14; // periodo CCI per il primo TF
extern int Level_1 = 100; // livello CCI per il primo TF
extern int TF_2 = 240; // Numero di minuti del secondo TF
extern int CCI_Period_2 = 14; // periodo CCI per il secondo TF
extern int Level_2 = 100; // livello CCI per il secondo TF
extern int NumberOfBars = 1000; // Numero di barre (0-All)
extern int ExtBars = 3;
int per;
//------- Buffer indicatori ------------------------------------------
doppio buf0[];
//+------------------------------------------------------------------+
//| funzione di inizializzazione dell'indicatore personalizzato
//+------------------------------------------------------------------+
void init() {
IndicatoreCifre(1);
SetIndexBuffer(0, buf0);
SetIndexLabel(0, "i-3CCI-h");
SetIndexStyle (0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexEmptyValue(0, 0);
}
//+------------------------------------------------------------------+
//| funzione di deinizializzazione dell'indicatore personalizzata
//+------------------------------------------------------------------+
void deinit() {
Commento(");
}
//+------------------------------------------------------------------+
//| funzione di iterazione dell'indicatore personalizzata
//+------------------------------------------------------------------+
void start() {
doppio cci0,cci1,cci2;
int nb1, nb2; count;
int LoopBegin, sh;
if (NumberOfBars==0) LoopBegin=Bars-1;
else LoopBegin=NumberOfBars-1;
LoopBegin=MathMin(Bars-1, LoopBegin);
count=IndicatorCounted();
per (sh=conteggio; sh>=0; sh--) {
nb1=iBarShift(NULL, TF_1, Time[sh+1], False);
nb2=iBarShift(NULL, TF_2, Time[sh+1], False);
cci0=iCCI(NULL, 0, CCI_Period_0, PRICE_CLOSE, sh+1);
cci1=iCCI(NULL, TF_1, CCI_Period_1, PRICE_CLOSE, nb1);
cci2=iCCI(NULL, TF_2, CCI_Period_2, PRICE_CLOSE, nb2);
/* doppio cci[3];
cci[0]=cci0;
cci[1]=cci1;
cci[2]=cci2;
stringa s1="cci-0 ***"+DoubleToStr(cci[0],3);
stringa s2="cci-1 ***"+DoubleToStr(cci[1],3);
stringa s3="cci-2 ***"+DoubleToStr(cci[2],3);
stringa str[3];
str[0]=s1;
str[1]=s2;
str[2]=s3;
color col=Lime;
for(int y=0;y<3;y++)
{ObjectCreate("textSignal "+y,OBJ_LABEL,0,0,0,0)
ObjectSet("textSignal "+y,OBJPROP_CORNER,1);
ObjectSet("textSignal "+y,OBJPROP_XDISTANCE,35-25);
ObjectSet("textSignal "+y,OBJPROP_YDISTANCE,y*(20)+20+8);
se(cci[y]>=0)col=Lime; altrimenti col=Red;
se(cci[y]>Livello_0) col=Aqua;
if(cci[y]<-Level_0) col=DarkViolet;
ObjectSetText("textSignal "+y,str[y],15, "Tahoma",col);
}
*/
if (cci0>Level_0 && cci1>Level_1 && cci2>Level_2) {buf0[sh]=1;
if (per != Time[0]) {per = Time[0];
if(sh<=ExtBars && ExtBars!=-1)
Alert(Symbol(),Period()," ",
TimeYear(Time[sh]),",
TimeDay(Time[sh]),",
TimeMonth(Time[sh]),",
TimeHour(Time[sh]),":",
TimeMinute(Time[sh]),",
"Acquisto");}}
if (cci0<-Level_0 && cci1<-Level_1 && cci2<-Level_2) {buf0[sh]=-1;
if (per != Time[0]) {per = Time[0];
if(sh<=ExtBars && ExtBars!=-1)
Alert(Symbol(),Period()," ",
TimeYear(Time[sh]),",
TimeDay(Time[sh]),",
TimeMonth(Time[sh]),",
TimeHour(Time[sh]),":",
TimeMinute(Time[sh])," ",
"Vendita");}}
}
}
//+------------------------------------------------------------------+
Provate da soli, io non riesco proprio a farlo funzionare. Non funziona affatto.
Le linee dovrebbero essere allineate. Ma in pratica è un po' diverso.
Potete dirmi per favore cosa potrebbe essere sbagliato?
Ho fatto una funzione ricorsiva che scrive un valore nel buffer.
Quando è chiamato da indictor funziona bene, quando ho provato a metterlo in EA, la risposta è 0
Quale può essere il problema?
Potete dirmi per favore cosa potrebbe essere sbagliato?
Ho fatto una funzione ricorsiva che scrive un valore nel buffer.
Quando è chiamato da indictor funziona bene, quando ho provato a metterlo in EA, la risposta è 0
Quale può essere il problema?
forse la dimensione del buffer non è impostata?
Ho trovato dove si verifica l'intoppo.
Risulta che IndicatorCounted dà 0 nell'indicatore e -1 nell'Expert Advisor (questa funzione ha un controllo di correttezza - essere >=0, quindi non è considerata nell'Expert Advisor)
Qual è la ragione e come risolvere l'errore?
MT4 build 225, eurusd M1.
Ho trovato dove si verifica l'intoppo.
Risulta che IndicatorCounted dà 0 nell'indicatore e -1 nell'Expert Advisor (questa funzione ha un controllo di correttezza - essere >=0, quindi non è considerata nell'Expert Advisor)
Qual è la ragione e come risolvere l'errore?
MT4 build 225, eurusd M1.
https://docs.mql4.com/ru/customind
if (k>k1+7 && s<(High[1]-(High[1]-Low[1])/2) && bay==true)
{
int t=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,NULL,NULL,"My order #",16384,0,Green);
bay=false;
Print (GetLastError());
}
}
if (s>(High[0]-(High[0]-Low[0])/2) && bay==false)
{
OrderSelect(t,SELECT_BY_TICKET,MODE_TRADES);
Print (GetLastError());
OrderClose(t,0.1,Ask,5,Red);
}
if (k>k1+7 && s<(High[1]-(High[1]-Low[1])/2) && bay==true)
{
int t=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,NULL,NULL,"My order #",16384,0,Green);
bay=false;
Print (GetLastError());
}
}
if (s>(High[0]-(High[0]-Low[0])/2) && bay==false)
{
OrderSelect(t,SELECT_BY_TICKET,MODE_TRADES);
Print (GetLastError());
OrderClose(t,0.1,Ask,5,Red);
}
L'apertura e la chiusura avvengono su tick diversi. E l'Expert Advisor non ricorda più cosa è stato assegnato alla variabile t. O dovrebbe essere globale o statico.
Una variabile globale è definita al di fuori delle funzioni. Oppure può essere dichiarato come int statico
L'apertura e la chiusura avvengono su tick diversi. E l'Expert Advisor non ricorda più cosa è stato assegnato alla variabile t. O dovrebbe essere globale o statico.
Una variabile globale è definita al di fuori delle funzioni. Oppure può essere dichiarato come int statico
grazie mille, l'avevo dimenticato ))
Nell'indicatore che ho impostato (per poi confrontarli con Time[i]):
Poi nel ciclo
Di conseguenza, StrToTime(StartRange) e StrToTime(EndRange) producono degli zeri .
- Perché e come risolvere il problema?