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

 
msl271170: Teach how to stop the Expert Advisor and start it when a new candle appears.

there is an example of Moving Average.mq4 Expert Advisor in the terminal - it has this:

//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;

I've seen it in another one:

datetime LastTime;  // Время начала тика для побарного режима
void OnTick()
{
  if (Time[0] == LastTime) return;
  LastTime = Time[0];
........
}
 
msl271170: I understand that MT5 has a different programming language. Will my code not work there?

Use MT4Orders - library for MetaTrader 5

 

I'm trying to figure out CopyTime, but I don't understand why DayData[] doesn't fill in (I want to see date rounded to whole day). I've added an example below, if anyone notices a mistake, please point it out or correct it:

datetime Data[3]={D'2017.09.22 08:05',D'2017.09.22 10:05',D'2017.09.22 12:05'};
int count=0;
datetime DayData[];
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   count++;
   
   if(count<4)
     {
      int copied=CopyTime(NULL,PERIOD_D1,Data[count-1],1,DayData);
      ArrayResize(DayData,count);
      Print("0 Data[",count-1,"]= ",Data[count-1]," DayData[count-1]= ",DayData[count-1]); // 1 control
     }

   for(int i=0; i<ArraySize(DayData);i++)
      Print("1 Data[",i,"]= ",Data[i]," DayData[i]= ",DayData[i]);  // 2 control

  }
//+------------------------------------------------------------------+
 

A whole page of empty posts (forum error). Had to delete.

 

Good day to you all!


I'm gradually learning mql4 from Evgeniy Zhdanov's book.

It describes an example of Envelopes, Zigzag application.

The iCustom and iEnvelopes functions are described there to receive Envelopes and ZigZag indicators data.

Can you advise where to find information and learn the data - than to describe the other indicators?

Maybe there is a link to a resource where I can learn which functions are described by which indicators?

Or is it all in the help?

I am sincerely thankful in advance!

 
Список функций языка MQL4 - Справочник MQL4
Список функций языка MQL4 - Справочник MQL4
  • docs.mql4.com
Читает из файла типа CSV строку одного из форматов: "YYYY.MM.DD HH:MM:SS", "YYYY.MM.DD" или "HH:MM:SS" - и преобразует ее в значение типа datetime
 
Taras Slobodyanik:

see iRsi and iBands

https://docs.mql4.com/ru/function_indices


Thank you so much!


Got my scuba gear, went for a dive!

 

There is also this question.

The following Expert Advisor is prescribed

If ZigZag is less than two Envelopes - open buy.

If ZigZag is larger than two Envelopes - open Sell.

Then if an order is opened by an EA - modify the order by so-and-so TP and so-and-so STOP.

There are no errors in compilation.

And here is the problem, no matter how I try to test it, the strategy tester always opens the first Buy order which the tester stubbornly refuses to modify. Furthermore, all orders open only for Sell, which are perfectly modified and do not cause any problems.

Is there some kind of error in the code?

Or is this a feature of the tester? I always start with any date I choose "use date" and the first order to buy is always unmodifiable. Then all my sell orders that are modified and work fine.

I have not found any information about this yet.

Thanks for your kind attention!

 

Why does the tester produce different results with

extern bool Tral =true;

...

void OnTick()

{

    if (Tral)Trailing();....

and if Tral is not moved to external variables, but simply uses the same function with the same variables:

void OnTick()

{

   Trailing();


 
RichLux:

Why does the tester give different results at ....

Try :

input bool Tral =true;

... or do you really need extern ?