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

 
r772ra:
Try it, each buffer in a separate loop.
Yep.
   for(int i=0; i<limit; i++)
   { 
     Macd1Buffer[i]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i);
     Macd2Buffer[i]=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,i);   
   }          

   for(i=0; i<limit; i++) 
   { 
      Signal1Buffer[i]=iMAOnArray(Macd1Buffer,Bars,5,0,MODE_SMA,i);
      Signal2Buffer[i]=iMAOnArray(Macd2Buffer,Bars,9,0,MODE_SMA,i);
   }      
 

Thank you for the advices. Everything works, but when you install the indicator it is drawn strangely (see chart). The indentation (in bars) from the left edge of the chart window to the vertical yellow line is always UNSTOPPED for ANY number of visible bars in the window and equals eight bars. Once these eight bars go beyond the left window boundary, ALL lines on the chart immediately appear and then everything is normal. Can it be fixed and how?


#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 DarkOrange
#property  indicator_width1  2
#property  indicator_width3  2
//--- buffers
double Macd1Buffer[];
double Signal1Buffer[];
double Macd2Buffer[];
double Signal2Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Macd1Buffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Signal1Buffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Macd2Buffer);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Signal2Buffer);
   
   IndicatorDigits(Digits);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {   
      double max1=-0.01,min1=0.01,
             max2=-0.01,min2=0.01,
             max_M1=-0.01,min_M1=0.01,
             max_M2=-0.01,min_M2=0.01,
             max_S1=-0.01,min_S1=0.01,
             max_S2=-0.01,min_S2=0.01;
             
       
 
   int bars_counted=WindowBarsPerChart()-1,
       limit;  
       limit=bars_counted;       


      
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
   
   { 
     Macd1Buffer[i]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i);
     Macd2Buffer[i]=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,i);
      
           max_M1=MathMax(Macd1Buffer[i],max_M1);
           min_M1=MathMin(Macd1Buffer[i],min_M1);
           
           max_M2=MathMax(Macd2Buffer[i],max_M2);
           min_M2=MathMin(Macd2Buffer[i],min_M2);
   }
   
   for( i=0; i<limit; i++)
           
   {
      Signal1Buffer[i]=iMAOnArray(Macd1Buffer,Bars,5,0,MODE_SMA,i);
      Signal2Buffer[i]=iMAOnArray(Macd2Buffer,Bars,9,0,MODE_SMA,i);
      
           
           max_S1=MathMax(Signal1Buffer[i],max_S1);
           min_S1=MathMin(Signal1Buffer[i],min_S1);
           
           max_S2=MathMax(Signal2Buffer[i],max_S2);
           min_S2=MathMin(Signal2Buffer[i],min_S2);         
   }          
           max1=MathMax(max_M1,max_S1);
           min1=MathMin(min_M1,min_S1);
             
           
            
      

//---- done 
   
 
      Comment( "\n"," Баров = ",WindowBarsPerChart()-1,
               "\n"," max_M1 = ",max_M1,
               "\n"," min_M1 = ",min_M1,
               "\n"," max_S1 = ",max_S1,
               "\n"," min_S1 = ",min_S1,
               "\n"," max_M2 = ",max_M2,
               "\n"," min_M2 = ",min_M2,
               "\n"," max_S2 = ",max_S2,
               "\n"," min_S2 = ",min_S2,
               "\n"," max1 = ",max1,
               "\n"," min1 = ",min1,    
               "\n"," max2 = ",max2,
               "\n"," min2 = ",min2);
         
             
         
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
MK07:

Thank you for the advices. It works, but when you install the indicator it is drawn strangely (see chart). The indentation (in bars) from the left border of the chart window to the vertical yellow line is always UNSTOPPED for ANY number of visible bars in the window and equals eight bars. As soon as these eight bars go beyond the left window border, ALL chart lines immediately appear and then everything is normal. Can it be fixed and how?


try it like this

   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
 
I need to build an indicator on ALL Bars SEEN in the window, and then find its max and min at this point! Help me solve the problem, mentioned in my previous post, I have an example, but I do not understand it all, can someone explain these three lines one by one?
 // обработка видимых баров.
   int bars_count=WindowBarsPerChart();
   int bar=WindowFirstVisibleBar();
   for(int i=0; i<bars_count; i++,bar--)
     {
      // номера баров уменьшаются, так как нумерация идет в обратном порядке.
      // ...
     } 
 
MK07:
This code construction allows to recalculate at every new tick the indicator only at zero and the first (for check) bar, instead of recalculating already calculated indicator anew. i need to build an indicator by ALL visible bars visible in the window, and then find its max and min at this point. help me to solve the problem, mentioned in my previous post. there is an example, but not everything is clear to me. can someone explain these three strings line by line?

Not quite clear what you need, if you need to find the MAX and MIN of the visible bars of the indicator, first draw the indicator and then search.

Maybe it's better to use WindowPriceMax(), WindowPriceMin().

 
r772ra:

Stepan2

Works


There's a glitch with arrays after all, but with while

c for for works without any problems

))

 

Good afternoon.

People, tell me what to test EAs with. Because the built in MT gives an average of 50% simulation quality, and people are posting more than 90% on screenshots.

 
jusser:

Good afternoon.

People, tell me what to test EAs with. Because the built in MT gives an average of 50% simulation quality, but on screenshots people post more than 90%.


If you have the whole minute history, it will be 90%. 99% is achieved by creating a tick history fxt yourself. This is usually done using dukascoping quotes. Google scripts on the subject of 99% quality testing

 
Good afternoon, could you tell me if there is an indicator in MT4 that shows open interest? If not, can it be replaced by something similar?
 
Hello, how to implement a condition in the code of the Expert Advisor to set the same type of orders 50 pips after the last order