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

 
Volodymyr Zubov #:

Always have to think about power cuts and so on...

An EA from history should be configured and working at any time.

This is when the robot is a really working trading system. It's too early for beginners. They need to prescribe a basic algorithm and test the trading system, for a start.

 
законопослушный гражданин possible loss of data due to type conversion


double openPrice()
  {
   double OP = dMA;
   if (GetLotSize()>LotControl) OP = dMA + Deviation * _Point;
   return(OP);
  }
 
Nerd Trader #:

Made a line follow the mouse cursor after pressing a button through draw and delete

Maybe there is another way? Because the processor cooler starts making noise :)

Fine. Delete, create. Create, delete. And why is the CPU making noise... :)

But we won't open the documentation and read about such beautiful functions as ObjectSetInteger and ObjectSetDouble...

 
Nerd Trader #:

Made a line follow the mouse cursor after pressing a button through draw and delete

Maybe there is another way? The CPU cooler is starting to get noisy :)

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
  {    
   if(ObjectGetInteger(0,"button_bs",OBJPROP_STATE))
     {
      int      x     =(int)lparam;
      int      y     =(int)dparam;
      datetime dt    =0;
      double   price =0;
      int      window=0;
     
      if(id == CHARTEVENT_MOUSE_MOVE)
        {
         if(ChartXYToTimePrice(0,x,y,window,dt,price))
           {
            if(ObjectMove(0,"H Line",window,dt,price))
              {
               ChartRedraw(0);
              }
           }
        }
     }
   else
     {
      ObjectDelete(0,"H Line");
     }
  }
 
MakarFX #:
ObjectMove is shifting, not setting new coordinates...? At least the documentation says it does...
 
MakarFX #:

just what I need, thank you.


Mihail Matkovskij #:

That's great. Delete, create. Create, delete. And why is the CPU making noise... :)

But we won't open the documentation and read about such nice functions as ObjectSetInteger and ObjectSetDouble...

I understand very well why the CPU is loaded smartly. When they put google search into *.chm, you'll write what I open and where I do not read.

 
Nerd Trader #:

just what I need, thank you.


I know exactly why the CPU is loading smarty-pants. When they put google search in *.chm, then you can write me what I open and where I don't read.

What google search? :)

https://www.mql5.com/ru/docs/objects

Документация по MQL5: Графические объекты
Документация по MQL5: Графические объекты
  • www.mql5.com
Графические объекты - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Removed the line creation from the mouse move event, still no better - the cooler is noisy, I guess that's as it should be.
   if(ObjectGetInteger(0,"button_bs",OBJPROP_STATE)){
      int      x     =(int)lparam;
      int      y     =(int)dparam;
      datetime dt    =0;
      double   price =0;
      int      window=0;

      if(ChartXYToTimePrice(0,x,y,window,dt,price)){
        ObjectCreate(0,"H Line",OBJ_HLINE,window,dt,price);
        if(id == CHARTEVENT_MOUSE_MOVE)
          if(ObjectMove(0,"H Line",window,dt,price))
            ChartRedraw(0);
      }
      else{
        ObjectDelete(0,"H Line");
      }
  }
 
Nerd Trader #:
Removed line creation from mouse move event, nevertheless it didn't get any better - the cooler is noisy, I guess it should be.

Then, dusting, lubricating the bearings, replacing the thermal paste... :)

 
Mihail Matkovskij #:

Then, dusting, lubricating the bearings, replacing the thermal paste... :)

But seriously, ChartRedraw gets called more than 24 times per second...

And ObjectCreate! The horror...