Wishes for MT5 - page 58

 
Urain:

No longer relevant, except as a matter of convenience.

int scale =(int)ChartGetInteger(chart_id,CHART_SCALE);
int pointer_per_bar=pow(2,scale);// количество пикселей на бар
// остальное можно высчитать из первого видимого бара, и ширины графика в пикселях.

О! Thank you, Nikolai! Can you finish it up? I mean, to the implementation of 4 specific functions:

int  ChartGetX(datetime T);

int  ChartGetY(double P);

datetime ChartGetTime(int X);

double ChartGetPrice(int Y);

Looks like you've got the puzzle worked out already, and I'll have to fiddle around for a long time. I'd be very grateful if you could do it.

 

Renat:

Trading several Expert Advisors on one symbol is nonsense.

This is no more delusional than the possibility of placing several indicators on one chart.

The very existence in MT4 of the ability to create, with one click, any complex structures from the Expert Advisors, to create any portfolios from them is grandiose.

To have this feature in five, make a trading class with support for virtual division of the trading account into sub-accounts

Or create in the terminal an opportunity to add your own virtual symbol on the basis of the existing ones.

 

Maybe I am behind of the new features of MT5, but I would like to be able to display charts by X and Y coordinates, and not by bars and price, if such a possibility already exists, advise please, if not, I think it is easy to implement using OBJ_CHART graphical object with a certain symbol/tool XY_Symbol

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов - Документация по MQL5
 
MetaDriver:

О! Thank you, Nikolai! Can you finish up to the end? I mean to the implementation of 4 specific functions:

Looks like you've got the puzzle worked out already, and I'll have to fiddle with it for a long time. I'd be very grateful if you could do it.

Somewhere like this. If you need a different angle, this can be recalculated from the pixel dimensions of the window.

//+------------------------------------------------------------------+
//| Преобразование координат. Верхний левый угол привязки            |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| time to X                                                        |
//+------------------------------------------------------------------+
int WindowGetX(long chart_id,datetime T)
  {
   datetime temp[]; int bar=(int)ChartGetInteger(chart_id,CHART_FIRST_VISIBLE_BAR);
   CopyTime(ChartSymbol(chart_id),ChartPeriod(chart_id),bar,1,temp);
   return((int)NormalizeDouble(
          ((T-temp[0])/(double)PeriodSeconds(ChartPeriod(chart_id)))*
          pow(2,ChartGetInteger(chart_id,CHART_SCALE)),0));
  };
//+------------------------------------------------------------------+
//| price to Y                                                       |
//+------------------------------------------------------------------+
int WindowGetY(long chart_id,double P)
  {
   return((int)((ChartGetDouble(chart_id,CHART_PRICE_MAX)-P)*
          (ChartGetInteger(chart_id,CHART_HEIGHT_IN_PIXELS)/
          (ChartGetDouble(chart_id,CHART_PRICE_MAX)-ChartGetDouble(chart_id,CHART_PRICE_MIN)))));
  };
//+------------------------------------------------------------------+
//| X to time                                                        |
//+------------------------------------------------------------------+
datetime WindowGetTime(long chart_id,int X)
  {
   datetime temp[]; int bar=(int)ChartGetInteger(chart_id,CHART_FIRST_VISIBLE_BAR);
   CopyTime(ChartSymbol(chart_id),ChartPeriod(chart_id),bar,1,temp);
   return((datetime)(temp[0]+
          (X/(double)pow(2,ChartGetInteger(chart_id,CHART_SCALE)))*
          PeriodSeconds(ChartPeriod(chart_id))));
  };
//+------------------------------------------------------------------+
//| Y to price                                                       |
//+------------------------------------------------------------------+
double WindowGetPrice(long chart_id,int Y)
  {
   return(ChartGetDouble(chart_id,CHART_PRICE_MAX)-Y/
          (ChartGetInteger(chart_id,CHART_HEIGHT_IN_PIXELS)/
          ChartGetDouble(chart_id,CHART_PRICE_MAX)-ChartGetDouble(chart_id,CHART_PRICE_MIN)));
  };

Example call.

void OnStart()
  {
   datetime T=StringToTime("2011.02.25 18:12");
   double P=1.37831;
   Object(ChartID(),T,P);
  }
//+------------------------------------------------------------------+
void Object(long chart_id,datetime T,double P)
  {
   int x=WindowGetX(chart_id,T);
   int y=WindowGetY(chart_id,P);
   string name="Button";
   if(ObjectCreate(chart_id,name,OBJ_BUTTON,0,0,0,0,0))
     {//---
      ObjectSetInteger(chart_id,name,OBJPROP_BACK,1);
      ObjectSetInteger(chart_id,name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(chart_id,name,OBJPROP_STATE,false);
      //--- привяжем кнопку к правому верхнему углу графика
      ObjectSetInteger(chart_id,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
      //--- теперь настроим свойства объекта      
      ObjectSetInteger(chart_id,name,OBJPROP_XSIZE,40);
      ObjectSetInteger(chart_id,name,OBJPROP_YSIZE,40);
      ObjectSetInteger(chart_id,name,OBJPROP_BGCOLOR,Silver);
      ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,y);
     }
  }
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки - Документация по MQL5
 
Again, though, it would be better to have these functions as standard. Then all language users would know about them, not just those who read this thread.
 
Corrected the code post, described as separate functions (without class) and changed the binding angle.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Угол привязки - Документация по MQL5
 
Urain:
Although again, it would be better to have these functions as standard. Then all language users would know about them, not just those who read this thread.

Thank you!
 
MetaDriver:
Thank you!
Put the checks in, because sometimes there is no data and you get a division by zero.
 

I would like to see a standard implementation of the function searching for a bar number at a given time.

Right now I'm implementing it with CArrayLong. But in this case I have to load a lot of data which already exists in the chart itself. In fact it duplicates the memory. I think it would work much faster in a standard form.

 
Urain:
Put the checks in, because sometimes there is no data and you get a division by zero.
OK.
Reason: