[ARQUIVO!] Qualquer pergunta de novato, para não desorganizar o fórum. Profissionais, não passem por aqui. Em nenhum lugar sem você - 4. - página 268

 
okvseok:

como você pode entender estas linhas:

Escreva assim e veja na revista:

//---- return orders volume

if(buys>0){
 Print("buys = ",buys);
 return(buys);
}
else{
 Print("-sells = ",-sells);
 return(-sells);// это эквивалентно команде return(sells*(-1));
}
 

Você pode me dar alguns conselhos?

Utilizo vários indicadores que utilizam a data em variáveis globais

extern bool   shiftdata           = false;
extern string ShiftHistory        = "02.06.2012 00:00";

Se você mudar a data na história, você tem que mudá-la em todos os indicadores.

Eufiz um indicador que envia o valor do turno através do iCustom para as barras int.

Mas o problema é que ela passa a data inalterada que é compilada (02.07.2012), mas quando você a muda manualmente (02.06.2012) ela não é passada!

por que e o que fazer15

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

#property indicator_chart_window
#property indicator_buffers 1
extern string BLOK_______1        = "Работа с историей";
extern string ShiftHistory        = "02.07.2012 00:00";
extern string PERIOD              = "D1";
//---
double buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,buffer);
   SetIndexStyle(0,DRAW_ARROW,0,0);
   SetIndexEmptyValue(0,0.0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int  counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
int i,period,limit,bs,barn;

if(PERIOD=="MN1") period=PERIOD_MN1;
else
if(PERIOD=="W1")  period=PERIOD_W1;
else
if(PERIOD=="D1")  period=PERIOD_D1;
else 
if(PERIOD=="H4")  period=PERIOD_H4;
else
if(PERIOD=="H1")  period=PERIOD_H1;
else
if(PERIOD=="M30") period=PERIOD_M30;
else
if(PERIOD=="M15") period=PERIOD_M15;
else
if(PERIOD=="M5")  period=PERIOD_M5;
else
if(PERIOD=="M1")  period=PERIOD_M1;
else
period=PERIOD_D1;

bs=iBarShift(Symbol(),period,StrToTime(ShiftHistory));
barn=iBars(Symbol(),period);
limit=barn-100;

if(limit>bs)
for(i=barn-1; i>=0; i--)
{
if (i==bs) buffer[i]=bs;
} RefreshRates();
return(0);
}

Aqui está o receptor

for(int y=barn-100; y>=0; y--)
{
int bbb,st=iCustom(Symbol(),PERIOD,"iTime",0,y);
if(st>0) bbb=st;
}
 Comment(bbb);

Comentário escreve turno 16. E em 02.06.2012 deverá ser 48.

Por favor, ajude a aconselhar!

 

ajudar-me a determinar o último alto e baixo de um ziguezague em um EA

duplo zz1;
int start()
{
zz1=iCustom(NULL,0, "ZigZag", 12, 5, 3, 0, 1);
MessageBox("zz1="+zz1,"zz1");
retorno(0);
}
"0,00000" está saindo

 
spek:

ajudar-me a determinar o último alto e baixo de um ziguezague em um EA

duplo zz1;
int start()
{
zz1=iCustom(NULL,0, "ZigZag", 12, 5, 3, 0, 1);
MessageBox("zz1="+zz1,"zz1");
retorno(0);
}
"0,00000" está saindo

double ZZ[10000]={0.0};  //массив для значений ZigZag
double zz1[10000]={0.0};

//-----
int init()
{

}
return(0);
//---
int start()
{
int q=1;   //ПОПРАВИЛ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

for(int i=1; i<=1000; i++)
{
zz1[i]=iCustom(NULL,0,"ZigZag", 12, 5, 3, 0, i);
if(zzl[i]>0) { ZZ[q]=zzl[i];  q++; }
//MessageBox("zz1="+zz1,"zz1");
Comment(ZZ[1],"  ",ZZ[2]);

return(0);
}
 

Quero colocar nele "Alerta()" para me dizer quando a tendência se reverteu.

Quero colocar ali "Alerta()" para me dizer quando a tendência se inverteu.

//+------------------------------------------------------------------+
//|                                                    mikahekin.mq4 |
//|                        Copyright 2004, MetaQuotes Software Corp. |
//|                                                http://www.sasara |
//|                              Modified by: Ronald Verwer/ROVERCOM |
//+------------------------------------------------------------------+
#property copyright "Copyright 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property  indicator_chart_window
#property  indicator_buffers 4
#property  indicator_color1  Silver
#property  indicator_color2  Yellow
#property  indicator_color3  Red
#property  indicator_color4  Blue
#property  indicator_width1 3
#property  indicator_width2 3

//---- input parameters
extern int KPeriod=3;
extern int DPeriod=3;
extern int JPeriod=7;

double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
double ind_buffer4[];
double HighesBuffer[];
double LowesBuffer[];

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
        IndicatorBuffers(6);
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 3);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 3);
   SetIndexStyle(2,DRAW_ARROW, 0, 1);
   SetIndexStyle(3,DRAW_ARROW, 0, 1);
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
   SetIndexDrawBegin(4,10);
   SetIndexDrawBegin(5,10);
//---- indicator buffers mapping
   SetIndexBuffer(0,ind_buffer1);
   SetIndexBuffer(1,ind_buffer2);
   SetIndexBuffer(2,ind_buffer3);
   SetIndexBuffer(3,ind_buffer4);
   SetIndexBuffer(4, HighesBuffer);
   SetIndexBuffer(5, LowesBuffer);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("mikahekin");
   SetIndexLabel(0,"Open");
   SetIndexLabel(1,"Close");
   SetIndexLabel(2,"High");
   SetIndexLabel(3,"Low");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k,j;
   int    counted_bars=IndicatorCounted();
   double price;
   
//----
   if(Bars<=10) return(0);
//---- initial zero
   if(counted_bars<0) return (-1);
//---- minimums  counting
   i=Bars-KPeriod;
   if(counted_bars>KPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      double min=1000000;
      k=i+KPeriod-1;
      while(k>=i)
        {
         price=Low[k];
         if(min>price) min=price;
         k--;
        }
      LowesBuffer[i]=min;
      i--;
     }
//---- maximums counting
   i=Bars-DPeriod;
   if(counted_bars>DPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      double max=-100000;
      j=i+DPeriod-1;
      while(j>=i)
        {
         price=High[j];
         if(price>max) max=price;
         j--;
        }
      HighesBuffer[i]=max;
      i--;
     }
//---- mikahekin calcaulation
   i=Bars-JPeriod;
   if(counted_bars>JPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      double sumlow=0.0;
      double sumhigh=0.0;
      double sumopen=0.0;
      double sumclose=0.0;
      double close=0.0;
      double open=0.0;
      double high=0.0;
      double low=0.0;

      for(k=(i+JPeriod-1);k>=i;k--)
         {
         sumclose+=Close[k];
         close=sumclose/JPeriod;
         sumlow+= LowesBuffer[k];
         low= sumlow/JPeriod;
         sumopen+=Open[k];
         open=sumopen/JPeriod;
         sumhigh+=HighesBuffer[k];
         high=sumhigh/JPeriod;
         }
         
      ind_buffer1[i]=open;
      ind_buffer2[i]=close;
      ind_buffer3[i]=high;
      ind_buffer4[i]=low;

      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Z.I. Sou um pouco melhor no mql4 do que no balé, mas...
 
Zhunko:

1. Não posso acrescentar nada. O que você quiser, devolva-o.

2. O terminal ignora e seu código não ignora, se é assim que ele é construído. A chamada do sistema ignora tanto os parâmetros quanto o valor de retorno. É bastante óbvio. Para onde se volta neste caso?

Só podemos adivinhar na criação do padrão. Os desenvolvedores devem ter procedido a partir da INT padrão.


Chegou um tique, o terminal chama a função start() da EA. Você afirma que o valor retornado por esta função é indiferente ao terminal. Isto está documentado em algum lugar?
 
KoKoS:

Quero colocar nele "Alerta()" para me dizer quando a tendência se reverteu.

Quero usar o "Alerta()" para me dizer quando a tendência se inverte.

Z.U. Sou um pouco melhor no mql4 do que no ballet, mas...


Linhas

#property  indicator_color1  Silver
#property  indicator_color2  Yellow

Acho que os dois primeiros amortecedores são o indicador de uma mudança de tendência. Eles têm placas vermelhas no topo dos castiçais e azuis na parte inferior. Somente a combinação amarelo-cinza funciona como um indicador de inversão de tendência. Para eles, será de acordo:

//---- indicator buffers mapping
   SetIndexBuffer(0,ind_buffer1);// для серого цвета
   SetIndexBuffer(1,ind_buffer2);// для жёлтого цвета
Ali, nos valores desses amortecedores, cavar.
 
Pessoal, avisem sobre a transferência de data através do iCustom. Passa o valor atual compilado, como passar o buffer alterado a nível global? Quando mudo a data, ela ainda passa o mesmo valor.
extern bool   shiftdata           = false;
extern string ShiftHistory        = "02.06.2012 00:00";

Indicador publicado logo acima.....

Ou não muda em nada?????

Vocês poderiam me falar sobre a transferência da data através do iCustom?

 

Por favor, ajudem, se algum de vocês puder, a escrever o código para a seguinte condição:

"se, uma ordem foi fechada pela TakeProfit, depois de cruzar uma média móvel, então não abra mais negócios nessa direção até que o preço cruze a média móvel na direção oposta".

Obrigado antecipadamente por sua ajuda!

 
drknn:

Chegou um tique, o terminal chama a função start() da EA. Você afirma que o valor retornado por esta função é indiferente ao terminal. Isto está documentado em algum lugar?
É da lei romana. Não é proibido, portanto, é permitido. Acima, eu dei um link para a seção de ajuda. Em nosso caso soa assim: nenhum comportamento é descrito, portanto, não importa.