[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 127

 
No.
 

This question: the standard OA indicator uses 2 additional index buffers, which are not involved in rendering the indicator:

//+------------------------------------------------------------------+
//|                                                  Accelerator.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  Green
#property  indicator_color3  Red
//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
double     ExtBuffer3[];
double     ExtBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+2);
   SetIndexDrawBegin(0,38);
   SetIndexDrawBegin(1,38);
   SetIndexDrawBegin(2,38);
//---- 4 indicator buffers mapping
   SetIndexBuffer(0, ExtBuffer0);
   SetIndexBuffer(1, ExtBuffer1);
   SetIndexBuffer(2, ExtBuffer2);
   SetIndexBuffer(3, ExtBuffer3);
   SetIndexBuffer(4, ExtBuffer4);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AC");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   double prev, current;
//---- last counted bar will be recounted
   if( counted_bars>0) counted_bars--;
   limit=Bars- counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i=0; i& lt; limit; i++)
      ExtBuffer3[ i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN, i)-
                    iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN, i);
//---- signal line counted in the 2-nd additional buffer
   for( i=0; i< limit; i++)
      ExtBuffer4[ i]=iMAOnArray( ExtBuffer3,Bars,5,0,MODE_SMA, i);
//---- dispatch values between 2 buffers
   bool up=true;
   for( i= limit-1; i>=0; i--)
     {
      current=ExtBuffer3[ i]- ExtBuffer4[ i];
      prev=ExtBuffer3[ i+1]- ExtBuffer4[ i+1];
      if( current> prev) up=true;
      if( current& lt; prev) up=false;
      if(! up)
        {
         ExtBuffer2[ i]= current;
         ExtBuffer1[ i]=0.0;
        }
      else
        {
         ExtBuffer1[ i]= current;
         ExtBuffer2[ i]=0.0;
        }
       ExtBuffer0[ i]= current;
     }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

As you can see only calculations are made in these arrays. I don't understand why these arrays should be assigned index buffer status?

 
neoclassic писал(а) >>

This question: the standard OA indicator uses 2 additional index buffers, which are not involved in rendering the indicator:

As you can see only calculations are made in these arrays. I don't understand, why do these arrays need to be assigned the status of index buffers?

to set the size of the array!

 

Hello forum users!

I am a total MQL programmer. But I would like to have a simple EA like this. Opens pose with some lot. I set immediately a fixed stop (20-30 pips). After reaching a certain profit (20-30 pips) we close part of the position (50%), and for the remaining positions the stop is moved to Breakeven. For the remaining position a profit order is placed or it is monitored manually. Here is an idea. I would be very grateful for answers.

 
vvavva >> :

to set the size of the array!

but what to do if you need to use a large number of arrays? >> (more than 8)

 

use regular arrays rather than buffer arrays

instead of

SetIndexBuffer(3,ExtBuffer3);SetIndexBuffer(4,ExtBuffer4);

use

ArrayResize(ExtBuffer3,Bars); ArrayResize(ExtBuffer4,Bars);

 
keekkenen >> :

use regular arrays rather than buffer arrays

instead of

SetIndexBuffer(3,ExtBuffer3);SetIndexBuffer(4,ExtBuffer4);

use

ArrayResize(ExtBuffer3,Bars); ArrayResize(ExtBuffer4,Bars);


Thank you!!!

 
neoclassic писал(а) >>

What if a large number of arrays need to be used? (more than 8)

arrays for drawing in the indicator cannot exceed the specified limit (I think it's 8)!

arrays for calculations also have limits, but the number is bigger!

to work around limits using arrays, you need to use libraries!

 
I have a question. Is it possible to make a news waiter. Let's say today will be the news exact time is not known approximate text one word, I need a longer and louder beep can do it.
 
Hello, plz tell me as many possible reasons why the variable k=Bars may change when a new bar has not yet started to form (any possible situations), say you changed the currency pair, timeframe, some mt4 update or in dc.
Reason: