A question for MQL experts - page 4

 
Rita:

How do you organise such a cycle?


for (int i = 0; i<Bars; i++)
{
  if  (iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)< iMA(NULL,0,30,0,MODE_SMA,PRICE_MEDIAN,i) && 
        iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i+1)> iMA(NULL,0,30,0,MODE_SMA,PRICE_MEDIAN,i+1) break;
}

Print ("Последнее пересечения МА было на ", i, " баре...");
Of course this is schematic, the intersections are described in a slightly more complex way, but somewhere along the line this cycle should look like this.
 
Thank you. I'll give it a try.
 
Rita:
Thank you. I'll give it a try.

Hey, hey... Careful, I already see a couple of errors (over Bars and no intersection at all) and that's not counting the fact that the description of the intersection doesn't take into account all the possible options.
 

Or maybe it's better this way

   int pos=0;
   while ((iMA(NULL,0, 5,0,MODE_SMA,PRICE_MEDIAN,pos)-iMA(NULL,0, 5,0,MODE_SMA,PRICE_MEDIAN,pos+1))*
          (iMA(NULL,0,30,0,MODE_SMA,PRICE_MEDIAN,pos)-iMA(NULL,0,30,0,MODE_SMA,PRICE_MEDIAN,pos+1))>0) 
   {
       pos++;
       if (pos==Bars-30-1) 
       {
           pos=-1;
           break;
       }
   }          
 

Thank you all. I'll experiment.

Got the gist of it.

 

Good afternoon.

Could you please tell me. My Expert Advisor works with opening prices.

Where should I set some mathematical calculations and variables like :

double g_Signal_0=iCustom(NULL,0,"......

- before the condition

if(Time[0] == prevtime)  return(0);//ждем новый бар
 prevtime = Time[0];//если появился новый бар - включаемся  

or after?

 
Rita:

Good afternoon.

Could you please tell me. My Expert Advisor works with opening prices.

Where should I set some mathematical calculations and variables like :

double g_Signal_0=iCustom(NULL,0,"......

- before the condition

or after?


Definitely after.
 
Ok. spsb.
 

Interested in this question. Importing data from Excel into MetaQuotes Language 4. I haven't found anything useful on this subject. Maybe I searched badly:)))

I want to import a table with 10-30 values to the indicator. Is it possible?

 
ULAD:

Interested in this question. Importing data from Excel into MetaQuotes Language 4. I haven't found anything useful on this subject. Maybe I searched wrong:))

I need to transfer a table of 10-30 values to the indicator. Is this possible?

is it https://www.mql5.com/ru/forum/103244 or https://www.mql5.com/ru/forum/107925 not helpful?

forum search works today, a lot of information on the request https://www.mql5.com/ru/search

Reason: