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

 

Hi all!

1) Compiled the EA.

2) Run it in tester.

3) There are three entries in the log:

2020.10.25 20:06:08.484 2020.09.24 00:00:00 OVERLOAD test started

2020.10.25 20:06:07.015 TestGenerator: current spread 7 used
2020.10.25 20:05:51.296 Expert UPDATE GBPUSD,M1: loaded successfully


4)Visualization stays in place.

Whatever logical mistake may have been made, the trades will not be executed, for example, but the tester should start counting the bars. But the chart freezes and stands still.

I have tried several other Expert Advisors, and they all work.

When I run this one everything stops.

Has anybody had such a problem? How to fix it?

 
Andrey Ilinykh:

If you write calculated values to a log or file, how does that help?

Find the error, form an algorithm.

 
Alexey Viktorov:

Well, you can work out the angle with a tangent. And you don't really need an angle per se, you just need a tangent.

The tangent is in any case a kilometre per hour or a point per mile or a thousand points per day and that's the speed. The dimensionality of the graph. and the tangent on it is the angle tied to the ordinate and abscissa dimensions. This is the place to start.

 
Aleksei Stepanenko:

Yes, again the speed is only units: pips per minute. As for weekends and holes, I've decided: what candles are on the chart is the time interval, and what is not (days/hours), it doesn't exist. Because if we take into account weekends, and the price stands still at that time, the speed will noticeably decrease without any reason. But then again, that's to each his own :)

Why fear speed. It's just a convention to give types.
As a variant of the angle definition function:

struct PointPriceTime
  {
   double            price;
   datetime          time;
                     PointPriceTime(double p, datetime t) { price=p; time=t; };
   void              Set(double p, datetime t){ price=p; time=t;};
                     PointPriceTime(PointPriceTime &p){ price=p.price; time=p.time; };
                     PointPriceTime() { price=0.0; time=0; };
  };

double Angle(PointPriceTime &p1,PointPriceTime &p2) // возвращает угол в градусах в приведенной системе координат price-price, где по оси X 
  {                                                 // расстояние между x1 и  x2  = N*_Point, где N - количество минутных баров во временном промежутке отрезка. 
   static int tf[9]= {PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1,PERIOD_MN1};
   int i=0;
   while(i<9 && SeriesInfoInteger(_Symbol,tf[i],SERIES_FIRSTDATE)>p1.time)
      i++;
   if(i==9)
     {
      Print("Время левой границы вне диапазона исторических данных");
      return DBL_MAX;
     }
   int bar1 = iBarShift(_Symbol,tf[i],p1.time);
   int bar2 = iBarShift(_Symbol,tf[i],p2.time);
   if(bar1==bar2)
      return 0.0;
   return atan((p2.price-p1.price)/((bar1-bar2)*PeriodSeconds(tf[i])*_Point/60))*180/M_PI;
  }

After MT5 the feeling of MT4 is just awful. The access to the history is somehow emasculated. I am not even speaking about the ticks.



Files:
Angle.mq4  11 kb
iCanvas.mqh  49 kb
 

Please advise whether there is a possibility to manage programmatically the display of trade level descriptions on the chart. Is it possible to disable them using MQL4 tools (while leaving trading levels on the chart) or change them?


I need to visually mark some trading levels providing them with their own descriptions. For that I create horizontal lines that are similar in style to trade levels but differ in colour. I set a description for them (OBJPROP_TEXT) and enable displaying object descriptions on the chart (ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,true)). In this case, the description I have created is superimposed on what is shown in the screenshot and as a result neither of them is legible.

Is it possible to disable or change the descriptions of trading levels created by the terminal? Are these descriptions accessible from the MQL program?

 
Janis Ozols:

Please advise whether there is a possibility to manage programmatically the display of trade level descriptions on the chart. Is it possible to disable them using MQL4 tools (while leaving trading levels on the chart) or change them?


I need to visually mark some trading levels providing them with their own descriptions. For that I create horizontal lines that are similar in style to trade levels but differ in colour. I set a description for them (OBJPROP_TEXT) and enable displaying object descriptions on the chart (ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,true)). In this case, the description I have created is superimposed on what is shown in the screenshot and as a result neither of them is legible.

Is it possible to disable or change the descriptions of trading levels created by the terminal? Are these descriptions accessible from within the MQL program?

Yes, there is,

uncheck the checkbox.

1

 
Alekseu Fedotov:

You can,
uncheck the box.

If you uncheck this box, then the trading levels (lines) themselves disappear from the chart along with their descriptions.

By asking the question, I was trying to emphasize that I do not want to remove the lines, I only need to change or delete their descriptions from the chart (shown by arrows in the screenshot).

 
Janis Ozols:

If you uncheck this box, then the trading levels(lines) disappear from the chart along with their descriptions.

By asking the question, I was trying to emphasize that I do not want to remove the lines, I only need to change or delete their descriptions from the chart (shown by arrows in the screenshot).

You don't need them, you create your lines on those places

 
Vitaly Muzichenko:

You don't need them, you create your lines in those places.

I only want to highlight some of the existing levels (for the example shown in the screenshot, the uppermost one), and leave the others as they are.

If it is impossible to access the descriptions of these levels programmatically, then probably we will have to disable the levels themselves and then on each tick poll the terminal to draw them independently by highlighting the appropriate levels in another colour and providing them with a different description. And there are not only open levels, but also stop-losses and take-profits that also have to be drawn.

Perhaps there is a more trivial way to disable the description of trading levels (leaving only lines) or change them?

 

Can you please explain in plain language what the difference between these functions is?

//+------------------------------------------------------------------+
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 CounterOrderTradeType(ENUM_ORDER_TYPE order_type)
  {
   int cnt=0;
   for(int pos=OrdersTotal()-1;pos>=0;pos--)
      if(OrderSelect(pos,SELECT_BY_POS)==true)
         if(OrderSymbol()==_Symbol)
            if(OrderType()==order_type)
               cnt++;
   return (cnt);
  }
//+------------------------------------------------------------------+
Reason: