[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 222

 
What the fuck. It's either FLOOD or a themed forum after all. You should be banned forever for such rubbish.
 

The essence of the question is that I need to count the number of bars in each continuous block of the bar diagram of the top indicator. I wrote such an indicator (the lowest). In it, the value of each bar chart column corresponds to the number of bars in a continuous block of the top indicator, but it starts displaying ONLY since its installation (the red vertical line).I want it to be displayed on the previous bars (like when you install AO or CCI), i.e. the "picture" was similar to the middle indicator (it is the same indicator, but installed even earlier). I will listen to any suggestions with gratitude (preferably with code snippets).

#property indicator_separate_window
#property indicator_minimum -7
#property indicator_maximum 7
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 DarkOrange
#property indicator_width1  2
#property indicator_width2  2
#property indicator_level1 0.0
//--- buffers
double UpMapBuffer[];
double DnMapBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,UpMapBuffer);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,DnMapBuffer);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {   
    
    int i;

    for(i=1;i<Bars;i++)                                                  
     {
      double AO_Sig_Sig_1 = iCustom(NULL,0,"Signal-Signal",0,i);                           
      double AO_Sig_Sig_2 = iCustom(NULL,0,"Signal-Signal",0,i+1);
                  
      if((AO_Sig_Sig_1!=AO_Sig_Sig_2))
       {
        break;
        i=0;
       }                                                                
     }
         
    i=i*(AO_Sig_Sig_1); 
            
    if(i>0)            
     {
      UpMapBuffer[0]=i;
     }
    else
     {
      UpMapBuffer[0]=0;
     } 
         
    if(i<0)         
     {
      DnMapBuffer[0]=i;
     }
    else
     {
      DnMapBuffer[0]=0;
     }            
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
MK07:

The essence of the question is that I need to count the number of bars in each continuous block of the bar diagram of the top indicator. I wrote such an indicator (the lowest). In it, the value of each bar chart column corresponds to the number of bars in a continuous block of the top indicator, but it starts displaying ONLY since its installation (the red vertical line).But I need it to be displayed on previous bars also (like when you install AO or CCI), i.e. the "picture" was similar to the middle indicator (it is the same as lower indicator, but it was installed even earlier).

Something like this?

-

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Bisque
#property indicator_width1 2
#property indicator_width2 2
//===============================
double fx1[],fx2[];
double ao,ao1;
int ti,n,fs;
//******************************************************************
int init()
{
   SetIndexBuffer(0,fx1); SetIndexStyle(0,2);
   SetIndexBuffer(1,fx2); SetIndexStyle(1,2);
   
   SetLevelValue(0,0);
   SetLevelValue(1,10);
   SetLevelValue(2,20);
   SetLevelValue(3,-10);
   SetLevelValue(4,-20);   

   return(0);
}
//******************************************************************
int start()
{
   int cbi=Bars-IndicatorCounted()-1; if (cbi<0) return(-1); 
   if (cbi==1) cbi--;
   if (cbi>1) {cbi=Bars-37; n=0; ti=Time[cbi];}  
   //-------------------------------------------------
   for(int i=cbi; i>=0; i--) 
   {
      if (ti!=Time[i]) {n++; ti=Time[i];}
      
      ao  = iAO(NULL,0,i); 
      ao1 = iAO(NULL,0,i+1); 
      
      if (ao>ao1) {if (fs==2) n=1; fs=1;} else
      if (ao<ao1) {if (fs==1) n=1; fs=2;}
      
      if (fs==1) {fx1[i]=n;  fx2[i]=0;} else
      if (fs==2) {fx2[i]=-n; fx1[i]=0;}
   } 
   
   return(0);
}
//******************************************************************
 
ANG3110:

Something like this?

-


Thank you so much! Just what you need!
 
Hi, could you please tell me why a position opens but the stop and profit does not. Thank you in advance!

int start()
{
double Sl =Low[1];
double Tpb =((High[1]-Open[1])/Tp)+Open;
double bar2b;
if (Open[2]<Close[2])bar2b=(High[2]-Open[2];
double bar1b;
if(Open[1]<Close[1])bar1b=(High[1]-Open[1]);
if(bar2b<bar1b)OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Sl,Tpb,",16384,0,Green);
 
xanzel:

help!!!

simple moving average indicator

how to apply it in an EA to: Previous Indicators Data

iMA(NULL,0,8,0,MODE_EMA,PRICE_PREVIOUS,0);


Spam. Enough of a separate branch
 
Vinin:

It is better to write a lot of words than just help "this is a higher life credo I guess".
 
xanzelIt's better to write a lot of words than to just help "that's a higher life expectation ".
There is one penalty for spamming - banning. So I'm just saving a lost soul. If you don't like it, I'll always help with the ban.
 

Gentlemen! Good evening!

Could you please tell me why the compiler thinks that in the code below

the int Ticket variable is undefined.

It generates one error

'Ticket' - variable not defined C:\Program Files\Alpari NZ MT4(2)\experts\hhhh.mq4 (18, 6)

int start()



{

 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);
 
 
 #include <OMASS.mq4> //объявление и инициализация массива
 double value =  Bid ;// параметру value функции ArrayBsearch присваивается значение текущей цены
 int S = ArrayBsearch(  massiv[43],  value, WHOLE_ARRAY,  0, MODE_ASCEND) //функция ищет самое близкое к текущей цене значение
 if (MathAbs(NormalizeDouble(Bid - S,Digits))<=0.5*Point//если текущая цена отличается от значени возвращенного функцией не более чем 0,5 п.
 if (Bid==Price  )
 int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"jfh",123 );//открыть ордер       
}





But the Ticket variable is also defined in the assignment statement in the code below and the code compiles successfully

int start()

{

 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);    
 

  
      if (Bid==Price  )
     
  int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"jfh",123 );



Спасибо.
 
solnce600:

Gentlemen! Good evening!

Could you please tell me why the compiler thinks that in the code below

the int Ticket variable is undefined.

It generates one error

'Ticket' - variable not defined C:\Program Files\Alpari NZ MT4(2)\experts\hhhh.mq4 (18, 6)


But the Ticket variable is also defined in the assignment statement in the code below and the code compiles successfully


Probably just missing parentheses in one place

if (MathAbs(NormalizeDouble(Bid - S,Digits))<=0.5*Point//если текущая цена отличается от значени возвращенного функцией не более чем 0,5 п.