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

 
ANDREY:

Please tell me what EA means in the context of what you wrote in your post. I want to find and read more about it.....
Thank you.

EA = Expert Advisor

EA

This is the first time I see someone on this forum who did not understand the abbreviation

I have not tried to place an order in MT5 by filling out the entire request structure, there is an SB, if you understand it, it is one line to open an order

trade.Buy(0.1);

https://www.mql5.com/ru/articles/481

 
MakarFX:

Print


It is not clear why it switches to M5

Are bylots and sellots global or local?
 
Alexey Viktorov:

Which is better?

(0 == 0 and 1 == 0) - condition is not satisfied

(0 + 1 == 0) - the condition is also not satisfied.

What is the difference between AND and addition in this particular example?

The code is more readable.
 
Alexey Viktorov:

When the TF is switched, the EA is restarted.

The issue is resolved as follows

int    CountOrder(int Order_Type) 
 {
  int Orders=0;
  for(int a=OrdersTotal()-1;a>=0;a--)
   {
    if(OrderSelect(a, SELECT_BY_POS, MODE_TRADES)==false) continue;
    if(OrderSymbol()!=_Symbol) continue;
    if(Order_Type == OrderType() || Order_Type == -1) Orders++;
   }
  return Orders;
 }
int    OrOfSy;
//+------------------------------------------------------------------+
void OnTimer(void)
  {
//----
   OrOfSy=CountOrder(-1);
  if(OrOfSy!=0)
   if(ChartPeriod()!=PERIOD_M15)
    if(ChartSetSymbolPeriod(0,Symbol(),PERIOD_M15))
     {Print(ChartPeriod());}
  if(OrOfSy==0)
   if(ChartPeriod()!=PERIOD_M5)
    if(ChartSetSymbolPeriod(0,Symbol(),PERIOD_M5))
     {Print(ChartPeriod());}
//----
  }
Everything works)
 
MakarFX:

The issue was resolved as follows

Everything works)
OrofSys is in the global zone.
 
Igor Makanu:

EA = Expert Advisor

EA

This is the first time I've seen someone on this forum who has not understood the abbreviation

about what was discussed - I have not tried to place orders in MT5 filling the entire request structure, there is a SB, if you understand it, then the order opening is in one line

https://www.mql5.com/ru/articles/481

Got it. Thanks.

 
SanAlex:

error - this line must be deleted ( double const = 0; )

and everything will work



Hello SanAlex ! 2020.10.29_06:54 GMT+3. Thank you for your suggestions. The BrainTrend1Sig.mq4 indicator will be useful. I myself have not coped with code conversion from .mq5 to .mq4 . I will try to make a profitable Expert Advisor based on this indicator.

 
Valeriy Yastremskiy:
The code is more readable.

It depends...

 

Can you tell me how to lock the button

   //--- обработка кнопки Создать трендовую линию Buy
   if(sparam=="Button 3")
      {
      if(trigger_greateB==true)
         {
         Sleep(100);
         trigger_greateB=false;
         ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);
         //--- Определяем координаты
         ChartXYToTimePrice(0,xn,yn+20,window,dt_1,price_1);
         ChartXYToTimePrice(0,xn+100,yn-20,window,dt_2,price_2);
         //--- Создаем трендовую линию Buy
         TrendCreate(0,("OrderBuy: "+Symbol()),0,dt_1,price_1,dt_2,price_2,ColorUP,0,1,false,true,false,false,0);
         return;
         }
      }

you need to lock the press if

if(ObjectGet("OrderBuy: "+Symbol(),OBJPROP_PRICE1)!=0)
 
MakarFX:

Can you tell me how to lock the button

You need to block the press if

Just like that, add it to the condition.

if(sparam=="Button 3" && ObjectGet("OrderBuy: "+Symbol(),OBJPROP_PRICE1)!=0)

Or == 0, more likely. Or better to use search for object by name, if there is no such object then create one. And it doesn't matter if the button is pressed or not.