Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1341

 
see what the retcode says after sending the order
 
Fast235 #:
see what the retcode says after the order is sent

Thank you.

10018

TRADE_RETCODE_MARKET_CLOSED

Market is closed.

It means there is a problem with the broker.

 

Greetings, please don't kick me too much)
I have an EA. I want to implement in it the function of opening a position, if on several currency pairs, a bar with index 1, has the same direction (bullish or bearish).
I am trying to do it with iclose and iopen.

Все происходит в bool-ой функцие.
Хотел реализовать конструкцию следующего вида:
if ((iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))&&(iOpen("EURGBP", PERIOD_CURRENT, 1)>iClose("EURGBP", PERIOD_CURRENT, 1))&&(iOpen("EURJPY", PERIOD_CURRENT, 1)>iClose("EURJPY", PERIOD_CURRENT, 1)))
return false;
else if ((iOpen(NULL, PERIOD_CURRENT, 1)<iClose(NULL, PERIOD_CURRENT, 1))&&(iOpen("EURGBP", PERIOD_CURRENT, 1)<iClose("EURGBP", PERIOD_CURRENT, 1))&&(iOpen("EURJPY", PERIOD_CURRENT, 1)<iClose("EURJPY", PERIOD_CURRENT, 1)))
return false;

Но ничего не получилось, и открываются позиции при любой комбинации баров с индексом 1.


Но работает следующая конструкция.

if(iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))
return false;
  if(iOpen("EURGBP", PERIOD_CURRENT, 1)>iClose("EURGBP", PERIOD_CURRENT, 1))
 return false;
     if(iOpen("EURJPY", PERIOD_CURRENT, 1)>iClose("EURJPY", PERIOD_CURRENT, 1))
    return false;

Тут советник правильно находит комбинацию из баров. Но таким способом можно искать либо комбинации из бычьих баров, либо медвежьих.


Ибо код такого вида не работает.
if(iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))
{

  if(iOpen("EURGBP", PERIOD_CURRENT, 1)>iClose("EURGBP", PERIOD_CURRENT, 1))
 return false;
     if(iOpen("EURJPY", PERIOD_CURRENT, 1)>iClose("EURJPY", PERIOD_CURRENT, 1))
    return false;
}

else if(iOpen(NULL, PERIOD_CURRENT, 1)<iClose(NULL, PERIOD_CURRENT, 1))
{

  if(iOpen("EURGBP", PERIOD_CURRENT, 1)<iClose("EURGBP", PERIOD_CURRENT, 1))
 return false;
     if(iOpen("EURJPY", PERIOD_CURRENT, 1)<iClose("EURJPY", PERIOD_CURRENT, 1))
    return false;
}

И такого тоже)
if(iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))
{
if(iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))
 return false;
  if(iOpen("EURGBP", PERIOD_CURRENT, 1)>iClose("EURGBP", PERIOD_CURRENT, 1))
 return false;
     if(iOpen("EURJPY", PERIOD_CURRENT, 1)>iClose("EURJPY", PERIOD_CURRENT, 1))
    return false;
}

else if(iOpen(NULL, PERIOD_CURRENT, 1)<iClose(NULL, PERIOD_CURRENT, 1))
{
if(iOpen(NULL, PERIOD_CURRENT, 1)<iClose(NULL, PERIOD_CURRENT, 1))
 return false;
  if(iOpen("EURGBP", PERIOD_CURRENT, 1)<iClose("EURGBP", PERIOD_CURRENT, 1))
   return false;
     if(iOpen("EURJPY", PERIOD_CURRENT, 1)<iClose("EURJPY", PERIOD_CURRENT, 1))
    return false;
}


So whatis the right way tolook for combinations of bearish and bullish bars at the same time? Once again, please don't hit it too hard.)

 
Scarick #:

Greetings, please don't kick me too much)
I have an EA. I want to implement in it the function of opening a position, if on several currency pairs, a bar with index 1, has the same direction (bullish or bearish).
I am trying to do it with iclose and iopen.

if ((iOpen(NULL, PERIOD_CURRENT, 1)>iClose(NULL, PERIOD_CURRENT, 1))&&(iOpen("EURGBP", PERIOD_CURRENT, 1)>iClose("EURGBP", PERIOD_CURRENT, 1))&&(iOpen("EURJPY", PERIOD_CURRENT, 1)>iClose("EURJPY", PERIOD_CURRENT, 1)))
return false;
else if ((iOpen(NULL, PERIOD_CURRENT, 1)<iClose(NULL, PERIOD_CURRENT, 1))&&(iOpen("EURGBP", PERIOD_CURRENT, 1)<iClose("EURGBP", PERIOD_CURRENT, 1))&&(iOpen("EURJPY", PERIOD_CURRENT, 1)<iClose("EURJPY", PERIOD_CURRENT, 1)))
return false;

So whatis the right way tolook for combinations of bearish and bullish bars at the same time? Once again, please do not hit me with a thump.)

UseCopyRates, and make sure you control how much you have ordered and how much you have received. Here is an example:

   MqlRates rates_current[],rates_eurgbp[],rates_eurjpy[];
   ArraySetAsSeries(rates_current,true);
   ArraySetAsSeries(rates_eurgbp,true);
   ArraySetAsSeries(rates_eurjpy,true);
   int start_pos=0,count=3;
   if(CopyRates(Symbol(),Period(),start_pos,count,rates_current)!=count)
      return;
   if(CopyRates("EURGBP",Period(),start_pos,count,rates_eurgbp)!=count)
      return;
   if(CopyRates("EURJPY",Period(),start_pos,count,rates_eurjpy)!=count)
      return;
//---
   bool signal_buy=false,signal_sell=false;
   if((rates_current[1].open>rates_current[1].close) && (rates_eurgbp[1].open>rates_eurgbp[1].close) && (rates_eurjpy[1].open>rates_eurjpy[1].close))
     {
      signal_buy=true;
      signal_sell=false;
     }
   else
     {
      if((rates_current[1].open<rates_current[1].close) && (rates_eurgbp[1].open<rates_eurgbp[1].close) && (rates_eurjpy[1].open<rates_eurjpy[1].close))
        {
         signal_buy=false;
         signal_sell=true;
        }
     }
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyRates
Документация по MQL5: Доступ к таймсериям и индикаторам / CopyRates
  • www.mql5.com
CopyRates - Доступ к таймсериям и индикаторам - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Hello all!

Situation.

The Expert Advisor is written, let's say, on muwings. When you finish testing it in the tester, the used muvings (with used parameters) appear in the window. This is OK.

Question.

But when this EA is also uploaded to the Market and a user downloads the demo, will it also pop up after the end of the test? Or does mql have a privacy policy in this regard?


Конечно, можно самому заморочиться и проверить. Но те кто, заливал продукты, поймут, что лучше просто спросить)  

 
Anton Iudakov #:

Hello all!

Situation.

The Expert Advisor is written, let's say, on muwings. When you finish testing it in the tester, the used muvings (with used parameters) appear in the window. This is OK.

Question.

But when this EA is also uploaded to the Market and a user downloads the demo, will it also pop up after the end of the test? Or does mql have a privacy policy in this regard?


Of course, it's easier to ask, but not everyone who has downloaded an EA to the market has checked it afterwards.

In fact, what difference does it make where the EA's file was obtained from? It will work the same whether it was downloaded from a developer or encrypted from the market...

 
Anton Iudakov #:

Hello all!

Situation.

The Expert Advisor is written, let's say, on muwings. When you finish testing it in the tester, the used muvings (with used parameters) appear in the window. This is OK.

Question.

But when this EA is also uploaded to the Market and a user downloads the demo, will it also pop up after the end of the test? Or does mql have a privacy policy in this regard?


TesterHideIndicators
 
Can you please tell me how aftertesting an EA in MQL5 to output any of my statistics in a pop-up window when the mouse is over the arrows?
Как протестировать торгового робота перед покупкой
Как протестировать торгового робота перед покупкой
  • www.mql5.com
Покупка торгового робота в MQL5 Маркете имеет одно большое преимущество перед всеми другими подобными предложениями - вы можете устроить комплексную проверку предлагаемой автоматической системы прямо в терминале MetaTrader 5. Каждый советник перед покупкой можно и нужно тщательно прогнать во всех неблагоприятных режимах во встроенном тестере торговых стратегий, чтобы получить о нем максимально полное представление.
 

Help me fix the indicator. It draws a price step/grid from a specified value. The problem is that when I remove it, the lines remain on the chart. Also, I cannot add a second indicator like it to the chart. In general, how to make it remove completely from the chart so that I can throw the same indicator on the chart with other values.

#property link      "https://www.forexsystems.biz"
#property version   "1.00"
#property indicator_chart_window

//---- для расчёта и отрисовки индикатора использовано ноль буферов
#property indicator_buffers 0
//---- использовано всего ноль графических построений
#property indicator_plots   0
//--- входные параметры 
input int count = 500;      //количество линий вверх вниз от цены
input int step  = 100;     //шаг линий 
input double pr = 1.1;  //цена от которой пляшем
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
   
  }
//+------------------------------------------------------------------+ 
//| Создает горизонтальную линию                                     | 
//+------------------------------------------------------------------+ 
bool HLine(const string name="HLine",double price=0)
  {
//--- создадим горизонтальную линию 
   if(!ObjectCreate(0,name,OBJ_HLINE,0,0,price))
     {
      Print(__FUNCTION__,
            ": не удалось создать горизонтальную линию! Код ошибки = ",GetLastError());
      return(false);
     }
//--- установим цвет линии 
   ObjectSetInteger(0,name,OBJPROP_COLOR,clrDodgerBlue);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
   return(true);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   double price=pr;
//--- создадим горизонтальную линию 
   for(int i=0;i<=count;i++)
     {
      HLine("HLine"+(string)i,price+step*i*_Point);
      HLine("HLine"+(string)(i+count+1),price-step*i*_Point);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


 
Green handsome #:

Help me fix the indicator. It draws a price step/grid from a specified value. The problem is that when I remove it, the lines remain on the chart. Also, I cannot add a second indicator like it to the chart. In general, how to make it delete completely from the chart, so that it is possible to add the same indicator on the chart with different values.

In OnDeinit you need to doObjectsDeleteAll- delete by prefix (in your case the prefix is "HLine")

int  ObjectsDeleteAll(
   long           chart_id,   // идентификатор графика
   const string     prefix,   // префикс имени объекта
   int       sub_window=-1,   // индекс окна
   int      object_type=-1    // тип объекта для удаления
   );

Документация по MQL5: Графические объекты / ObjectsDeleteAll
Документация по MQL5: Графические объекты / ObjectsDeleteAll
  • www.mql5.com
ObjectsDeleteAll - Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5