Questions from Beginners MQL4 MT4 MetaTrader 4 - page 159

 

Hello esteemed programmers please help me to tweak this EA.



1. Opening of orders automatically.
2.When it reaches + it opens an order in the same side with initial lot.
3. When it reaches the - it reverses the order (opens the order in the direction in which it was received).
 
Greetings, colleagues!
Can you advise if anyone has encountered this problem?
1) Tested in MT4 co-op. There are Error to order modify1 in the log. What is the reason of Error to order modify1 and how to correct it?
2) I cannot install and run the EA. I move the EA to the chart window and it either does not stick to the upper right corner, or stays stuck, but does not start. Instead of a colobus, it is a rectangle! (See the screenshot)
3) How do I correctly install MT4 on my ROSA (Linux)? I have MT4 installed on c/Program Files (x86)/MT4 . Do I have to copy files from c/Program Files (x86)/MT4 to c/users/xxl/AppData/ and to _c/users/xxl/Application Data/MetaQuotes/? If so, which files should I put in the LocalLow and Roaming folders and which in the Terminal and WebInstall folders?
Thanks for the detailed answer! )

 

Hi all. Here's the bottom line. There is an intersection point of alligator with N bar. We need to find the angle between the alligator and e.g. the low of the 1st bar from this intersection point. The difficulty is that we have two incompatible values - the number of bars and the price. I wanted, as suggested by someone, to dance on the size of a cell in the chart. But if the number of bars in the square is proportional to the change of scale, the price does not have such a proportion.

I have two questions based on the above:

1. Maybe someone has met or knows the solution to this problem.

2. Does the Expert Advisor work with a certain scale of the chart, or just with the price?

 
Alexander Dubovik:

One more remark for the developers.

The documentation for the typedef language construct (as well as typedef itself) is perplexing.

typedef char My_Char; - does not compile.

From the documentation:"The key word typedef in C++ allows you to create custom data types.....". Excuse me, but WHY would you make a reference to C++ in documentation on MQL, if in fact MQL only contains declaration of pointers to functions?

In MQL4/5 typedef is neutered and serves only for declaring pointers to functions and is useful for nothing else.


typedef int (*TFunc)(int,int);

int add(int x,int y) 
{
    return(x+y); 
}

void OnStart()
{
    TFunc pfunc = add;   
    Print(pfunc(4,5));    
}
 
Alex Pirate:

Hi all!

i've got a simple EA, it's simple, something's wrong, it gives me an error... i want to attach a trawl to it but it won't even open... it says - return value of 'OrderSend' should be checked

why does it still check??? what's wrong??? it looks like the programmers and those who are good at helping everyone here.... Too bad ((!)

https://translate.google.ru/?hl=ru&tab=TT#en/ru/return%20value%20of%20'OrderSend'%20should%20be%20checked

Google Переводчик
  • translate.google.ru
Бесплатный сервис Google позволяет мгновенно переводить слова, фразы и веб-страницы с английского на более чем 100 языков и обратно.
 
Alex Pirate:

Hi all!


 
Artyom Trishkin:


Thank you, I'm aware of that... That's the translated question I asked at the bottom... not what he says I wonder... why? what's wrong with the code??? what did I write wrong???

 
Alex Pirate:

Thank you, I'm aware of that... That's the translated question I asked at the bottom... I wonder why? What's wrong with the code?

 
Artyom Trishkin:

extern int    MA_1_Period   = 22;
extern int    MA_1_MAShift  = 1;
extern int    MA_1_Method   = 1;
extern int    MA_1_Price    = 1;
extern int    MA_1_Shift    = 0;

extern int    MA_2_Period   = 55;
extern int    MA_2_MAShift  = 1;
extern int    MA_2_Method   = 1;
extern int    MA_2_Price    = 1;
extern int    MA_2_Shift    = 0;

extern int    MA_3_Period   = 163;
extern int    MA_3_MAShift  = 1;
extern int    MA_3_Method   = 1;
extern int    MA_3_Price    = 1;
extern int    MA_3_Shift    = 0;

extern double lot           = 0.1;
extern int    TP            = 60;
extern int    SL            = 40;
extern int    Slippage      = 5;
extern int    Magic         = 888;

int timeprev;

//+------------------------------------------------------------------+
int init()
{ 
   if (Digits == 3 || Digits == 5)
   {
     TP           *= 10;
     SL           *= 10;
     Slippage     *= 10;
     
   }

   return(0); 
}
//+------------------------------------------------------------------+
int deinit() 
{
   return(0);
}
//+------------------------------------------------------------------+

int start()
{
   if (timeprev == Time[0]) return(0);
   timeprev = Time[0];
   
   double MA_1_1 = iMA(Symbol(), 0, MA_1_Period, MA_1_MAShift, MA_1_Method, MA_1_Price, MA_1_Shift);
   double MA_1_2 = iMA(Symbol(), 0, MA_1_Period, MA_1_MAShift, MA_1_Method, MA_1_Price, MA_1_Shift);
   
   double MA_2_1 = iMA(Symbol(), 0, MA_2_Period, MA_2_MAShift, MA_2_Method, MA_2_Price, MA_2_Shift);
   double MA_2_2 = iMA(Symbol(), 0, MA_2_Period, MA_2_MAShift, MA_2_Method, MA_2_Price, MA_2_Shift);
   
   double MA_3_1 = iMA(Symbol(), 0, MA_3_Period, MA_3_MAShift, MA_3_Method, MA_3_Price, MA_3_Shift);
   double MA_3_2 = iMA(Symbol(), 0, MA_3_Period, MA_3_MAShift, MA_3_Method, MA_3_Price, MA_3_Shift);
     
 //+------------------------------------------------------------------+  
 // покупаем
 
   if (CountBuy() + CountSell() == 0 && MA_1_1 > MA_1_2 && MA_2_1 > MA_2_2 && MA_3_1 > MA_3_2 )
   
      {
         OrderSend(Symbol(), OP_BUY , lot, Ask, Slippage, SL, TP, "", Magic,0, Green);
      }
// продаём
   
   if (CountBuy() + CountSell() == 0 && MA_1_1 < MA_1_2 && MA_2_1 < MA_2_2 && MA_3_1 < MA_3_2 )
   
      {
         OrderSend(Symbol(), OP_SELL, lot, Bid, Slippage, SL, TP, "", Magic,0, Red);
      }
          
   return(0);
}
//+------------------------------------------------------------------+
int CountBuy()
{
   int count = 0;
   
   for (int i = OrdersTotal() - 1; i >= 0; i --)
   {
      if (OrderSelect(i,SELECT_BY_POS, MODE_TRADES))
      {
        if (OrderSymbol() == Symbol() && OrderMagicNumber() ==  Magic && OrderType() == OP_BUY)
           count++;
      }
   }
   return(count);
}
//+------------------------------------------------------------------+
int CountSell()
{
   int count = 0;
   
   for (int i = OrdersTotal() - 1; i >= 0; i --)
   {
      if (OrderSelect(i,SELECT_BY_POS, MODE_TRADES))
      {
        if (OrderSymbol() == Symbol() && OrderMagicNumber() ==  Magic && OrderType() == OP_SELL)
           count++;
      }
   }
   return(count);
}
//+------------------------------------------------------------------+
 
Alex Pirate:

What are you comparing with what?

   double MA_1_1 = iMA(Symbol(), 0, MA_1_Period, MA_1_MAShift, MA_1_Method, MA_1_Price, MA_1_Shift);
   double MA_1_2 = iMA(Symbol(), 0, MA_1_Period, MA_1_MAShift, MA_1_Method, MA_1_Price, MA_1_Shift);
   
   double MA_2_1 = iMA(Symbol(), 0, MA_2_Period, MA_2_MAShift, MA_2_Method, MA_2_Price, MA_2_Shift);
   double MA_2_2 = iMA(Symbol(), 0, MA_2_Period, MA_2_MAShift, MA_2_Method, MA_2_Price, MA_2_Shift);
   
   double MA_3_1 = iMA(Symbol(), 0, MA_3_Period, MA_3_MAShift, MA_3_Method, MA_3_Price, MA_3_Shift);
   double MA_3_2 = iMA(Symbol(), 0, MA_3_Period, MA_3_MAShift, MA_3_Method, MA_3_Price, MA_3_Shift);
     
 //+------------------------------------------------------------------+  
 // покупаем
 
   if (CountBuy() + CountSell() == 0 && MA_1_1 > MA_1_2 && MA_2_1 > MA_2_2 && MA_3_1 > MA_3_2 )

If 0 > 0 and 0 > 0 and 0 > 0

Reason: