Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1513

 
frank2020:

I'm new to programming, not very good, can you redo it and make it available for download ???

this is the download.
 
MakarFX:
Download it.
Thank you for the answer, I downloaded it, nothing has changed. I wanted the channel to be on the whole history of the chart, not on a short segment????
 
frank2020:
Thanks for the reply, I downloaded it, but it didn't change anything I wanted the channel to be on the whole history of the chart, not on a short segment????
I don't understand MQL5
 
Igor Makanu:

if you want to remind yourself, it is better to throw a custom event in OnChartEvent(), it is more convenient, imho

that's how it is, events between any charts within the terminal

 
Ctrl+N
 

Hello. I can't figure out how to code the calculation of Accelerator Oscillator bands after crossing two MAs, I need to put a vertical line on the 3rd band after closing the 2nd one (after crossing the MA). I understand that probably you will send me to study the reference book. But maybe you'll suggest at least a solution. I would be grateful for help.

void OnTick()
  {
      //обновлять данные всех индикаторов раз в период
   if(Update_Time != iTime(NULL,0,0))
     {
      Update_Time = iTime(NULL,0,0); //перезаписываем значение переменной для хранения времени текущей свечи

      //импорт данных индикатора Moving Averages.
      double FastMA_1 = iMA(NULL,0,FastMA,0,FastMA_method,PRICE_CLOSE,1);
      double FastMA_2 = iMA(NULL,0,FastMA,0,FastMA_method,PRICE_CLOSE,2);
      double SlowMA_1 = iMA(NULL,0,SlowMA,0,SlowMA_method,PRICE_CLOSE,1);
      double SlowMA_2 = iMA(NULL,0,SlowMA,0,SlowMA_method,PRICE_CLOSE,2);
      double   ac     = iAC(NULL,0,1);
      
         //---FastMA_1 выше SlowMA_1, т.е. произошло пересечение снизу вверх
                 
      if(FastMA_1 > SlowMA_1 && FastMA_2 <= SlowMA_2)
        {

//---Не пойму как сделать подсчет полос в iAC после пересечения МА...         
         if((ac[2]>0.0) && (ac[1]>ac[2]))
           {
             VLineCreate(0,"VLine",0,0,clrRed,STYLE_SOLID,1,false,true,true,0); 
           }
        }
     }
  }

I attached a screenshot from the chart for visual representation:

Files:
 
DYM:

Hello. I can't figure out how to code the calculation of Accelerator Oscillator bands after crossing two MAs, I need to put a vertical line on the 3rd band after closing the 2nd one (after crossing the MA). I understand that probably you will send me to study the reference book. But maybe you'll suggest at least a solution. I would be grateful for help.

I attached a screenshot from the chart for visual representation:

double   ac1     = iAC(NULL,0,1);

double   ac2     = iAC(NULL,0,2);
 
DYM:

Hello. I can't figure out how to code the calculation of Accelerator Oscillator bands after crossing two MAs, I need to put a vertical line on the 3rd band after closing the 2nd one (after crossing the MA). I understand that probably you will send me to study the reference book. But maybe you'll suggest at least a solution. I would be grateful for help.

I attached a screenshot from the chart for visual representation:

Check MA crossing not on 1 and 2 bars, but on 3 and 4. And if crossover, then check AO values on 1 and 2 bars.

 

Thank you very much. It was hard, but I think I've got it sorted. Here it is:

void OnTick()
  {


      //импорт данных индикатора Moving Averages.
      double FastMA_1 = iMA(NULL,0,FastMA,0,0,PRICE_CLOSE,1);
      double FastMA_2 = iMA(NULL,0,FastMA,0,0,PRICE_CLOSE,2);
      double SlowMA_1 = iMA(NULL,0,SlowMA,0,0,PRICE_CLOSE,1);
      double SlowMA_2 = iMA(NULL,0,SlowMA,0,0,PRICE_CLOSE,2);
      double   ac     = iAC(NULL,0,0);
      double   ac1     = iAC(NULL,0,1);
      double   ac2     = iAC(NULL,0,2);
      
      
      
         //---Быстрая скользящая средняя (меньше периода) на первой свече выше медленной, т.е. произошло пересечение снизу вверх
      if(FastMA_1 > SlowMA_1 && FastMA_2 <= SlowMA_2)
        {
         
         if((ac>0.0) && (ac>ac1) && (ac1>ac2))
           {
             VLineCreate(0,"VLine",0,0,clrLimeGreen,STYLE_SOLID,1,false,true,true,0);
           }
        }
        
        //---Быстрая скользящая средняя (меньше периода) на первой свече ниже медленной, т.е. произошло пересечение cверху вниз
      if(FastMA_1 < SlowMA_1 && FastMA_2 >= SlowMA_2)
        {
         
         if((ac<0.0) && (ac<ac1) && (ac1<ac2))
           {
             VLineCreate(0,"VLine",0,0,clrOrangeRed,STYLE_SOLID,1,false,true,true,0);
           }
        }
  }

I took a screenshot:

Files:
 
DYM:

Thank you very much. It was difficult, but I think I've got it sorted. Here it is:

I took a screenshot:

wait for error 4200
Reason: