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

 
Everybody knows. IN MT4. There is a strategy tester. It is possible to push the enumeration of parameters, through optimization.

The question is as follows.

Can we shove this optimization, search of parameters, into the Expert Advisor? If the Expert Advisor optimizes parameters from time to time, it selects those that are profitable and works with them? Say, every 7 days the Expert Advisor optimizes for 7 days. And selected parameters on the profitability. And them owls, already working further 7 days?

Want to hear the answer, someone who understands this. Let's say the amount of work. The severity of the work. etcetera. What it's all about.

 
Aleksey Radzisheuski:
Everybody knows. IN MT4. There is a strategy tester. It is possible to push the enumeration of parameters, through optimization.
The question is as follows.
Can we shove this optimization, search of parameters, into the Expert Advisor? If the Expert Advisor optimizes parameters from time to time, it selects those that are profitable and works with them? Say, every 7 days the Expert Advisor optimizes for 7 days. And selected parameters on the profitability. And them owls, already working further 7 days?

Want to hear the answer, someone who understands this. Let's say the amount of work. The severity of the work. etcetera. What it's all about.

Here's the article https://www.mql5.com/ru/articles/1467 ...

Автоматическая оптимизация торгового робота в процессе реальной торговли
Автоматическая оптимизация торгового робота в процессе реальной торговли
  • 2007.04.16
  • Igor Malcev
  • www.mql5.com
В статье описана и представлена библиотека функций, позволяющая проводить оптимизацию входных параметров советника, запуская оптимизацию непосредственно из советника.
 
Alekseu Fedotov:


Do you havea Trend line?

And visually goes over(under) 0 bar, no, check the box in properties, beam.


The line is a trend line. Changed properties to a ray. It did not help. Ideally, I want the price to be displayed regardless of the position of the zero bar (top, bottom).

This code doesn't work either.

int start() {

double pr=ObjectGetValueByShift("line",0);

If (Bid==pr){

Alert (pr);}

return(0);}

 
Valerius:

Good afternoon everyone!

Question, on insta when trying to send an order, it says that the stops are wrong.

Here is the line itself:

OrderSend(Symbol(),OP_BUYSTOP,Lots,HiP,3,0,0,NULL,111,0,clrBlue);

Stop Loss and Take Points have 0. If I set a number in Stop Loss, everything is normal.

I don't need Stop Loss. What should I do?

This is not a problem of StopLoss, but of the opening price of a pending order. If the price of the pending order is incorrect, error 130 comes in.
 
Kot:


The line is trending. Changed the properties to a ray. It did not help. Ideally the price should be displayed regardless of the position of the zero bar (top, bottom).

This code doesn't work either.

int start() {

double pr=ObjectGetValueByShift("line",0);

If (Bid==pr){

Alert (pr);}

return(0);}


Did you type the line name correctly?

Try this script, and show what it says in the logs.

void OnStart()
  {
     double pr;
     int obj_total=ObjectsTotal(); 
     string name;
     int i; 
     
   for(i=0;i<obj_total;i++) 
     { 
      name=ObjectName(i); 
      if(ObjectType(name)!=OBJ_TREND) continue; 
      PrintFormat("Объект %d:     Имя объекта - %s",i,name); 
      pr=ObjectGetValueByShift(name,0);
      PrintFormat("Объект %d:     Цена - %.5f",i,pr);
      
     } 
  }
 

We have a task. Data from the indicators on the higher timeframes is called into the iCustom Expert Advisor. Let's call their support and resistance lines.

Suppose the three figures x1 x2 x3. Please help me to write code that draws lines with these three figures directly in EA.

I tried ObjCreate (I want them to be drawn on a chart as points on every tick, but nothing worked)

To clarify, 3 separate lines. I would not link to mql4 primer. Just share the working code

Основы тестирования в MetaTrader 5
Основы тестирования в MetaTrader 5
  • 2011.03.28
  • MetaQuotes Software Corp.
  • www.mql5.com
В чем различия между тремя режимами тестирования в MetaTrader 5 и на что обратить внимание? Как происходит тестирование эксперта, торгующего одновременно на нескольких инструментах? Когда и как вычисляются значения индикаторов при тестировании и как обрабатываются события? Как синхронизировать бары с разных инструментов при тестировании в режиме "Только цены открытия"? Статья призвана дать ответы на эти и многие другие вопросы.
 
Artyom Trishkin:

In this thread I want to begin to help those who really want to understand and learn programming in the new MQL4 and want to easily switch to MQL5 - the languages are very similar.

This will be a good place to discuss tasks, algorithms of their solution and any other questions concerning MT programming.

I hope that other experienced participants of our forum will join the discussion of this issue and the branch will be interesting for everybody.


Here is the task. To the iCustom Expert Advisor, we will call the data of the indicators that stand on the higher timeframes. Let's call their support and resistance lines.

Suppose the three figures x1 x2 x3. Please help me to write code that draws lines with these three figures directly in EA.

I tried ObjCreate (I want them to be drawn on a chart as points onevery tick, but nothing worked)

To clarify, 3 separate lines. Please do not refer to mql4 tutorial. Just share the working code

Основы тестирования в MetaTrader 5
Основы тестирования в MetaTrader 5
  • 2011.03.28
  • MetaQuotes Software Corp.
  • www.mql5.com
В чем различия между тремя режимами тестирования в MetaTrader 5 и на что обратить внимание? Как происходит тестирование эксперта, торгующего одновременно на нескольких инструментах? Когда и как вычисляются значения индикаторов при тестировании и как обрабатываются события? Как синхронизировать бары с разных инструментов при тестировании в режиме "Только цены открытия"? Статья призвана дать ответы на эти и многие другие вопросы.
 
BoBoforex:

We have a task. Data from the indicators on the higher timeframes is called into the iCustom Expert Advisor. Let's call their support and resistance lines.

Suppose the three figures x1 x2 x3. Please help me to write code that draws lines with these three figures directly in EA.

I tried ObjCreate (I want them to be drawn on a chart as points onevery tick, but nothing worked)

To clarify, 3 separate lines. Please do not refer to mql4 tutorial. Just share the code that works.


The function

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 30.03.2008                                                     |
//|  Описание : Установка объекта OBJ_HLINE горизонтальная линия               |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cl - цвет линии                                                         |
//|    nm - наименование               ("" - время открытия текущего бара)     |
//|    p1 - ценовой уровень            (0  - Bid)                              |
//|    st - стиль линии                (0  - простая линия)                    |
//|    wd - ширина линии               (1  - по умолчанию)                     |
//+----------------------------------------------------------------------------+
void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=1) {
  if (nm=="") nm=DoubleToStr(Time[0], 0);
  if (p1<=0) p1=Bid;
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0);
  ObjectSet(nm, OBJPROP_PRICE1, p1);
  ObjectSet(nm, OBJPROP_COLOR , cl);
  ObjectSet(nm, OBJPROP_STYLE , st);
  ObjectSet(nm, OBJPROP_WIDTH , wd);
}

Place it outside void OnTick() function

And this is inside void OnTick()

  SetHLine(clrRed,"x1",x1); 
  SetHLine(clrRed,"x2",x2);
  SetHLine(clrRed,"x3",x3);  
 

Please help - I can't understand why I get zero when calculating the VesMass array in i>0 values ?

   int NumberTotal=3;
   int VesTotal=NumberTotal;//всего веслов в массиве
   double VesMass[];//массив с весами
   ArrayResize(VesMass,VesTotal);



   for(int i=0;i<VesTotal;i++)
     {
      if(i==0)
        {
         VesMass[i]=1;
         Print("VesMass ",i,"=",VesMass[i]);
        }
      if(i>0)
        {
         VesMass[i]=VesMass[i-1]*(4/5);
         Print("VesMass ",i-1,"=",VesMass[i-1]);
         Print("VesMass ",i,"=",VesMass[i]);
        }
     }
 
Alexey Viktorov:
This is not the problem of Stop Loss but of the open price of the pending order. If the price of the pending order is incorrect, the error is 130.


I've tried to place the pending order within double spread of the price. Only then the error disappears. I don't understand if this is correct?

For example, BUYSTOP order is set at 60 points of Bida. TakeProfit also does not allow to be set less by the value of spread.

I do not understand why it is so. It does not work on the real account but works in the demo mode.

Reason: