Questions from Beginners MQL5 MT5 MetaTrader 5 - page 860

 
Hello ! Is there any robot based on the alligator indicator + EMA (233) + Stochastic? And what is your opinion on the strategy ?
 
Lizaku:
Hello ! Is there a robot based on Alligator + EMA (233) + Stochastic indicator? If you can give me a link . And what is your opinion on the strategy ?

The Moving Average is clearly unnecessary here, because the Alligator already consists of three moving averages. That leaves Alligator + Stochastic:

Alligator + Stochastic

 
How to check in the script/advisor the fact of the end of indicator calculation, which of them is called? So far I've had to put Sleep(), but I've lost half a day not understanding why the values in buffers are zero...
 
It's always midnight.
 
Aleksey Vyazmikin:
How do I check in the script/advisor to see if the calculation of the indicator is finished and which of them is called? So far I've had to put Sleep(), but I've lost half a day not understanding why the values in buffers are zero...

I use the following cycle

 int n = 0;
    do
     {
      // Пытаемся получить нужное значение;
      if(значение не получено)
       {
        n++;
        Sleep(100);
       }
     }
    while(значение не получено && n < 7 && !IsStopped());
 
Alexey Viktorov:

I use a cycle like this.

Thanks. I was hoping there was a standard tool for this, it's just not clear why buffers should be filled with zeros and then calculated values put there - it would give a buffer copying error and it would be fine...

 
Aleksey Vyazmikin:

Thank you. I was hoping that there was an in-house tool for this, it's just not clear why buffers should be filled with zeros and then calculated values put there - it would give a buffer copying error and that would be fine...

I have internal tools, I once tried to figure it out, but to no avail. I can't even remember now in which section of documentation it's mentioned. Something to do with synchronisation, if I remember correctly.

 

Good afternoon, I am writing an indicator based on 5-band Bollinger lines, as a final step I started to write conditions for forming a pattern in relation to the indicator lines, but during testing I get 2 variants: either the alert somehow closes itself, or nothing happens. Here is a fragment:

Can you tell me what can be fixed here, if there is anything to fix?

int OnCalculate (const int rates_total,      // размер входных таймсерий 
                 const int prev_calculated,  // обработано баров на предыдущем вызове 
                 const datetime& time[],     // Time
                 const double& open[],       // Open 
                 const double& high[],       // High 
                 const double& low[],        // Low 
                 const double& close[],      // Close 
                 const long& tick_volume[],  // Tick Volume 
                 const long& volume[],       // Real Volume 
                 const int& spread[])         // Spread 
 {
 
//----     
//--- переменные
   int pos; // позиция
   static datetime prevtime = 0;
   int shift1;
   int shift2;
   int shift3;
   string pattern, period;
   int setPattern = 0;
   int alert = 0;
   double O, O1, O2, C, C1, C2, L, L1, L2, H, H1, H2;   
  
//----

//----   
//--- check for bars count - проверка колчества баров
   if(rates_total<ExtPlotBegin)
      return(0);
//--- начало вычисления
   if(prev_calculated>1) pos=prev_calculated-1;
   else pos=0;
//--- главный цикл
   for(int i = pos ; i < rates_total;i++)
    {
      int shift = 0;
      shift1 = shift + 1;
      shift2 = shift + 2;
      shift3 = shift + 3;      
      O = open[shift1];
      O1 = open[shift2];
      O2 = open[shift3];
      H = high[shift1];
      H1 = high[shift2];
      H2 = high[shift3];
      L = low[shift1];
      L1 = low[shift2];
      L2 = low[shift3];
      C = close[shift1];
      C1 = close[shift2];
      C2 = close[shift3]; 
      //--- middle line
      ExtMLBuffer[i]=SimpleMA(i,ExtBandsPeriod,close);
      //--- calculate and write down StdDev
      ExtStdDevBuffer[i]=StdDev_Func(i,close,ExtMLBuffer,ExtBandsPeriod);
      //--- upper line
      ExtTLBuffer[i]=ExtMLBuffer[i]+ExtBandsDeviations*ExtStdDevBuffer[i];
      //--- mediumH line
      ExtMDHBuffer[i]=ExtMLBuffer[i]+ExtBandsDeviationsM*ExtStdDevBuffer[i];
      //--- mediumL line
      ExtMDLBuffer[i]=ExtMLBuffer[i]-ExtBandsDeviationsM*ExtStdDevBuffer[i];  
      //--- lower line
      ExtBLBuffer[i]=ExtMLBuffer[i]-ExtBandsDeviations*ExtStdDevBuffer[i];
     
      // Импульсная свеча от нижней границы Боллинджера
        if(((O <= H) && (H <= ExtMDLBuffer[i])) && ((L >= C) && (C <= ExtBLBuffer[i])))
        {
            Alert("Pin up!");
            PlaySound ("UpperBandAlert.wav"); 
         }
            Sleep(5000);
    }                  
//---- OnCalculate done. Return new prev_calculated. Расчет закончен, возврат к новым предыдущим барам
   return(rates_total);
  }
//+-
 

Hello.

First position volume =0.1, last =0.2, how do I get the volume of the last position =0.2?

In the hedge account this is the case:

double Lot_pos_b()
  {
   int total=0;
   double lot=0;
   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {
               lot=m_position.Volume();
              }
//---
   return(lot);
  }
On a netting account, how do I get the lot? this function returns 0.3 instead of 0.2.
 
lil_lil:

Hello.

First position volume =0.1, last =0.2, how do I get the volume of the last position =0.2?

In a hedge account, it is like this:

In the netting account, how to get the lot volume? this function returns 0.3 instead of 0.2.

View trades belonging to the position and see their volume.

Just unprint all found trades of a position (each position's properties) - figure out what to search for there.